@promptbook/components 0.100.0-24

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 (780) hide show
  1. package/README.md +570 -0
  2. package/esm/index.es.js +1953 -0
  3. package/esm/index.es.js.map +1 -0
  4. package/esm/typings/books/index.d.ts +131 -0
  5. package/esm/typings/servers.d.ts +40 -0
  6. package/esm/typings/src/_packages/anthropic-claude.index.d.ts +16 -0
  7. package/esm/typings/src/_packages/azure-openai.index.d.ts +10 -0
  8. package/esm/typings/src/_packages/browser.index.d.ts +12 -0
  9. package/esm/typings/src/_packages/cli.index.d.ts +64 -0
  10. package/esm/typings/src/_packages/components.index.d.ts +4 -0
  11. package/esm/typings/src/_packages/core.index.d.ts +322 -0
  12. package/esm/typings/src/_packages/deepseek.index.d.ts +10 -0
  13. package/esm/typings/src/_packages/documents.index.d.ts +8 -0
  14. package/esm/typings/src/_packages/editable.index.d.ts +90 -0
  15. package/esm/typings/src/_packages/fake-llm.index.d.ts +6 -0
  16. package/esm/typings/src/_packages/google.index.d.ts +12 -0
  17. package/esm/typings/src/_packages/javascript.index.d.ts +10 -0
  18. package/esm/typings/src/_packages/legacy-documents.index.d.ts +8 -0
  19. package/esm/typings/src/_packages/markdown-utils.index.d.ts +48 -0
  20. package/esm/typings/src/_packages/markitdown.index.d.ts +8 -0
  21. package/esm/typings/src/_packages/node.index.d.ts +24 -0
  22. package/esm/typings/src/_packages/ollama.index.d.ts +14 -0
  23. package/esm/typings/src/_packages/openai.index.d.ts +32 -0
  24. package/esm/typings/src/_packages/pdf.index.d.ts +14 -0
  25. package/esm/typings/src/_packages/remote-client.index.d.ts +16 -0
  26. package/esm/typings/src/_packages/remote-server.index.d.ts +12 -0
  27. package/esm/typings/src/_packages/templates.index.d.ts +4 -0
  28. package/esm/typings/src/_packages/types.index.d.ts +638 -0
  29. package/esm/typings/src/_packages/utils.index.d.ts +170 -0
  30. package/esm/typings/src/_packages/vercel.index.d.ts +6 -0
  31. package/esm/typings/src/_packages/website-crawler.index.d.ts +8 -0
  32. package/esm/typings/src/_packages/wizard.index.d.ts +64 -0
  33. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +30 -0
  34. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.test.d.ts +1 -0
  35. package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +26 -0
  36. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +38 -0
  37. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +39 -0
  38. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/FrontendRAGService.d.ts +48 -0
  39. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +51 -0
  40. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/RAGService.d.ts +54 -0
  41. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/BaseKnowledgeProcessor.d.ts +45 -0
  42. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/PdfProcessor.d.ts +31 -0
  43. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/ProcessorFactory.d.ts +23 -0
  44. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/TextProcessor.d.ts +18 -0
  45. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/types.d.ts +56 -0
  46. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/utils/ragHelper.d.ts +34 -0
  47. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +44 -0
  48. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +56 -0
  49. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +39 -0
  50. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +49 -0
  51. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +46 -0
  52. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +44 -0
  53. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +44 -0
  54. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +38 -0
  55. package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +52 -0
  56. package/esm/typings/src/book-2.0/commitments/_base/BookCommitment.d.ts +5 -0
  57. package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +48 -0
  58. package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +22 -0
  59. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +19 -0
  60. package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +37 -0
  61. package/esm/typings/src/book-2.0/commitments/_misc/AgentSourceParseResult.d.ts +18 -0
  62. package/esm/typings/src/book-2.0/commitments/_misc/ParsedCommitment.d.ts +22 -0
  63. package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirements.d.ts +61 -0
  64. package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirementsWithCommitments.d.ts +35 -0
  65. package/esm/typings/src/book-2.0/commitments/_misc/createCommitmentRegex.d.ts +20 -0
  66. package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +24 -0
  67. package/esm/typings/src/book-2.0/commitments/_misc/removeCommentsFromSystemMessage.d.ts +11 -0
  68. package/esm/typings/src/book-2.0/commitments/index.d.ts +56 -0
  69. package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +39 -0
  70. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +26 -0
  71. package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +13 -0
  72. package/esm/typings/src/cli/cli-commands/about.d.ts +14 -0
  73. package/esm/typings/src/cli/cli-commands/common/handleActionErrors.d.ts +11 -0
  74. package/esm/typings/src/cli/cli-commands/hello.d.ts +14 -0
  75. package/esm/typings/src/cli/cli-commands/list-models.d.ts +13 -0
  76. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +13 -0
  77. package/esm/typings/src/cli/cli-commands/login.d.ts +14 -0
  78. package/esm/typings/src/cli/cli-commands/make.d.ts +16 -0
  79. package/esm/typings/src/cli/cli-commands/prettify.d.ts +15 -0
  80. package/esm/typings/src/cli/cli-commands/run.d.ts +17 -0
  81. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
  82. package/esm/typings/src/cli/cli-commands/start-server.d.ts +13 -0
  83. package/esm/typings/src/cli/cli-commands/test-command.d.ts +16 -0
  84. package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +7 -0
  85. package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +28 -0
  86. package/esm/typings/src/cli/main.d.ts +16 -0
  87. package/esm/typings/src/cli/promptbookCli.d.ts +13 -0
  88. package/esm/typings/src/cli/test/ptbk.d.ts +5 -0
  89. package/esm/typings/src/cli/test/ptbk.test.d.ts +1 -0
  90. package/esm/typings/src/collection/PipelineCollection.d.ts +25 -0
  91. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +37 -0
  92. package/esm/typings/src/collection/collectionToJson.d.ts +13 -0
  93. package/esm/typings/src/collection/collectionToJson.test.d.ts +7 -0
  94. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +65 -0
  95. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.test.d.ts +1 -0
  96. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +13 -0
  97. package/esm/typings/src/collection/constructors/createCollectionFromJson.test.d.ts +1 -0
  98. package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +23 -0
  99. package/esm/typings/src/collection/constructors/createCollectionFromPromise.test.d.ts +1 -0
  100. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +29 -0
  101. package/esm/typings/src/collection/constructors/createSubcollection.d.ts +13 -0
  102. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +11 -0
  103. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommand.test.d.ts +1 -0
  104. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +9 -0
  105. package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +17 -0
  106. package/esm/typings/src/commands/EXPECT/expectCommand.test.d.ts +1 -0
  107. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +11 -0
  108. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +10 -0
  109. package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +27 -0
  110. package/esm/typings/src/commands/FOREACH/foreachCommand.test.d.ts +1 -0
  111. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +12 -0
  112. package/esm/typings/src/commands/FORMAT/FormatCommand.d.ts +9 -0
  113. package/esm/typings/src/commands/FORMAT/formatCommand.test.d.ts +1 -0
  114. package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +9 -0
  115. package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +11 -0
  116. package/esm/typings/src/commands/FORMFACTOR/formfactorCommand.test.d.ts +1 -0
  117. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +11 -0
  118. package/esm/typings/src/commands/JOKER/JokerCommand.d.ts +11 -0
  119. package/esm/typings/src/commands/JOKER/jokerCommand.test.d.ts +1 -0
  120. package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +9 -0
  121. package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +11 -0
  122. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommand.test.d.ts +1 -0
  123. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +12 -0
  124. package/esm/typings/src/commands/KNOWLEDGE/utils/knowledgeSourceContentToName.d.ts +11 -0
  125. package/esm/typings/src/commands/KNOWLEDGE/utils/knowledgeSourceContentToName.test.d.ts +4 -0
  126. package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +14 -0
  127. package/esm/typings/src/commands/MODEL/modelCommand.test.d.ts +1 -0
  128. package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +10 -0
  129. package/esm/typings/src/commands/PARAMETER/ParameterCommand.d.ts +15 -0
  130. package/esm/typings/src/commands/PARAMETER/parameterCommand.test.d.ts +1 -0
  131. package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +9 -0
  132. package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +13 -0
  133. package/esm/typings/src/commands/PERSONA/personaCommand.test.d.ts +1 -0
  134. package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +9 -0
  135. package/esm/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +11 -0
  136. package/esm/typings/src/commands/POSTPROCESS/postprocessCommand.test.d.ts +1 -0
  137. package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +9 -0
  138. package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +11 -0
  139. package/esm/typings/src/commands/SECTION/sectionCommand.test.d.ts +1 -0
  140. package/esm/typings/src/commands/SECTION/sectionCommandParser.d.ts +20 -0
  141. package/esm/typings/src/commands/URL/UrlCommand.d.ts +10 -0
  142. package/esm/typings/src/commands/URL/urlCommand.test.d.ts +1 -0
  143. package/esm/typings/src/commands/URL/urlCommandParser.d.ts +9 -0
  144. package/esm/typings/src/commands/X_ACTION/ActionCommand.d.ts +9 -0
  145. package/esm/typings/src/commands/X_ACTION/actionCommand.test.d.ts +1 -0
  146. package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +12 -0
  147. package/esm/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +9 -0
  148. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommand.test.d.ts +1 -0
  149. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +12 -0
  150. package/esm/typings/src/commands/_BOILERPLATE/BoilerplateCommand.d.ts +10 -0
  151. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommand.test.d.ts +1 -0
  152. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +11 -0
  153. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +11 -0
  154. package/esm/typings/src/commands/_common/getParserForCommand.test.d.ts +1 -0
  155. package/esm/typings/src/commands/_common/parseCommand.d.ts +12 -0
  156. package/esm/typings/src/commands/_common/parseCommand.test.d.ts +1 -0
  157. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +12 -0
  158. package/esm/typings/src/commands/_common/stringifyCommand.test.d.ts +1 -0
  159. package/esm/typings/src/commands/_common/types/Command.d.ts +6 -0
  160. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +205 -0
  161. package/esm/typings/src/commands/_common/types/CommandType.d.ts +17 -0
  162. package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +13 -0
  163. package/esm/typings/src/commands/index.d.ts +9 -0
  164. package/esm/typings/src/config.d.ts +313 -0
  165. package/esm/typings/src/config.test.d.ts +4 -0
  166. package/esm/typings/src/constants.d.ts +76 -0
  167. package/esm/typings/src/conversion/archive/loadArchive.d.ts +16 -0
  168. package/esm/typings/src/conversion/archive/saveArchive.d.ts +18 -0
  169. package/esm/typings/src/conversion/compilePipeline.d.ts +25 -0
  170. package/esm/typings/src/conversion/compilePipeline.test.d.ts +1 -0
  171. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +21 -0
  172. package/esm/typings/src/conversion/parsePipeline.d.ts +30 -0
  173. package/esm/typings/src/conversion/parsePipeline.test.d.ts +1 -0
  174. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +18 -0
  175. package/esm/typings/src/conversion/prettify/PrettifyOptions.d.ts +13 -0
  176. package/esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts +12 -0
  177. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +30 -0
  178. package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +15 -0
  179. package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.test.d.ts +1 -0
  180. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +23 -0
  181. package/esm/typings/src/conversion/validation/pipelineStringToJson-parseErrors.test.d.ts +4 -0
  182. package/esm/typings/src/conversion/validation/validatePipeline-logicErrors.test.d.ts +4 -0
  183. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +42 -0
  184. package/esm/typings/src/conversion/validation/validatePipeline.test.d.ts +4 -0
  185. package/esm/typings/src/dialogs/callback/CallbackInterfaceTools.d.ts +17 -0
  186. package/esm/typings/src/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +14 -0
  187. package/esm/typings/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +22 -0
  188. package/esm/typings/src/dialogs/user-interface-execution-tools.test.d.ts +1 -0
  189. package/esm/typings/src/errors/0-BoilerplateError.d.ts +12 -0
  190. package/esm/typings/src/errors/0-index.d.ts +94 -0
  191. package/esm/typings/src/errors/AbstractFormatError.d.ts +11 -0
  192. package/esm/typings/src/errors/AuthenticationError.d.ts +9 -0
  193. package/esm/typings/src/errors/CollectionError.d.ts +9 -0
  194. package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +9 -0
  195. package/esm/typings/src/errors/ExpectError.d.ts +12 -0
  196. package/esm/typings/src/errors/KnowledgeScrapeError.d.ts +9 -0
  197. package/esm/typings/src/errors/LimitReachedError.d.ts +9 -0
  198. package/esm/typings/src/errors/MissingToolsError.d.ts +9 -0
  199. package/esm/typings/src/errors/NotFoundError.d.ts +9 -0
  200. package/esm/typings/src/errors/NotYetImplementedError.d.ts +9 -0
  201. package/esm/typings/src/errors/ParseError.d.ts +12 -0
  202. package/esm/typings/src/errors/PipelineExecutionError.d.ts +14 -0
  203. package/esm/typings/src/errors/PipelineLogicError.d.ts +9 -0
  204. package/esm/typings/src/errors/PipelineUrlError.d.ts +9 -0
  205. package/esm/typings/src/errors/PromptbookFetchError.d.ts +9 -0
  206. package/esm/typings/src/errors/UnexpectedError.d.ts +9 -0
  207. package/esm/typings/src/errors/WrappedError.d.ts +10 -0
  208. package/esm/typings/src/errors/assertsError.d.ts +11 -0
  209. package/esm/typings/src/errors/utils/ErrorJson.d.ts +25 -0
  210. package/esm/typings/src/errors/utils/deserializeError.d.ts +7 -0
  211. package/esm/typings/src/errors/utils/deserializeError.test.d.ts +1 -0
  212. package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +6 -0
  213. package/esm/typings/src/errors/utils/serializeError.d.ts +7 -0
  214. package/esm/typings/src/errors/utils/serializeError.test.d.ts +1 -0
  215. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +12 -0
  216. package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +12 -0
  217. package/esm/typings/src/executables/apps/locateLibreoffice.test.d.ts +1 -0
  218. package/esm/typings/src/executables/apps/locatePandoc.d.ts +12 -0
  219. package/esm/typings/src/executables/apps/locatePandoc.test.d.ts +1 -0
  220. package/esm/typings/src/executables/locateApp.d.ts +33 -0
  221. package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
  222. package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +13 -0
  223. package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +13 -0
  224. package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +13 -0
  225. package/esm/typings/src/execution/AbstractTaskResult.d.ts +25 -0
  226. package/esm/typings/src/execution/AvailableModel.d.ts +46 -0
  227. package/esm/typings/src/execution/CommonToolsOptions.d.ts +28 -0
  228. package/esm/typings/src/execution/EmbeddingVector.d.ts +8 -0
  229. package/esm/typings/src/execution/Executables.d.ts +18 -0
  230. package/esm/typings/src/execution/ExecutionTask.d.ts +119 -0
  231. package/esm/typings/src/execution/ExecutionTools.d.ts +69 -0
  232. package/esm/typings/src/execution/FilesystemTools.d.ts +9 -0
  233. package/esm/typings/src/execution/LlmExecutionTools.d.ts +61 -0
  234. package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +11 -0
  235. package/esm/typings/src/execution/PipelineExecutor.d.ts +16 -0
  236. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +39 -0
  237. package/esm/typings/src/execution/PromptResult.d.ts +101 -0
  238. package/esm/typings/src/execution/PromptbookFetch.d.ts +12 -0
  239. package/esm/typings/src/execution/PromptbookFetch.test-type.d.ts +5 -0
  240. package/esm/typings/src/execution/ScriptExecutionTools.d.ts +39 -0
  241. package/esm/typings/src/execution/UncertainNumber.d.ts +19 -0
  242. package/esm/typings/src/execution/Usage.d.ts +33 -0
  243. package/esm/typings/src/execution/UserInterfaceTools.d.ts +46 -0
  244. package/esm/typings/src/execution/assertsTaskSuccessful.d.ts +14 -0
  245. package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +56 -0
  246. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +46 -0
  247. package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +10 -0
  248. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +48 -0
  249. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +51 -0
  250. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +27 -0
  251. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +70 -0
  252. package/esm/typings/src/execution/createPipelineExecutor/computeCosineSimilarity.d.ts +13 -0
  253. package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +35 -0
  254. package/esm/typings/src/execution/createPipelineExecutor/getContextForTask.d.ts +14 -0
  255. package/esm/typings/src/execution/createPipelineExecutor/getExamplesForTask.d.ts +10 -0
  256. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +42 -0
  257. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +48 -0
  258. package/esm/typings/src/execution/createPipelineExecutor/knowledgePiecesToString.d.ts +9 -0
  259. package/esm/typings/src/execution/embeddingVectorToString.d.ts +7 -0
  260. package/esm/typings/src/execution/execution-report/ExecutionPromptReportJson.d.ts +24 -0
  261. package/esm/typings/src/execution/execution-report/ExecutionReportJson.d.ts +41 -0
  262. package/esm/typings/src/execution/execution-report/ExecutionReportString.d.ts +16 -0
  263. package/esm/typings/src/execution/execution-report/ExecutionReportStringOptions.d.ts +25 -0
  264. package/esm/typings/src/execution/execution-report/countWorkingDuration.d.ts +7 -0
  265. package/esm/typings/src/execution/execution-report/countWorkingDuration.test.d.ts +1 -0
  266. package/esm/typings/src/execution/execution-report/executionReportJsonToString.d.ts +15 -0
  267. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +7 -0
  268. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +11 -0
  269. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +8 -0
  270. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +22 -0
  271. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +7 -0
  272. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +8 -0
  273. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +1 -0
  274. package/esm/typings/src/execution/translation/automatic-translate/translateMessages.d.ts +12 -0
  275. package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +13 -0
  276. package/esm/typings/src/execution/utils/addUsage.d.ts +9 -0
  277. package/esm/typings/src/execution/utils/addUsage.test.d.ts +1 -0
  278. package/esm/typings/src/execution/utils/checkExpectations.d.ts +29 -0
  279. package/esm/typings/src/execution/utils/checkExpectations.test.d.ts +1 -0
  280. package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +10 -0
  281. package/esm/typings/src/execution/utils/forEachAsync.d.ts +20 -0
  282. package/esm/typings/src/execution/utils/uncertainNumber.d.ts +10 -0
  283. package/esm/typings/src/execution/utils/usage-constants.d.ts +147 -0
  284. package/esm/typings/src/execution/utils/usageToHuman.d.ts +26 -0
  285. package/esm/typings/src/execution/utils/usageToWorktime.d.ts +20 -0
  286. package/esm/typings/src/execution/utils/usageToWorktime.test.d.ts +1 -0
  287. package/esm/typings/src/execution/utils/validatePromptResult.d.ts +53 -0
  288. package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +10 -0
  289. package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +10 -0
  290. package/esm/typings/src/formats/_common/FormatParser.d.ts +72 -0
  291. package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +66 -0
  292. package/esm/typings/src/formats/csv/CsvFormatError.d.ts +10 -0
  293. package/esm/typings/src/formats/csv/CsvFormatParser.d.ts +17 -0
  294. package/esm/typings/src/formats/csv/CsvSettings.d.ts +13 -0
  295. package/esm/typings/src/formats/csv/utils/csvParse.d.ts +12 -0
  296. package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +9 -0
  297. package/esm/typings/src/formats/csv/utils/isValidCsvString.test.d.ts +1 -0
  298. package/esm/typings/src/formats/index.d.ts +9 -0
  299. package/esm/typings/src/formats/json/JsonFormatParser.d.ts +19 -0
  300. package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +9 -0
  301. package/esm/typings/src/formats/json/utils/isValidJsonString.test.d.ts +1 -0
  302. package/esm/typings/src/formats/json/utils/jsonParse.d.ts +8 -0
  303. package/esm/typings/src/formats/text/TextFormatParser.d.ts +19 -0
  304. package/esm/typings/src/formats/xml/XmlFormatParser.d.ts +19 -0
  305. package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +9 -0
  306. package/esm/typings/src/formats/xml/utils/isValidXmlString.test.d.ts +1 -0
  307. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +15 -0
  308. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +49 -0
  309. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +10 -0
  310. package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +6 -0
  311. package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +45 -0
  312. package/esm/typings/src/formfactors/completion/CompletionFormfactorDefinition.d.ts +29 -0
  313. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +25 -0
  314. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +14 -0
  315. package/esm/typings/src/formfactors/image-generator/ImageGeneratorFormfactorDefinition.d.ts +24 -0
  316. package/esm/typings/src/formfactors/index.d.ts +170 -0
  317. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +21 -0
  318. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +26 -0
  319. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +25 -0
  320. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
  321. package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
  322. package/esm/typings/src/high-level-abstractions/index.d.ts +54 -0
  323. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +13 -0
  324. package/esm/typings/src/llm-providers/_common/filterModels.d.ts +15 -0
  325. package/esm/typings/src/llm-providers/_common/register/$llmToolsMetadataRegister.d.ts +13 -0
  326. package/esm/typings/src/llm-providers/_common/register/$llmToolsRegister.d.ts +13 -0
  327. package/esm/typings/src/llm-providers/_common/register/$provideEnvFilename.d.ts +12 -0
  328. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +19 -0
  329. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +27 -0
  330. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +59 -0
  331. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +41 -0
  332. package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +22 -0
  333. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +30 -0
  334. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +58 -0
  335. package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +17 -0
  336. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +49 -0
  337. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.test.d.ts +1 -0
  338. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +33 -0
  339. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +27 -0
  340. package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +19 -0
  341. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +22 -0
  342. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +17 -0
  343. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +36 -0
  344. package/esm/typings/src/llm-providers/_common/utils/pricing.d.ts +16 -0
  345. package/esm/typings/src/llm-providers/_common/utils/pricing.test.d.ts +1 -0
  346. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +63 -0
  347. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +21 -0
  348. package/esm/typings/src/llm-providers/_multiple/playground/playground.d.ts +5 -0
  349. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +66 -0
  350. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +31 -0
  351. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +24 -0
  352. package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +18 -0
  353. package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.test.d.ts +4 -0
  354. package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +19 -0
  355. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +7 -0
  356. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +14 -0
  357. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +16 -0
  358. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +67 -0
  359. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +37 -0
  360. package/esm/typings/src/llm-providers/azure-openai/createAzureOpenAiExecutionTools.d.ts +15 -0
  361. package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +6 -0
  362. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +14 -0
  363. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +15 -0
  364. package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +9 -0
  365. package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +14 -0
  366. package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +23 -0
  367. package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +14 -0
  368. package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +15 -0
  369. package/esm/typings/src/llm-providers/google/GoogleExecutionToolsOptions.d.ts +9 -0
  370. package/esm/typings/src/llm-providers/google/createGoogleExecutionTools.d.ts +14 -0
  371. package/esm/typings/src/llm-providers/google/google-models.d.ts +23 -0
  372. package/esm/typings/src/llm-providers/google/register-configuration.d.ts +14 -0
  373. package/esm/typings/src/llm-providers/google/register-constructor.d.ts +15 -0
  374. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +15 -0
  375. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +40 -0
  376. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +44 -0
  377. package/esm/typings/src/llm-providers/mocked/test/fakeTextToExpectations.test.d.ts +1 -0
  378. package/esm/typings/src/llm-providers/mocked/test/faked-completion.test.d.ts +1 -0
  379. package/esm/typings/src/llm-providers/mocked/test/joker.test.d.ts +4 -0
  380. package/esm/typings/src/llm-providers/mocked/test/mocked-chat.test.d.ts +5 -0
  381. package/esm/typings/src/llm-providers/mocked/test/mocked-completion.test.d.ts +4 -0
  382. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +44 -0
  383. package/esm/typings/src/llm-providers/ollama/OllamaExecutionToolsOptions.d.ts +23 -0
  384. package/esm/typings/src/llm-providers/ollama/createOllamaExecutionTools.d.ts +11 -0
  385. package/esm/typings/src/llm-providers/ollama/ollama-models.d.ts +14 -0
  386. package/esm/typings/src/llm-providers/ollama/playground/playground.d.ts +6 -0
  387. package/esm/typings/src/llm-providers/ollama/register-configuration.d.ts +14 -0
  388. package/esm/typings/src/llm-providers/ollama/register-constructor.d.ts +15 -0
  389. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +36 -0
  390. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +14 -0
  391. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +91 -0
  392. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionToolsOptions.d.ts +52 -0
  393. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +38 -0
  394. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +9 -0
  395. package/esm/typings/src/llm-providers/openai/computeOpenAiUsage.d.ts +18 -0
  396. package/esm/typings/src/llm-providers/openai/computeOpenAiUsage.test.d.ts +4 -0
  397. package/esm/typings/src/llm-providers/openai/createOpenAiAssistantExecutionTools.d.ts +15 -0
  398. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +74 -0
  399. package/esm/typings/src/llm-providers/openai/createOpenAiExecutionTools.d.ts +17 -0
  400. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +25 -0
  401. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +6 -0
  402. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +35 -0
  403. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +39 -0
  404. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +59 -0
  405. package/esm/typings/src/llm-providers/remote/playground/playground.d.ts +5 -0
  406. package/esm/typings/src/llm-providers/vercel/VercelExecutionToolsOptions.d.ts +23 -0
  407. package/esm/typings/src/llm-providers/vercel/VercelProvider.d.ts +13 -0
  408. package/esm/typings/src/llm-providers/vercel/createExecutionToolsFromVercelProvider.d.ts +8 -0
  409. package/esm/typings/src/llm-providers/vercel/playground/playground.d.ts +6 -0
  410. package/esm/typings/src/migrations/migratePipeline.d.ts +9 -0
  411. package/esm/typings/src/other/templates/getBookTemplates.d.ts +24 -0
  412. package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +10 -0
  413. package/esm/typings/src/personas/preparePersona.d.ts +17 -0
  414. package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +22 -0
  415. package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +14 -0
  416. package/esm/typings/src/pipeline/PipelineInterface/getPipelineInterface.d.ts +11 -0
  417. package/esm/typings/src/pipeline/PipelineInterface/isPipelineImplementingInterface.d.ts +27 -0
  418. package/esm/typings/src/pipeline/PipelineInterface/isPipelineInterfacesEqual.d.ts +10 -0
  419. package/esm/typings/src/pipeline/PipelineJson/CommonTaskJson.d.ts +103 -0
  420. package/esm/typings/src/pipeline/PipelineJson/DialogTaskJson.d.ts +13 -0
  421. package/esm/typings/src/pipeline/PipelineJson/Expectations.d.ts +40 -0
  422. package/esm/typings/src/pipeline/PipelineJson/KnowledgePieceJson.d.ts +73 -0
  423. package/esm/typings/src/pipeline/PipelineJson/KnowledgeSourceJson.d.ts +44 -0
  424. package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +98 -0
  425. package/esm/typings/src/pipeline/PipelineJson/PersonaJson.d.ts +47 -0
  426. package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +113 -0
  427. package/esm/typings/src/pipeline/PipelineJson/PreparationJson.d.ts +22 -0
  428. package/esm/typings/src/pipeline/PipelineJson/PromptTaskJson.d.ts +26 -0
  429. package/esm/typings/src/pipeline/PipelineJson/ScriptTaskJson.d.ts +20 -0
  430. package/esm/typings/src/pipeline/PipelineJson/SimpleTaskJson.d.ts +13 -0
  431. package/esm/typings/src/pipeline/PipelineJson/TaskJson.d.ts +11 -0
  432. package/esm/typings/src/pipeline/PipelineString.d.ts +11 -0
  433. package/esm/typings/src/pipeline/book-notation.d.ts +20 -0
  434. package/esm/typings/src/pipeline/isValidPipelineString.d.ts +13 -0
  435. package/esm/typings/src/pipeline/isValidPipelineString.test.d.ts +4 -0
  436. package/esm/typings/src/pipeline/prompt-notation.d.ts +31 -0
  437. package/esm/typings/src/pipeline/prompt-notation.test.d.ts +4 -0
  438. package/esm/typings/src/pipeline/validatePipelineString.d.ts +14 -0
  439. package/esm/typings/src/playground/playground.d.ts +5 -0
  440. package/esm/typings/src/postprocessing/utils/extractBlock.d.ts +16 -0
  441. package/esm/typings/src/postprocessing/utils/extractJsonBlock.d.ts +25 -0
  442. package/esm/typings/src/postprocessing/utils/extractJsonBlock.test.d.ts +1 -0
  443. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +51 -0
  444. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +18 -0
  445. package/esm/typings/src/prepare/isPipelinePrepared.test.d.ts +1 -0
  446. package/esm/typings/src/prepare/preparePipeline.d.ts +22 -0
  447. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +17 -0
  448. package/esm/typings/src/prepare/prepareTasks.d.ts +36 -0
  449. package/esm/typings/src/prepare/unpreparePipeline.d.ts +13 -0
  450. package/esm/typings/src/remote-server/RemoteServer.d.ts +23 -0
  451. package/esm/typings/src/remote-server/createRemoteClient.d.ts +10 -0
  452. package/esm/typings/src/remote-server/openapi-types.d.ts +626 -0
  453. package/esm/typings/src/remote-server/openapi.d.ts +581 -0
  454. package/esm/typings/src/remote-server/socket-types/_common/PromptbookServer_Error.d.ts +7 -0
  455. package/esm/typings/src/remote-server/socket-types/_subtypes/Identification.d.ts +59 -0
  456. package/esm/typings/src/remote-server/socket-types/_subtypes/identificationToPromptbookToken.d.ts +11 -0
  457. package/esm/typings/src/remote-server/socket-types/_subtypes/promptbookTokenToIdentification.d.ts +10 -0
  458. package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +17 -0
  459. package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Response.d.ts +17 -0
  460. package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Request.d.ts +17 -0
  461. package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Response.d.ts +12 -0
  462. package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts +17 -0
  463. package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Response.d.ts +12 -0
  464. package/esm/typings/src/remote-server/startRemoteServer.d.ts +25 -0
  465. package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +24 -0
  466. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +164 -0
  467. package/esm/typings/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +43 -0
  468. package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +20 -0
  469. package/esm/typings/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.d.ts +5 -0
  470. package/esm/typings/src/scrapers/_boilerplate/register-constructor.d.ts +15 -0
  471. package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +28 -0
  472. package/esm/typings/src/scrapers/_common/Converter.d.ts +25 -0
  473. package/esm/typings/src/scrapers/_common/Scraper.d.ts +60 -0
  474. package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +16 -0
  475. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +19 -0
  476. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.test.d.ts +1 -0
  477. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +12 -0
  478. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +15 -0
  479. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +13 -0
  480. package/esm/typings/src/scrapers/_common/register/$provideScriptingForNode.d.ts +11 -0
  481. package/esm/typings/src/scrapers/_common/register/$registeredScrapersMessage.d.ts +13 -0
  482. package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +13 -0
  483. package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +14 -0
  484. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +46 -0
  485. package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +13 -0
  486. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +35 -0
  487. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.test.d.ts +4 -0
  488. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +13 -0
  489. package/esm/typings/src/scrapers/_common/utils/promptbookFetch.d.ts +10 -0
  490. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +43 -0
  491. package/esm/typings/src/scrapers/document/DocumentScraper.test.d.ts +4 -0
  492. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +20 -0
  493. package/esm/typings/src/scrapers/document/playground/document-scraper-playground.d.ts +5 -0
  494. package/esm/typings/src/scrapers/document/register-constructor.d.ts +15 -0
  495. package/esm/typings/src/scrapers/document/register-metadata.d.ts +28 -0
  496. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +43 -0
  497. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.test.d.ts +4 -0
  498. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +21 -0
  499. package/esm/typings/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.d.ts +5 -0
  500. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +15 -0
  501. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +28 -0
  502. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +29 -0
  503. package/esm/typings/src/scrapers/markdown/MarkdownScraper.test.d.ts +4 -0
  504. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +20 -0
  505. package/esm/typings/src/scrapers/markdown/playground/markdown-scraper-playground.d.ts +5 -0
  506. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +15 -0
  507. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +28 -0
  508. package/esm/typings/src/scrapers/markitdown/MarkitdownScraper.d.ts +50 -0
  509. package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +22 -0
  510. package/esm/typings/src/scrapers/markitdown/playground/markitdown-scraper-playground.d.ts +5 -0
  511. package/esm/typings/src/scrapers/markitdown/register-constructor.d.ts +17 -0
  512. package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +28 -0
  513. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +41 -0
  514. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +21 -0
  515. package/esm/typings/src/scrapers/pdf/playground/pdf-scraper-playground.d.ts +5 -0
  516. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +15 -0
  517. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +28 -0
  518. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +50 -0
  519. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +21 -0
  520. package/esm/typings/src/scrapers/website/playground/website-scraper-playground.d.ts +5 -0
  521. package/esm/typings/src/scrapers/website/register-constructor.d.ts +15 -0
  522. package/esm/typings/src/scrapers/website/register-metadata.d.ts +28 -0
  523. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +7 -0
  524. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.test.d.ts +1 -0
  525. package/esm/typings/src/scripting/_test/custom-function-async.test.ts.test.d.ts +1 -0
  526. package/esm/typings/src/scripting/_test/custom-function-missing.test.d.ts +1 -0
  527. package/esm/typings/src/scripting/_test/custom-function-with-dependencies.test.d.ts +1 -0
  528. package/esm/typings/src/scripting/_test/custom-function.test.d.ts +1 -0
  529. package/esm/typings/src/scripting/_test/postprocessing.test.d.ts +1 -0
  530. package/esm/typings/src/scripting/_test/script-execution-errors.test.d.ts +1 -0
  531. package/esm/typings/src/scripting/_test/script-execution-tools.test.d.ts +1 -0
  532. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +22 -0
  533. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.test.d.ts +4 -0
  534. package/esm/typings/src/scripting/javascript/JavascriptExecutionTools.d.ts +8 -0
  535. package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +26 -0
  536. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +56 -0
  537. package/esm/typings/src/scripting/javascript/utils/extractVariablesFromJavascript.d.ts +14 -0
  538. package/esm/typings/src/scripting/javascript/utils/extractVariablesFromJavascript.test.d.ts +1 -0
  539. package/esm/typings/src/scripting/javascript/utils/extractVariablesFromScript.test.d.ts +1 -0
  540. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +14 -0
  541. package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +18 -0
  542. package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +18 -0
  543. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +24 -0
  544. package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
  545. package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
  546. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +40 -0
  547. package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +40 -0
  548. package/esm/typings/src/storage/file-cache-storage/FileCacheStorageOptions.d.ts +12 -0
  549. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +8 -0
  550. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
  551. package/esm/typings/src/storage/local-storage/getIndexedDbStorage.d.ts +11 -0
  552. package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +10 -0
  553. package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +10 -0
  554. package/esm/typings/src/storage/local-storage/utils/IndexedDbStorageOptions.d.ts +14 -0
  555. package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.d.ts +8 -0
  556. package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.d.ts +12 -0
  557. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +33 -0
  558. package/esm/typings/src/storage/utils/PrefixStorage.d.ts +25 -0
  559. package/esm/typings/src/types/Arrayable.d.ts +11 -0
  560. package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +8 -0
  561. package/esm/typings/src/types/ModelRequirements.d.ts +104 -0
  562. package/esm/typings/src/types/ModelVariant.d.ts +15 -0
  563. package/esm/typings/src/types/NonEmptyArray.d.ts +8 -0
  564. package/esm/typings/src/types/Prompt.d.ts +111 -0
  565. package/esm/typings/src/types/ScriptLanguage.d.ts +13 -0
  566. package/esm/typings/src/types/SectionType.d.ts +21 -0
  567. package/esm/typings/src/types/TaskType.d.ts +15 -0
  568. package/esm/typings/src/types/typeAliasEmoji.d.ts +12 -0
  569. package/esm/typings/src/types/typeAliases.d.ts +685 -0
  570. package/esm/typings/src/utils/$Register.d.ts +40 -0
  571. package/esm/typings/src/utils/$getCurrentDate.d.ts +10 -0
  572. package/esm/typings/src/utils/FromtoItems.d.ts +19 -0
  573. package/esm/typings/src/utils/arrayableToArray.d.ts +11 -0
  574. package/esm/typings/src/utils/arrayableToArray.test.d.ts +1 -0
  575. package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +17 -0
  576. package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.test.d.ts +1 -0
  577. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +13 -0
  578. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +1 -0
  579. package/esm/typings/src/utils/editable/edit-pipeline-string/removePipelineCommand.d.ts +22 -0
  580. package/esm/typings/src/utils/editable/edit-pipeline-string/removePipelineCommand.test.d.ts +1 -0
  581. package/esm/typings/src/utils/editable/types/PipelineEditableSerialized.d.ts +27 -0
  582. package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +8 -0
  583. package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +1 -0
  584. package/esm/typings/src/utils/editable/utils/renamePipelineParameter.d.ts +29 -0
  585. package/esm/typings/src/utils/editable/utils/renamePipelineParameter.test.d.ts +1 -0
  586. package/esm/typings/src/utils/editable/utils/stringifyPipelineJson.d.ts +16 -0
  587. package/esm/typings/src/utils/emojis.d.ts +24 -0
  588. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +10 -0
  589. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +11 -0
  590. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +11 -0
  591. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +11 -0
  592. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +11 -0
  593. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +16 -0
  594. package/esm/typings/src/utils/execCommand/$execCommandNormalizeOptions.d.ts +12 -0
  595. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +18 -0
  596. package/esm/typings/src/utils/execCommand/ExecCommandOptions.d.ts +45 -0
  597. package/esm/typings/src/utils/execCommand/execCommand.test.d.ts +1 -0
  598. package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.test.d.ts +1 -0
  599. package/esm/typings/src/utils/expectation-counters/constants.d.ts +16 -0
  600. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +10 -0
  601. package/esm/typings/src/utils/expectation-counters/countCharacters.test.d.ts +1 -0
  602. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +12 -0
  603. package/esm/typings/src/utils/expectation-counters/countLines.test.d.ts +1 -0
  604. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +12 -0
  605. package/esm/typings/src/utils/expectation-counters/countPages.test.d.ts +1 -0
  606. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +10 -0
  607. package/esm/typings/src/utils/expectation-counters/countParagraphs.test.d.ts +1 -0
  608. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +16 -0
  609. package/esm/typings/src/utils/expectation-counters/countSentences.test.d.ts +1 -0
  610. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +10 -0
  611. package/esm/typings/src/utils/expectation-counters/countWords.test.d.ts +1 -0
  612. package/esm/typings/src/utils/expectation-counters/index.d.ts +12 -0
  613. package/esm/typings/src/utils/files/extensionToMimeType.d.ts +8 -0
  614. package/esm/typings/src/utils/files/extensionToMimeType.test.d.ts +1 -0
  615. package/esm/typings/src/utils/files/getFileExtension.d.ts +8 -0
  616. package/esm/typings/src/utils/files/getFileExtension.test.d.ts +1 -0
  617. package/esm/typings/src/utils/files/isDirectoryExisting.d.ts +14 -0
  618. package/esm/typings/src/utils/files/isDirectoryExisting.test.d.ts +1 -0
  619. package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
  620. package/esm/typings/src/utils/files/isFileExisting.d.ts +13 -0
  621. package/esm/typings/src/utils/files/isFileExisting.test.d.ts +1 -0
  622. package/esm/typings/src/utils/files/listAllFiles.d.ts +17 -0
  623. package/esm/typings/src/utils/files/listAllFiles.test.d.ts +1 -0
  624. package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +10 -0
  625. package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +1 -0
  626. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +14 -0
  627. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.test.d.ts +1 -0
  628. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +38 -0
  629. package/esm/typings/src/utils/markdown/createMarkdownChart.test.d.ts +1 -0
  630. package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +11 -0
  631. package/esm/typings/src/utils/markdown/createMarkdownTable.test.d.ts +1 -0
  632. package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +11 -0
  633. package/esm/typings/src/utils/markdown/escapeMarkdownBlock.test.d.ts +1 -0
  634. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
  635. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +36 -0
  636. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.test.d.ts +1 -0
  637. package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +15 -0
  638. package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts +1 -0
  639. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +22 -0
  640. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.test.d.ts +1 -0
  641. package/esm/typings/src/utils/markdown/flattenMarkdown.d.ts +17 -0
  642. package/esm/typings/src/utils/markdown/flattenMarkdown.test.d.ts +1 -0
  643. package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +34 -0
  644. package/esm/typings/src/utils/markdown/parseMarkdownSection.test.d.ts +1 -0
  645. package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +9 -0
  646. package/esm/typings/src/utils/markdown/prettifyMarkdown.test.d.ts +1 -0
  647. package/esm/typings/src/utils/markdown/removeMarkdownComments.d.ts +10 -0
  648. package/esm/typings/src/utils/markdown/removeMarkdownComments.test.d.ts +1 -0
  649. package/esm/typings/src/utils/markdown/removeMarkdownFormatting.d.ts +9 -0
  650. package/esm/typings/src/utils/markdown/removeMarkdownFormatting.test.d.ts +1 -0
  651. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +15 -0
  652. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.test.d.ts +1 -0
  653. package/esm/typings/src/utils/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +12 -0
  654. package/esm/typings/src/utils/normalization/IKeywords.d.ts +21 -0
  655. package/esm/typings/src/utils/normalization/capitalize.d.ts +6 -0
  656. package/esm/typings/src/utils/normalization/capitalize.test.d.ts +1 -0
  657. package/esm/typings/src/utils/normalization/decapitalize.d.ts +6 -0
  658. package/esm/typings/src/utils/normalization/decapitalize.test.d.ts +1 -0
  659. package/esm/typings/src/utils/normalization/isValidKeyword.d.ts +10 -0
  660. package/esm/typings/src/utils/normalization/isValidKeyword.test.d.ts +1 -0
  661. package/esm/typings/src/utils/normalization/nameToUriPart.d.ts +9 -0
  662. package/esm/typings/src/utils/normalization/nameToUriPart.test.d.ts +1 -0
  663. package/esm/typings/src/utils/normalization/nameToUriParts.d.ts +9 -0
  664. package/esm/typings/src/utils/normalization/nameToUriParts.test.d.ts +1 -0
  665. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +21 -0
  666. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.test.d.ts +1 -0
  667. package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +17 -0
  668. package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.test.d.ts +1 -0
  669. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +26 -0
  670. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts +1 -0
  671. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +22 -0
  672. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.test.d.ts +1 -0
  673. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +17 -0
  674. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.test.d.ts +1 -0
  675. package/esm/typings/src/utils/normalization/normalizeWhitespaces.d.ts +6 -0
  676. package/esm/typings/src/utils/normalization/normalizeWhitespaces.test.d.ts +1 -0
  677. package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
  678. package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
  679. package/esm/typings/src/utils/normalization/parseKeywords.d.ts +16 -0
  680. package/esm/typings/src/utils/normalization/parseKeywords.test.d.ts +1 -0
  681. package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +9 -0
  682. package/esm/typings/src/utils/normalization/parseKeywordsFromString.test.d.ts +1 -0
  683. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +11 -0
  684. package/esm/typings/src/utils/normalization/removeDiacritics.test.d.ts +1 -0
  685. package/esm/typings/src/utils/normalization/searchKeywords.d.ts +13 -0
  686. package/esm/typings/src/utils/normalization/searchKeywords.test.d.ts +1 -0
  687. package/esm/typings/src/utils/normalization/suffixUrl.d.ts +7 -0
  688. package/esm/typings/src/utils/normalization/suffixUrl.test.d.ts +1 -0
  689. package/esm/typings/src/utils/normalization/titleToName.d.ts +9 -0
  690. package/esm/typings/src/utils/normalization/titleToName.test.d.ts +1 -0
  691. package/esm/typings/src/utils/organization/$sideEffect.d.ts +9 -0
  692. package/esm/typings/src/utils/organization/TODO_USE.d.ts +12 -0
  693. package/esm/typings/src/utils/organization/TODO_any.d.ts +6 -0
  694. package/esm/typings/src/utils/organization/TODO_narrow.d.ts +6 -0
  695. package/esm/typings/src/utils/organization/TODO_object.d.ts +6 -0
  696. package/esm/typings/src/utils/organization/TODO_remove_as.d.ts +6 -0
  697. package/esm/typings/src/utils/organization/TODO_string.d.ts +6 -0
  698. package/esm/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
  699. package/esm/typings/src/utils/organization/___and___.d.ts +7 -0
  700. package/esm/typings/src/utils/organization/___or___.d.ts +6 -0
  701. package/esm/typings/src/utils/organization/empty_object.d.ts +10 -0
  702. package/esm/typings/src/utils/organization/just.d.ts +14 -0
  703. package/esm/typings/src/utils/organization/just_empty_object.d.ts +12 -0
  704. package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
  705. package/esm/typings/src/utils/organization/keepUnused.d.ts +16 -0
  706. package/esm/typings/src/utils/organization/really_any.d.ts +6 -0
  707. package/esm/typings/src/utils/organization/really_unknown.d.ts +6 -0
  708. package/esm/typings/src/utils/organization/spaceTrim.d.ts +11 -0
  709. package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +10 -0
  710. package/esm/typings/src/utils/parameters/extractParameterNames.test.d.ts +1 -0
  711. package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +27 -0
  712. package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.test.d.ts +1 -0
  713. package/esm/typings/src/utils/parameters/numberToString.d.ts +7 -0
  714. package/esm/typings/src/utils/parameters/numberToString.test.d.ts +1 -0
  715. package/esm/typings/src/utils/parameters/templateParameters.d.ts +16 -0
  716. package/esm/typings/src/utils/parameters/templateParameters.test.d.ts +1 -0
  717. package/esm/typings/src/utils/parameters/valueToString.d.ts +17 -0
  718. package/esm/typings/src/utils/parameters/valueToString.test.d.ts +1 -0
  719. package/esm/typings/src/utils/parseNumber.d.ts +16 -0
  720. package/esm/typings/src/utils/parseNumber.test.d.ts +1 -0
  721. package/esm/typings/src/utils/random/$randomSeed.d.ts +10 -0
  722. package/esm/typings/src/utils/random/$randomToken.d.ts +13 -0
  723. package/esm/typings/src/utils/removeEmojis.d.ts +8 -0
  724. package/esm/typings/src/utils/removeEmojis.test.d.ts +1 -0
  725. package/esm/typings/src/utils/removeQuotes.d.ts +14 -0
  726. package/esm/typings/src/utils/removeQuotes.test.d.ts +1 -0
  727. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +14 -0
  728. package/esm/typings/src/utils/serialization/asSerializable.d.ts +15 -0
  729. package/esm/typings/src/utils/serialization/asSerializable.test.d.ts +1 -0
  730. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +45 -0
  731. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +14 -0
  732. package/esm/typings/src/utils/serialization/deepClone.d.ts +14 -0
  733. package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
  734. package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
  735. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +25 -0
  736. package/esm/typings/src/utils/serialization/isSerializableAsJson.test.d.ts +1 -0
  737. package/esm/typings/src/utils/serialization/jsonStringsToJsons.d.ts +9 -0
  738. package/esm/typings/src/utils/serialization/jsonStringsToJsons.test.d.ts +1 -0
  739. package/esm/typings/src/utils/sets/difference.d.ts +10 -0
  740. package/esm/typings/src/utils/sets/difference.test.d.ts +1 -0
  741. package/esm/typings/src/utils/sets/intersection.d.ts +7 -0
  742. package/esm/typings/src/utils/sets/intersection.test.d.ts +1 -0
  743. package/esm/typings/src/utils/sets/union.d.ts +7 -0
  744. package/esm/typings/src/utils/sets/union.test.d.ts +1 -0
  745. package/esm/typings/src/utils/trimCodeBlock.d.ts +9 -0
  746. package/esm/typings/src/utils/trimCodeBlock.test.d.ts +1 -0
  747. package/esm/typings/src/utils/trimEndOfCodeBlock.d.ts +9 -0
  748. package/esm/typings/src/utils/trimEndOfCodeBlock.test.d.ts +1 -0
  749. package/esm/typings/src/utils/unwrapResult.d.ts +37 -0
  750. package/esm/typings/src/utils/unwrapResult.test.d.ts +1 -0
  751. package/esm/typings/src/utils/validators/email/isValidEmail.d.ts +8 -0
  752. package/esm/typings/src/utils/validators/email/isValidEmail.test.d.ts +1 -0
  753. package/esm/typings/src/utils/validators/filePath/isRootPath.d.ts +12 -0
  754. package/esm/typings/src/utils/validators/filePath/isRootPath.test.d.ts +4 -0
  755. package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +12 -0
  756. package/esm/typings/src/utils/validators/filePath/isValidFilePath.test.d.ts +1 -0
  757. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +10 -0
  758. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.test.d.ts +1 -0
  759. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +11 -0
  760. package/esm/typings/src/utils/validators/parameterName/validateParameterName.test.d.ts +1 -0
  761. package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +15 -0
  762. package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.test.d.ts +1 -0
  763. package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +12 -0
  764. package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.test.d.ts +1 -0
  765. package/esm/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.d.ts +11 -0
  766. package/esm/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.test.d.ts +1 -0
  767. package/esm/typings/src/utils/validators/url/isUrlOnPrivateNetwork.d.ts +13 -0
  768. package/esm/typings/src/utils/validators/url/isUrlOnPrivateNetwork.test.d.ts +1 -0
  769. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +15 -0
  770. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.test.d.ts +1 -0
  771. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +13 -0
  772. package/esm/typings/src/utils/validators/url/isValidUrl.test.d.ts +1 -0
  773. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +8 -0
  774. package/esm/typings/src/utils/validators/uuid/isValidUuid.test.d.ts +1 -0
  775. package/esm/typings/src/version.d.ts +26 -0
  776. package/esm/typings/src/wizard/$getCompiledBook.d.ts +16 -0
  777. package/esm/typings/src/wizard/wizard.d.ts +78 -0
  778. package/package.json +100 -0
  779. package/umd/index.umd.js +1965 -0
  780. package/umd/index.umd.js.map +1 -0
@@ -0,0 +1,1965 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('spacetrim')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', 'spacetrim'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.react, global.spaceTrim));
5
+ })(this, (function (exports, jsxRuntime, react, spaceTrim) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
10
+
11
+ // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
12
+ /**
13
+ * The version of the Book language
14
+ *
15
+ * @generated
16
+ * @see https://github.com/webgptorg/book
17
+ */
18
+ const BOOK_LANGUAGE_VERSION = '1.0.0';
19
+ /**
20
+ * The version of the Promptbook engine
21
+ *
22
+ * @generated
23
+ * @see https://github.com/webgptorg/promptbook
24
+ */
25
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-24';
26
+ /**
27
+ * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
+ * Note: [💞] Ignore a discrepancy between file name and entity name
29
+ */
30
+
31
+ /**
32
+ * Type guard to check if a string is a valid agent source
33
+ *
34
+ * @public exported from `@promptbook/core`
35
+ */
36
+ function isValidBook(value) {
37
+ // Basic validation - agent source should have at least a name (first line)
38
+ return typeof value === 'string' /* && value.trim().length > 0 */;
39
+ }
40
+ /**
41
+ * Validates and converts a string to agent source branded type
42
+ * This function should be used when you have a string that you know represents agent source
43
+ * but need to convert it to the branded type for type safety
44
+ *
45
+ * @public exported from `@promptbook/core`
46
+ */
47
+ function validateBook(source) {
48
+ if (!isValidBook(source)) {
49
+ throw new Error('Invalid agent source: must be a string');
50
+ }
51
+ return source;
52
+ }
53
+ /**
54
+ * Default book
55
+ *
56
+ * @public exported from `@promptbook/core`
57
+ */
58
+ const DEFAULT_BOOK = validateBook(spaceTrim__default["default"](`
59
+ AI Avatar
60
+
61
+ PERSONA A friendly AI assistant that helps you with your tasks
62
+ `));
63
+
64
+ /**
65
+ * Freezes the given object and all its nested objects recursively
66
+ *
67
+ * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
68
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
69
+ *
70
+ * @returns The same object as the input, but deeply frozen
71
+ * @public exported from `@promptbook/utils`
72
+ */
73
+ function $deepFreeze(objectValue) {
74
+ if (Array.isArray(objectValue)) {
75
+ return Object.freeze(objectValue.map((item) => $deepFreeze(item)));
76
+ }
77
+ const propertyNames = Object.getOwnPropertyNames(objectValue);
78
+ for (const propertyName of propertyNames) {
79
+ const value = objectValue[propertyName];
80
+ if (value && typeof value === 'object') {
81
+ $deepFreeze(value);
82
+ }
83
+ }
84
+ Object.freeze(objectValue);
85
+ return objectValue;
86
+ }
87
+ /**
88
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
89
+ */
90
+
91
+ /**
92
+ * Generates a regex pattern to match a specific commitment
93
+ *
94
+ * Note: It always creates new Regex object
95
+ * Note: Uses word boundaries to ensure only full words are matched (e.g., "PERSONA" matches but "PERSONALITY" does not)
96
+ *
97
+ * @private
98
+ */
99
+ function createCommitmentRegex(commitment) {
100
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
101
+ const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
102
+ const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
103
+ return regex;
104
+ }
105
+ /**
106
+ * Generates a regex pattern to match a specific commitment type
107
+ *
108
+ * Note: It just matches the type part of the commitment
109
+ * Note: It always creates new Regex object
110
+ * Note: Uses word boundaries to ensure only full words are matched (e.g., "PERSONA" matches but "PERSONALITY" does not)
111
+ *
112
+ * @private
113
+ */
114
+ function createCommitmentTypeRegex(commitment) {
115
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
116
+ const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
117
+ const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
118
+ return regex;
119
+ }
120
+
121
+ /**
122
+ * Base implementation of CommitmentDefinition that provides common functionality
123
+ * Most commitments can extend this class and only override the applyToAgentModelRequirements method
124
+ *
125
+ * @private
126
+ */
127
+ class BaseCommitmentDefinition {
128
+ constructor(type) {
129
+ this.type = type;
130
+ }
131
+ /**
132
+ * Creates a regex pattern to match this commitment in agent source
133
+ * Uses the existing createCommitmentRegex function as internal helper
134
+ */
135
+ createRegex() {
136
+ return createCommitmentRegex(this.type);
137
+ }
138
+ /**
139
+ * Creates a regex pattern to match just the commitment type
140
+ * Uses the existing createCommitmentTypeRegex function as internal helper
141
+ */
142
+ createTypeRegex() {
143
+ return createCommitmentTypeRegex(this.type);
144
+ }
145
+ /**
146
+ * Helper method to create a new requirements object with updated system message
147
+ * This is commonly used by many commitments
148
+ */
149
+ updateSystemMessage(requirements, messageUpdate) {
150
+ const newMessage = typeof messageUpdate === 'string' ? messageUpdate : messageUpdate(requirements.systemMessage);
151
+ return {
152
+ ...requirements,
153
+ systemMessage: newMessage,
154
+ };
155
+ }
156
+ /**
157
+ * Helper method to append content to the system message
158
+ */
159
+ appendToSystemMessage(requirements, content, separator = '\n\n') {
160
+ return this.updateSystemMessage(requirements, (currentMessage) => {
161
+ if (!currentMessage.trim()) {
162
+ return content;
163
+ }
164
+ return currentMessage + separator + content;
165
+ });
166
+ }
167
+ /**
168
+ * Helper method to add a comment section to the system message
169
+ * Comments are lines starting with # that will be removed from the final system message
170
+ * but can be useful for organizing and structuring the message during processing
171
+ */
172
+ addCommentSection(requirements, commentTitle, content, position = 'end') {
173
+ const commentSection = `# ${commentTitle.toUpperCase()}\n${content}`;
174
+ if (position === 'beginning') {
175
+ return this.updateSystemMessage(requirements, (currentMessage) => {
176
+ if (!currentMessage.trim()) {
177
+ return commentSection;
178
+ }
179
+ return commentSection + '\n\n' + currentMessage;
180
+ });
181
+ }
182
+ else {
183
+ return this.appendToSystemMessage(requirements, commentSection);
184
+ }
185
+ }
186
+ }
187
+
188
+ /**
189
+ * ACTION commitment definition
190
+ *
191
+ * The ACTION commitment defines specific actions or capabilities that the agent can perform.
192
+ * This helps define what the agent is capable of doing and how it should approach tasks.
193
+ *
194
+ * Example usage in agent source:
195
+ *
196
+ * ```book
197
+ * ACTION Can generate code snippets and explain programming concepts
198
+ * ACTION Able to analyze data and provide insights
199
+ * ```
200
+ *
201
+ * @private [🪔] Maybe export the commitments through some package
202
+ */
203
+ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
204
+ constructor() {
205
+ super('ACTION');
206
+ }
207
+ /**
208
+ * Short one-line description of ACTION.
209
+ */
210
+ get description() {
211
+ return 'Define agent capabilities and actions it can perform.';
212
+ }
213
+ /**
214
+ * Markdown documentation for ACTION commitment.
215
+ */
216
+ get documentation() {
217
+ return spaceTrim.spaceTrim(`
218
+ # ACTION
219
+
220
+ Defines specific actions or capabilities that the agent can perform.
221
+
222
+ ## Key behaviors
223
+
224
+ - Multiple \`ACTION\` commitments are applied sequentially.
225
+ - Each action adds to the agent's capability list.
226
+ - Actions help users understand what the agent can do.
227
+
228
+ ## Examples
229
+
230
+ \`\`\`book
231
+ Code Assistant
232
+
233
+ PERSONA You are a programming assistant
234
+ ACTION Can generate code snippets and explain programming concepts
235
+ ACTION Able to debug existing code and suggest improvements
236
+ ACTION Can create unit tests for functions
237
+ \`\`\`
238
+
239
+ \`\`\`book
240
+ Data Scientist
241
+
242
+ PERSONA You are a data analysis expert
243
+ ACTION Able to analyze data and provide insights
244
+ ACTION Can create visualizations and charts
245
+ ACTION Capable of statistical analysis and modeling
246
+ KNOWLEDGE Data analysis best practices and statistical methods
247
+ \`\`\`
248
+ `);
249
+ }
250
+ applyToAgentModelRequirements(requirements, content) {
251
+ const trimmedContent = content.trim();
252
+ if (!trimmedContent) {
253
+ return requirements;
254
+ }
255
+ // Add action capability to the system message
256
+ const actionSection = `Capability: ${trimmedContent}`;
257
+ return this.appendToSystemMessage(requirements, actionSection, '\n\n');
258
+ }
259
+ }
260
+ /**
261
+ * Singleton instance of the ACTION commitment definition
262
+ *
263
+ * @private [🪔] Maybe export the commitments through some package
264
+ */
265
+ new ActionCommitmentDefinition();
266
+ /**
267
+ * Note: [💞] Ignore a discrepancy between file name and entity name
268
+ */
269
+
270
+ /**
271
+ * FORMAT commitment definition
272
+ *
273
+ * The FORMAT commitment defines the specific output structure and formatting
274
+ * that the agent should use in its responses. This includes data formats,
275
+ * response templates, and structural requirements.
276
+ *
277
+ * Example usage in agent source:
278
+ *
279
+ * ```book
280
+ * FORMAT Always respond in JSON format with 'status' and 'data' fields
281
+ * FORMAT Use markdown formatting for all code blocks
282
+ * ```
283
+ *
284
+ * @private [🪔] Maybe export the commitments through some package
285
+ */
286
+ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
287
+ constructor() {
288
+ super('FORMAT');
289
+ }
290
+ /**
291
+ * Short one-line description of FORMAT.
292
+ */
293
+ get description() {
294
+ return 'Specify output structure or formatting requirements.';
295
+ }
296
+ /**
297
+ * Markdown documentation for FORMAT commitment.
298
+ */
299
+ get documentation() {
300
+ return spaceTrim.spaceTrim(`
301
+ # FORMAT
302
+
303
+ Defines the specific output structure and formatting for responses (data formats, templates, structure).
304
+
305
+ ## Key behaviors
306
+
307
+ - Multiple \`FORMAT\` commitments are applied sequentially.
308
+ - If they are in conflict, the last one takes precedence.
309
+ - You can specify both data formats and presentation styles.
310
+
311
+ ## Examples
312
+
313
+ \`\`\`book
314
+ Customer Support Bot
315
+
316
+ PERSONA You are a helpful customer support agent
317
+ FORMAT Always respond in JSON format with 'status' and 'data' fields
318
+ FORMAT Use markdown formatting for all code blocks
319
+ \`\`\`
320
+
321
+ \`\`\`book
322
+ Data Analyst
323
+
324
+ PERSONA You are a data analysis expert
325
+ FORMAT Present results in structured tables
326
+ FORMAT Include confidence scores for all predictions
327
+ STYLE Be concise and precise in explanations
328
+ \`\`\`
329
+ `);
330
+ }
331
+ applyToAgentModelRequirements(requirements, content) {
332
+ const trimmedContent = content.trim();
333
+ if (!trimmedContent) {
334
+ return requirements;
335
+ }
336
+ // Add format instructions to the system message
337
+ const formatSection = `Output Format: ${trimmedContent}`;
338
+ return this.appendToSystemMessage(requirements, formatSection, '\n\n');
339
+ }
340
+ }
341
+ /**
342
+ * Singleton instance of the FORMAT commitment definition
343
+ *
344
+ * @private [🪔] Maybe export the commitments through some package
345
+ */
346
+ new FormatCommitmentDefinition();
347
+ /**
348
+ * Note: [💞] Ignore a discrepancy between file name and entity name
349
+ */
350
+
351
+ /**
352
+ * Error thrown when a fetch request fails
353
+ *
354
+ * @public exported from `@promptbook/core`
355
+ */
356
+ class PromptbookFetchError extends Error {
357
+ constructor(message) {
358
+ super(message);
359
+ this.name = 'PromptbookFetchError';
360
+ Object.setPrototypeOf(this, PromptbookFetchError.prototype);
361
+ }
362
+ }
363
+
364
+ /**
365
+ * Name for the Promptbook
366
+ *
367
+ * TODO: [🗽] Unite branding and make single place for it
368
+ *
369
+ * @public exported from `@promptbook/core`
370
+ */
371
+ const NAME = `Promptbook`;
372
+ /**
373
+ * Email of the responsible person
374
+ *
375
+ * @public exported from `@promptbook/core`
376
+ */
377
+ const ADMIN_EMAIL = 'pavol@ptbk.io';
378
+ /**
379
+ * Name of the responsible person for the Promptbook on GitHub
380
+ *
381
+ * @public exported from `@promptbook/core`
382
+ */
383
+ const ADMIN_GITHUB_NAME = 'hejny';
384
+ // <- TODO: [🧜‍♂️]
385
+ /**
386
+ * Default settings for parsing and generating CSV files in Promptbook.
387
+ *
388
+ * @public exported from `@promptbook/core`
389
+ */
390
+ Object.freeze({
391
+ delimiter: ',',
392
+ quoteChar: '"',
393
+ newline: '\n',
394
+ skipEmptyLines: true,
395
+ });
396
+ /**
397
+ * Note: [💞] Ignore a discrepancy between file name and entity name
398
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteServerUrl and path into single value
399
+ */
400
+
401
+ /**
402
+ * Make error report URL for the given error
403
+ *
404
+ * @private private within the repository
405
+ */
406
+ function getErrorReportUrl(error) {
407
+ const report = {
408
+ title: `🐜 Error report from ${NAME}`,
409
+ body: spaceTrim__default["default"]((block) => `
410
+
411
+
412
+ \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
413
+
414
+ \`\`\`
415
+ ${block(error.message || '(no error message)')}
416
+ \`\`\`
417
+
418
+
419
+ ## More info:
420
+
421
+ - **Promptbook engine version:** ${PROMPTBOOK_ENGINE_VERSION}
422
+ - **Book language version:** ${BOOK_LANGUAGE_VERSION}
423
+ - **Time:** ${new Date().toISOString()}
424
+
425
+ <details>
426
+ <summary>Stack trace:</summary>
427
+
428
+ ## Stack trace:
429
+
430
+ \`\`\`stacktrace
431
+ ${block(error.stack || '(empty)')}
432
+ \`\`\`
433
+ </details>
434
+
435
+ `),
436
+ };
437
+ const reportUrl = new URL(`https://github.com/webgptorg/promptbook/issues/new`);
438
+ reportUrl.searchParams.set('labels', 'bug');
439
+ reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
440
+ reportUrl.searchParams.set('title', report.title);
441
+ reportUrl.searchParams.set('body', report.body);
442
+ return reportUrl;
443
+ }
444
+
445
+ /**
446
+ * This error type indicates that the error should not happen and its last check before crashing with some other error
447
+ *
448
+ * @public exported from `@promptbook/core`
449
+ */
450
+ class UnexpectedError extends Error {
451
+ constructor(message) {
452
+ super(spaceTrim.spaceTrim((block) => `
453
+ ${block(message)}
454
+
455
+ Note: This error should not happen.
456
+ It's probably a bug in the pipeline collection
457
+
458
+ Please report issue:
459
+ ${block(getErrorReportUrl(new Error(message)).href)}
460
+
461
+ Or contact us on ${ADMIN_EMAIL}
462
+
463
+ `));
464
+ this.name = 'UnexpectedError';
465
+ Object.setPrototypeOf(this, UnexpectedError.prototype);
466
+ }
467
+ }
468
+
469
+ /**
470
+ * This error type indicates that somewhere in the code non-Error object was thrown and it was wrapped into the `WrappedError`
471
+ *
472
+ * @public exported from `@promptbook/core`
473
+ */
474
+ class WrappedError extends Error {
475
+ constructor(whatWasThrown) {
476
+ const tag = `[🤮]`;
477
+ console.error(tag, whatWasThrown);
478
+ super(spaceTrim.spaceTrim(`
479
+ Non-Error object was thrown
480
+
481
+ Note: Look for ${tag} in the console for more details
482
+ Please report issue on ${ADMIN_EMAIL}
483
+ `));
484
+ this.name = 'WrappedError';
485
+ Object.setPrototypeOf(this, WrappedError.prototype);
486
+ }
487
+ }
488
+
489
+ /**
490
+ * Helper used in catch blocks to assert that the error is an instance of `Error`
491
+ *
492
+ * @param whatWasThrown Any object that was thrown
493
+ * @returns Nothing if the error is an instance of `Error`
494
+ * @throws `WrappedError` or `UnexpectedError` if the error is not standard
495
+ *
496
+ * @private within the repository
497
+ */
498
+ function assertsError(whatWasThrown) {
499
+ // Case 1: Handle error which was rethrown as `WrappedError`
500
+ if (whatWasThrown instanceof WrappedError) {
501
+ const wrappedError = whatWasThrown;
502
+ throw wrappedError;
503
+ }
504
+ // Case 2: Handle unexpected errors
505
+ if (whatWasThrown instanceof UnexpectedError) {
506
+ const unexpectedError = whatWasThrown;
507
+ throw unexpectedError;
508
+ }
509
+ // Case 3: Handle standard errors - keep them up to consumer
510
+ if (whatWasThrown instanceof Error) {
511
+ return;
512
+ }
513
+ // Case 4: Handle non-standard errors - wrap them into `WrappedError` and throw
514
+ throw new WrappedError(whatWasThrown);
515
+ }
516
+
517
+ /**
518
+ * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
519
+ *
520
+ * @public exported from `@promptbook/core`
521
+ */
522
+ const promptbookFetch = async (urlOrRequest, init) => {
523
+ try {
524
+ return await fetch(urlOrRequest, init);
525
+ }
526
+ catch (error) {
527
+ assertsError(error);
528
+ let url;
529
+ if (typeof urlOrRequest === 'string') {
530
+ url = urlOrRequest;
531
+ }
532
+ else if (urlOrRequest instanceof Request) {
533
+ url = urlOrRequest.url;
534
+ }
535
+ throw new PromptbookFetchError(spaceTrim__default["default"]((block) => `
536
+ Can not fetch "${url}"
537
+
538
+ Fetch error:
539
+ ${block(error.message)}
540
+
541
+ `));
542
+ }
543
+ };
544
+ /**
545
+ * TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
546
+ */
547
+
548
+ /**
549
+ * Frontend RAG Service that uses backend APIs for processing
550
+ * This avoids Node.js dependencies in the frontend
551
+ *
552
+ * @private - TODO: [🧠] Maybe should be public?
553
+ */
554
+ class FrontendRAGService {
555
+ constructor(config) {
556
+ this.chunks = [];
557
+ this.sources = [];
558
+ this.isInitialized = false;
559
+ this.config = {
560
+ maxChunkSize: 1000,
561
+ chunkOverlap: 200,
562
+ maxRetrievedChunks: 5,
563
+ minRelevanceScore: 0.1,
564
+ ...config,
565
+ };
566
+ }
567
+ /**
568
+ * Initialize knowledge sources by processing them on the backend
569
+ */
570
+ async initializeKnowledgeSources(sources) {
571
+ if (sources.length === 0) {
572
+ this.isInitialized = true;
573
+ return;
574
+ }
575
+ try {
576
+ const response = await promptbookFetch('/api/knowledge/process-sources', {
577
+ method: 'POST',
578
+ headers: {
579
+ 'Content-Type': 'application/json',
580
+ },
581
+ body: JSON.stringify({
582
+ sources,
583
+ config: {
584
+ maxChunkSize: this.config.maxChunkSize,
585
+ chunkOverlap: this.config.chunkOverlap,
586
+ },
587
+ }),
588
+ });
589
+ if (!response.ok) {
590
+ throw new Error(`Failed to process knowledge sources: ${response.status}`);
591
+ }
592
+ const result = (await response.json());
593
+ if (!result.success) {
594
+ throw new Error(result.message || 'Failed to process knowledge sources');
595
+ }
596
+ this.chunks = result.chunks;
597
+ this.sources = sources;
598
+ this.isInitialized = true;
599
+ console.log(`Initialized RAG service with ${this.chunks.length} chunks from ${sources.length} sources`);
600
+ }
601
+ catch (error) {
602
+ console.error('Failed to initialize knowledge sources:', error);
603
+ // Don't throw - allow the system to continue without RAG
604
+ this.isInitialized = true;
605
+ }
606
+ }
607
+ /**
608
+ * Get relevant context for a user query
609
+ */
610
+ async getContextForQuery(query) {
611
+ if (!this.isInitialized) {
612
+ console.warn('RAG service not initialized');
613
+ return '';
614
+ }
615
+ if (this.chunks.length === 0) {
616
+ return '';
617
+ }
618
+ try {
619
+ const response = await promptbookFetch('/api/knowledge/retrieve-context', {
620
+ method: 'POST',
621
+ headers: {
622
+ 'Content-Type': 'application/json',
623
+ },
624
+ body: JSON.stringify({
625
+ query,
626
+ chunks: this.chunks,
627
+ config: {
628
+ maxRetrievedChunks: this.config.maxRetrievedChunks,
629
+ minRelevanceScore: this.config.minRelevanceScore,
630
+ },
631
+ }),
632
+ });
633
+ if (!response.ok) {
634
+ console.error(`Failed to retrieve context: ${response.status}`);
635
+ return '';
636
+ }
637
+ const result = (await response.json());
638
+ if (!result.success) {
639
+ console.error('Context retrieval failed:', result.message);
640
+ return '';
641
+ }
642
+ return result.context;
643
+ }
644
+ catch (error) {
645
+ console.error('Error retrieving context:', error);
646
+ return '';
647
+ }
648
+ }
649
+ /**
650
+ * Get relevant chunks for a query (for debugging/inspection)
651
+ */
652
+ async getRelevantChunks(query) {
653
+ if (!this.isInitialized || this.chunks.length === 0) {
654
+ return [];
655
+ }
656
+ try {
657
+ const response = await promptbookFetch('/api/knowledge/retrieve-context', {
658
+ method: 'POST',
659
+ headers: {
660
+ 'Content-Type': 'application/json',
661
+ },
662
+ body: JSON.stringify({
663
+ query,
664
+ chunks: this.chunks,
665
+ config: {
666
+ maxRetrievedChunks: this.config.maxRetrievedChunks,
667
+ minRelevanceScore: this.config.minRelevanceScore,
668
+ },
669
+ }),
670
+ });
671
+ if (!response.ok) {
672
+ return [];
673
+ }
674
+ const result = (await response.json());
675
+ return result.success ? result.relevantChunks : [];
676
+ }
677
+ catch (error) {
678
+ console.error('Error retrieving relevant chunks:', error);
679
+ return [];
680
+ }
681
+ }
682
+ /**
683
+ * Get knowledge base statistics
684
+ */
685
+ getStats() {
686
+ return {
687
+ sources: this.sources.length,
688
+ chunks: this.chunks.length,
689
+ isInitialized: this.isInitialized,
690
+ };
691
+ }
692
+ /**
693
+ * Check if the service is ready to use
694
+ */
695
+ isReady() {
696
+ return this.isInitialized;
697
+ }
698
+ /**
699
+ * Clear all knowledge sources
700
+ */
701
+ clearKnowledgeBase() {
702
+ this.chunks = [];
703
+ this.sources = [];
704
+ this.isInitialized = false;
705
+ }
706
+ /**
707
+ * Add a single knowledge source (for incremental updates)
708
+ */
709
+ async addKnowledgeSource(url) {
710
+ if (this.sources.includes(url)) {
711
+ console.log(`Knowledge source already exists: ${url}`);
712
+ return;
713
+ }
714
+ try {
715
+ const response = await promptbookFetch('/api/knowledge/process-sources', {
716
+ method: 'POST',
717
+ headers: {
718
+ 'Content-Type': 'application/json',
719
+ },
720
+ body: JSON.stringify({
721
+ sources: [url],
722
+ config: {
723
+ maxChunkSize: this.config.maxChunkSize,
724
+ chunkOverlap: this.config.chunkOverlap,
725
+ },
726
+ }),
727
+ });
728
+ if (!response.ok) {
729
+ throw new Error(`Failed to process knowledge source: ${response.status}`);
730
+ }
731
+ const result = (await response.json());
732
+ if (!result.success) {
733
+ throw new Error(result.message || 'Failed to process knowledge source');
734
+ }
735
+ // Add new chunks to existing ones
736
+ this.chunks.push(...result.chunks);
737
+ this.sources.push(url);
738
+ console.log(`Added knowledge source: ${url} (${result.chunks.length} chunks)`);
739
+ }
740
+ catch (error) {
741
+ console.error(`Failed to add knowledge source ${url}:`, error);
742
+ throw error;
743
+ }
744
+ }
745
+ }
746
+
747
+ /**
748
+ * KNOWLEDGE commitment definition
749
+ *
750
+ * The KNOWLEDGE commitment adds specific knowledge, facts, or context to the agent
751
+ * using RAG (Retrieval-Augmented Generation) approach for external sources.
752
+ *
753
+ * Supports both direct text knowledge and external sources like PDFs.
754
+ *
755
+ * Example usage in agent source:
756
+ *
757
+ * ```book
758
+ * KNOWLEDGE The company was founded in 2020 and specializes in AI-powered solutions
759
+ * KNOWLEDGE https://example.com/company-handbook.pdf
760
+ * KNOWLEDGE https://example.com/product-documentation.pdf
761
+ * ```
762
+ *
763
+ * @private [🪔] Maybe export the commitments through some package
764
+ */
765
+ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
766
+ constructor() {
767
+ super('KNOWLEDGE');
768
+ this.ragService = new FrontendRAGService();
769
+ }
770
+ /**
771
+ * Short one-line description of KNOWLEDGE.
772
+ */
773
+ get description() {
774
+ return 'Add domain **knowledge** via direct text or external sources (RAG).';
775
+ }
776
+ /**
777
+ * Markdown documentation for KNOWLEDGE commitment.
778
+ */
779
+ get documentation() {
780
+ return spaceTrim.spaceTrim(`
781
+ # KNOWLEDGE
782
+
783
+ Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
784
+
785
+ ## Key behaviors
786
+
787
+ - Multiple \`KNOWLEDGE\` commitments are applied sequentially.
788
+ - Supports both direct text knowledge and external URLs.
789
+ - External sources (PDFs, websites) are processed via RAG for context retrieval.
790
+
791
+ ## Supported formats
792
+
793
+ - Direct text: Immediate knowledge incorporated into agent
794
+ - URLs: External documents processed for contextual retrieval
795
+ - Supported file types: PDF, text, markdown, HTML
796
+
797
+ ## Examples
798
+
799
+ \`\`\`book
800
+ Customer Support Bot
801
+
802
+ PERSONA You are a helpful customer support agent for TechCorp
803
+ KNOWLEDGE TechCorp was founded in 2020 and specializes in AI-powered solutions
804
+ KNOWLEDGE https://example.com/company-handbook.pdf
805
+ KNOWLEDGE https://example.com/product-documentation.pdf
806
+ RULE Always be polite and professional
807
+ \`\`\`
808
+
809
+ \`\`\`book
810
+ Research Assistant
811
+
812
+ PERSONA You are a knowledgeable research assistant
813
+ KNOWLEDGE Academic research requires careful citation and verification
814
+ KNOWLEDGE https://example.com/research-guidelines.pdf
815
+ ACTION Can help with literature reviews and data analysis
816
+ STYLE Present information in clear, academic format
817
+ \`\`\`
818
+ `);
819
+ }
820
+ applyToAgentModelRequirements(requirements, content) {
821
+ var _a;
822
+ const trimmedContent = content.trim();
823
+ if (!trimmedContent) {
824
+ return requirements;
825
+ }
826
+ // Check if content is a URL (external knowledge source)
827
+ if (this.isUrl(trimmedContent)) {
828
+ // Store the URL for later async processing
829
+ const updatedRequirements = {
830
+ ...requirements,
831
+ metadata: {
832
+ ...requirements.metadata,
833
+ ragService: this.ragService,
834
+ knowledgeSources: [
835
+ ...(((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.knowledgeSources) || []),
836
+ trimmedContent,
837
+ ],
838
+ },
839
+ };
840
+ // Add placeholder information about knowledge sources to system message
841
+ const knowledgeInfo = `Knowledge Source URL: ${trimmedContent} (will be processed for retrieval during chat)`;
842
+ return this.appendToSystemMessage(updatedRequirements, knowledgeInfo, '\n\n');
843
+ }
844
+ else {
845
+ // Direct text knowledge - add to system message
846
+ const knowledgeSection = `Knowledge: ${trimmedContent}`;
847
+ return this.appendToSystemMessage(requirements, knowledgeSection, '\n\n');
848
+ }
849
+ }
850
+ /**
851
+ * Check if content is a URL
852
+ */
853
+ isUrl(content) {
854
+ try {
855
+ new URL(content);
856
+ return true;
857
+ }
858
+ catch (_a) {
859
+ return false;
860
+ }
861
+ }
862
+ /**
863
+ * Get RAG service instance for retrieving context during chat
864
+ */
865
+ getRagService() {
866
+ return this.ragService;
867
+ }
868
+ }
869
+ /**
870
+ * Singleton instance of the KNOWLEDGE commitment definition
871
+ *
872
+ * @private [🪔] Maybe export the commitments through some package
873
+ */
874
+ new KnowledgeCommitmentDefinition();
875
+ /**
876
+ * Note: [💞] Ignore a discrepancy between file name and entity name
877
+ */
878
+
879
+ /**
880
+ * META IMAGE commitment definition
881
+ *
882
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
883
+ * This commitment is special because it doesn't affect the system message,
884
+ * but is handled separately in the parsing logic.
885
+ *
886
+ * Example usage in agent source:
887
+ *
888
+ * ```book
889
+ * META IMAGE https://example.com/avatar.jpg
890
+ * META IMAGE /assets/agent-avatar.png
891
+ * ```
892
+ *
893
+ * @private [🪔] Maybe export the commitments through some package
894
+ */
895
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
896
+ constructor() {
897
+ super('META IMAGE');
898
+ }
899
+ /**
900
+ * Short one-line description of META IMAGE.
901
+ */
902
+ get description() {
903
+ return "Set the agent's profile image URL.";
904
+ }
905
+ /**
906
+ * Markdown documentation for META IMAGE commitment.
907
+ */
908
+ get documentation() {
909
+ return spaceTrim.spaceTrim(`
910
+ # META IMAGE
911
+
912
+ Sets the agent's avatar/profile image URL.
913
+
914
+ ## Key behaviors
915
+
916
+ - Does not modify the agent's behavior or responses.
917
+ - Only one \`META IMAGE\` should be used per agent.
918
+ - If multiple are specified, the last one takes precedence.
919
+ - Used for visual representation in user interfaces.
920
+
921
+ ## Examples
922
+
923
+ \`\`\`book
924
+ Professional Assistant
925
+
926
+ META IMAGE https://example.com/professional-avatar.jpg
927
+ PERSONA You are a professional business assistant
928
+ STYLE Maintain a formal and courteous tone
929
+ \`\`\`
930
+
931
+ \`\`\`book
932
+ Creative Helper
933
+
934
+ META IMAGE /assets/creative-bot-avatar.png
935
+ PERSONA You are a creative and inspiring assistant
936
+ STYLE Be enthusiastic and encouraging
937
+ ACTION Can help with brainstorming and ideation
938
+ \`\`\`
939
+ `);
940
+ }
941
+ applyToAgentModelRequirements(requirements, content) {
942
+ // META IMAGE doesn't modify the system message or model requirements
943
+ // It's handled separately in the parsing logic for profile image extraction
944
+ // This method exists for consistency with the CommitmentDefinition interface
945
+ return requirements;
946
+ }
947
+ /**
948
+ * Extracts the profile image URL from the content
949
+ * This is used by the parsing logic
950
+ */
951
+ extractProfileImageUrl(content) {
952
+ const trimmedContent = content.trim();
953
+ return trimmedContent || null;
954
+ }
955
+ }
956
+ /**
957
+ * Singleton instance of the META IMAGE commitment definition
958
+ *
959
+ * @private [🪔] Maybe export the commitments through some package
960
+ */
961
+ new MetaImageCommitmentDefinition();
962
+ /**
963
+ * Note: [💞] Ignore a discrepancy between file name and entity name
964
+ */
965
+
966
+ /**
967
+ * META LINK commitment definition
968
+ *
969
+ * The `META LINK` commitment represents the link to the person from whom the agent is created.
970
+ * This commitment is special because it doesn't affect the system message,
971
+ * but is handled separately in the parsing logic for profile display.
972
+ *
973
+ * Example usage in agent source:
974
+ *
975
+ * ```
976
+ * META LINK https://twitter.com/username
977
+ * META LINK https://linkedin.com/in/profile
978
+ * META LINK https://github.com/username
979
+ * ```
980
+ *
981
+ * Multiple `META LINK` commitments can be used when there are multiple sources:
982
+ *
983
+ * ```book
984
+ * META LINK https://twitter.com/username
985
+ * META LINK https://linkedin.com/in/profile
986
+ * ```
987
+ *
988
+ * @private [🪔] Maybe export the commitments through some package
989
+ */
990
+ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
991
+ constructor() {
992
+ super('META LINK');
993
+ }
994
+ /**
995
+ * Short one-line description of META LINK.
996
+ */
997
+ get description() {
998
+ return 'Provide profile/source links for the person the agent models.';
999
+ }
1000
+ /**
1001
+ * Markdown documentation for META LINK commitment.
1002
+ */
1003
+ get documentation() {
1004
+ return spaceTrim.spaceTrim(`
1005
+ # META LINK
1006
+
1007
+ Represents a profile or source link for the person the agent is modeled after.
1008
+
1009
+ ## Key behaviors
1010
+
1011
+ - Does not modify the agent's behavior or responses.
1012
+ - Multiple \`META LINK\` commitments can be used for different social profiles.
1013
+ - Used for attribution and crediting the original person.
1014
+ - Displayed in user interfaces for transparency.
1015
+
1016
+ ## Examples
1017
+
1018
+ \`\`\`book
1019
+ Expert Consultant
1020
+
1021
+ META LINK https://twitter.com/expertname
1022
+ META LINK https://linkedin.com/in/expertprofile
1023
+ PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
1024
+ KNOWLEDGE Extensive background in machine learning and neural networks
1025
+ \`\`\`
1026
+
1027
+ \`\`\`book
1028
+ Open Source Developer
1029
+
1030
+ META LINK https://github.com/developer
1031
+ META LINK https://twitter.com/devhandle
1032
+ PERSONA You are an experienced open source developer
1033
+ ACTION Can help with code reviews and architecture decisions
1034
+ STYLE Be direct and technical in explanations
1035
+ \`\`\`
1036
+ `);
1037
+ }
1038
+ applyToAgentModelRequirements(requirements, content) {
1039
+ // META LINK doesn't modify the system message or model requirements
1040
+ // It's handled separately in the parsing logic for profile link extraction
1041
+ // This method exists for consistency with the CommitmentDefinition interface
1042
+ return requirements;
1043
+ }
1044
+ /**
1045
+ * Extracts the profile link URL from the content
1046
+ * This is used by the parsing logic
1047
+ */
1048
+ extractProfileLinkUrl(content) {
1049
+ const trimmedContent = content.trim();
1050
+ return trimmedContent || null;
1051
+ }
1052
+ /**
1053
+ * Validates if the provided content is a valid URL
1054
+ */
1055
+ isValidUrl(content) {
1056
+ try {
1057
+ new URL(content.trim());
1058
+ return true;
1059
+ }
1060
+ catch (_a) {
1061
+ return false;
1062
+ }
1063
+ }
1064
+ }
1065
+ /**
1066
+ * Singleton instance of the META LINK commitment definition
1067
+ *
1068
+ * @private [🪔] Maybe export the commitments through some package
1069
+ */
1070
+ new MetaLinkCommitmentDefinition();
1071
+ /**
1072
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1073
+ */
1074
+
1075
+ /**
1076
+ * MODEL commitment definition
1077
+ *
1078
+ * The MODEL commitment specifies which AI model to use and can also set
1079
+ * model-specific parameters like temperature, topP, and topK.
1080
+ *
1081
+ * Example usage in agent source:
1082
+ *
1083
+ * ```book
1084
+ * MODEL gpt-4
1085
+ * MODEL claude-3-opus temperature=0.3
1086
+ * MODEL gpt-3.5-turbo temperature=0.8 topP=0.9
1087
+ * ```
1088
+ *
1089
+ * @private [🪔] Maybe export the commitments through some package
1090
+ */
1091
+ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
1092
+ constructor() {
1093
+ super('MODEL');
1094
+ }
1095
+ /**
1096
+ * Short one-line description of MODEL.
1097
+ */
1098
+ get description() {
1099
+ return 'Select the AI model and optional decoding parameters.';
1100
+ }
1101
+ /**
1102
+ * Markdown documentation for MODEL commitment.
1103
+ */
1104
+ get documentation() {
1105
+ return spaceTrim.spaceTrim(`
1106
+ # MODEL
1107
+
1108
+ Specifies which AI model to use and optional decoding parameters.
1109
+
1110
+ ## Key behaviors
1111
+
1112
+ - Only one \`MODEL\` commitment should be used per agent.
1113
+ - If multiple are specified, the last one takes precedence.
1114
+ - Parameters control the randomness and creativity of responses.
1115
+
1116
+ ## Supported parameters
1117
+
1118
+ - \`temperature\`: Controls randomness (0.0 = deterministic, 1.0+ = creative)
1119
+ - \`topP\` (aka \`top_p\`): Nucleus sampling parameter
1120
+ - \`topK\` (aka \`top_k\`): Top-k sampling parameter
1121
+
1122
+ ## Examples
1123
+
1124
+ \`\`\`book
1125
+ Precise Assistant
1126
+
1127
+ PERSONA You are a precise and accurate assistant
1128
+ MODEL gpt-4 temperature=0.1
1129
+ RULE Always provide factual information
1130
+ \`\`\`
1131
+
1132
+ \`\`\`book
1133
+ Creative Writer
1134
+
1135
+ PERSONA You are a creative writing assistant
1136
+ MODEL claude-3-opus temperature=0.8 topP=0.9
1137
+ STYLE Be imaginative and expressive
1138
+ ACTION Can help with storytelling and character development
1139
+ \`\`\`
1140
+ `);
1141
+ }
1142
+ applyToAgentModelRequirements(requirements, content) {
1143
+ const trimmedContent = content.trim();
1144
+ if (!trimmedContent) {
1145
+ return requirements;
1146
+ }
1147
+ // Parse the model specification
1148
+ const parts = trimmedContent.split(/\s+/);
1149
+ const modelName = parts[0];
1150
+ if (!modelName) {
1151
+ return requirements;
1152
+ }
1153
+ // Start with the model name
1154
+ const updatedRequirements = {
1155
+ ...requirements,
1156
+ modelName,
1157
+ };
1158
+ // Parse additional parameters
1159
+ const result = { ...updatedRequirements };
1160
+ for (let i = 1; i < parts.length; i++) {
1161
+ const param = parts[i];
1162
+ if (param && param.includes('=')) {
1163
+ const [key, value] = param.split('=');
1164
+ if (key && value) {
1165
+ const numValue = parseFloat(value);
1166
+ if (!isNaN(numValue)) {
1167
+ switch (key.toLowerCase()) {
1168
+ case 'temperature':
1169
+ result.temperature = numValue;
1170
+ break;
1171
+ case 'topp':
1172
+ case 'top_p':
1173
+ result.topP = numValue;
1174
+ break;
1175
+ case 'topk':
1176
+ case 'top_k':
1177
+ result.topK = Math.round(numValue);
1178
+ break;
1179
+ }
1180
+ }
1181
+ }
1182
+ }
1183
+ }
1184
+ return result;
1185
+ }
1186
+ }
1187
+ /**
1188
+ * Singleton instance of the MODEL commitment definition
1189
+ *
1190
+ * @private [🪔] Maybe export the commitments through some package
1191
+ */
1192
+ new ModelCommitmentDefinition();
1193
+ /**
1194
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1195
+ */
1196
+
1197
+ /**
1198
+ * NOTE commitment definition
1199
+ *
1200
+ * The NOTE commitment is used to add comments to the agent source without making any changes
1201
+ * to the system message or agent model requirements. It serves as a documentation mechanism
1202
+ * for developers to add explanatory comments, reminders, or annotations directly in the agent source.
1203
+ *
1204
+ * Key features:
1205
+ * - Makes no changes to the system message
1206
+ * - Makes no changes to agent model requirements
1207
+ * - Content is preserved in metadata.NOTE for debugging and inspection
1208
+ * - Multiple NOTE commitments are aggregated together
1209
+ * - Comments (# NOTE) are removed from the final system message
1210
+ *
1211
+ * Example usage in agent source:
1212
+ *
1213
+ * ```book
1214
+ * NOTE This agent was designed for customer support scenarios
1215
+ * NOTE Remember to update the knowledge base monthly
1216
+ * NOTE Performance optimized for quick response times
1217
+ * ```
1218
+ *
1219
+ * The above notes will be stored in metadata but won't affect the agent's behavior.
1220
+ *
1221
+ * @private [🪔] Maybe export the commitments through some package
1222
+ */
1223
+ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
1224
+ constructor() {
1225
+ super('NOTE');
1226
+ }
1227
+ /**
1228
+ * Short one-line description of NOTE.
1229
+ */
1230
+ get description() {
1231
+ return 'Add developer-facing notes without changing behavior or output.';
1232
+ }
1233
+ /**
1234
+ * Markdown documentation for NOTE commitment.
1235
+ */
1236
+ get documentation() {
1237
+ return spaceTrim.spaceTrim(`
1238
+ # NOTE
1239
+
1240
+ Adds comments for documentation without changing agent behavior.
1241
+
1242
+ ## Key behaviors
1243
+
1244
+ - Does not modify the agent's behavior or responses.
1245
+ - Multiple \`NOTE\` commitments are aggregated for debugging.
1246
+ - Useful for documenting design decisions and reminders.
1247
+ - Content is preserved in metadata for inspection.
1248
+
1249
+ ## Examples
1250
+
1251
+ \`\`\`book
1252
+ Customer Support Bot
1253
+
1254
+ NOTE This agent was designed for customer support scenarios
1255
+ NOTE Remember to update the knowledge base monthly
1256
+ PERSONA You are a helpful customer support representative
1257
+ KNOWLEDGE Company policies and procedures
1258
+ RULE Always be polite and professional
1259
+ \`\`\`
1260
+
1261
+ \`\`\`book
1262
+ Research Assistant
1263
+
1264
+ NOTE Performance optimized for quick response times
1265
+ NOTE Uses RAG for accessing latest research papers
1266
+ PERSONA You are a knowledgeable research assistant
1267
+ ACTION Can help with literature reviews and citations
1268
+ STYLE Present information in academic format
1269
+ \`\`\`
1270
+ `);
1271
+ }
1272
+ applyToAgentModelRequirements(requirements, content) {
1273
+ var _a;
1274
+ // The NOTE commitment makes no changes to the system message or model requirements
1275
+ // It only stores the note content in metadata for documentation purposes
1276
+ const trimmedContent = content.trim();
1277
+ if (!trimmedContent) {
1278
+ return requirements;
1279
+ }
1280
+ // Get existing note content from metadata
1281
+ const existingNoteContent = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.NOTE) || '';
1282
+ // Merge the new content with existing note content
1283
+ // When multiple NOTE commitments exist, they are aggregated together
1284
+ const mergedNoteContent = existingNoteContent ? `${existingNoteContent}\n${trimmedContent}` : trimmedContent;
1285
+ // Store the merged note content in metadata for debugging and inspection
1286
+ const updatedMetadata = {
1287
+ ...requirements.metadata,
1288
+ NOTE: mergedNoteContent,
1289
+ };
1290
+ // Return requirements with updated metadata but no changes to system message
1291
+ return {
1292
+ ...requirements,
1293
+ metadata: updatedMetadata,
1294
+ };
1295
+ }
1296
+ }
1297
+ /**
1298
+ * Singleton instance of the NOTE commitment definition
1299
+ *
1300
+ * @private [🪔] Maybe export the commitments through some package
1301
+ */
1302
+ new NoteCommitmentDefinition();
1303
+ /**
1304
+ * [💞] Ignore a discrepancy between file name and entity name
1305
+ */
1306
+
1307
+ /**
1308
+ * PERSONA commitment definition
1309
+ *
1310
+ * The PERSONA commitment modifies the agent's personality and character in the system message.
1311
+ * It defines who the agent is, their background, expertise, and personality traits.
1312
+ *
1313
+ * Key features:
1314
+ * - Multiple PERSONA commitments are automatically merged into one
1315
+ * - Content is placed at the beginning of the system message
1316
+ * - Original content with comments is preserved in metadata.PERSONA
1317
+ * - Comments (# PERSONA) are removed from the final system message
1318
+ *
1319
+ * Example usage in agent source:
1320
+ *
1321
+ * ```book
1322
+ * PERSONA You are a helpful programming assistant with expertise in TypeScript and React
1323
+ * PERSONA You have deep knowledge of modern web development practices
1324
+ * ```
1325
+ *
1326
+ * The above will be merged into a single persona section at the beginning of the system message.
1327
+ *
1328
+ * @private [🪔] Maybe export the commitments through some package
1329
+ */
1330
+ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
1331
+ constructor() {
1332
+ super('PERSONA');
1333
+ }
1334
+ /**
1335
+ * Short one-line description of PERSONA.
1336
+ */
1337
+ get description() {
1338
+ return 'Define who the agent is: background, expertise, and personality.';
1339
+ }
1340
+ /**
1341
+ * Markdown documentation for PERSONA commitment.
1342
+ */
1343
+ get documentation() {
1344
+ return spaceTrim.spaceTrim(`
1345
+ # PERSONA
1346
+
1347
+ Defines who the agent is, their background, expertise, and personality traits.
1348
+
1349
+ ## Key behaviors
1350
+
1351
+ - Multiple \`PERSONA\` commitments are merged together.
1352
+ - If they are in conflict, the last one takes precedence.
1353
+ - You can write persona content in multiple lines.
1354
+
1355
+ ## Examples
1356
+
1357
+ \`\`\`book
1358
+ Programming Assistant
1359
+
1360
+ PERSONA You are a helpful programming assistant with expertise in TypeScript and React
1361
+ PERSONA You have deep knowledge of modern web development practices
1362
+ \`\`\`
1363
+ `);
1364
+ }
1365
+ applyToAgentModelRequirements(requirements, content) {
1366
+ var _a, _b;
1367
+ // The PERSONA commitment aggregates all persona content and places it at the beginning
1368
+ const trimmedContent = content.trim();
1369
+ if (!trimmedContent) {
1370
+ return requirements;
1371
+ }
1372
+ // Get existing persona content from metadata
1373
+ const existingPersonaContent = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.PERSONA) || '';
1374
+ // Merge the new content with existing persona content
1375
+ // When multiple PERSONA commitments exist, they are merged into one
1376
+ const mergedPersonaContent = existingPersonaContent
1377
+ ? `${existingPersonaContent}\n${trimmedContent}`
1378
+ : trimmedContent;
1379
+ // Store the merged persona content in metadata for debugging and inspection
1380
+ const updatedMetadata = {
1381
+ ...requirements.metadata,
1382
+ PERSONA: mergedPersonaContent,
1383
+ };
1384
+ // Get the agent name from metadata (which should contain the first line of agent source)
1385
+ // If not available, extract from current system message as fallback
1386
+ let agentName = (_b = requirements.metadata) === null || _b === void 0 ? void 0 : _b.agentName;
1387
+ if (!agentName) {
1388
+ // Fallback: extract from current system message
1389
+ const currentMessage = requirements.systemMessage.trim();
1390
+ const basicFormatMatch = currentMessage.match(/^You are (.+)$/);
1391
+ if (basicFormatMatch && basicFormatMatch[1]) {
1392
+ agentName = basicFormatMatch[1];
1393
+ }
1394
+ else {
1395
+ agentName = 'AI Agent'; // Final fallback
1396
+ }
1397
+ }
1398
+ // Remove any existing persona content from the system message
1399
+ // (this handles the case where we're processing multiple PERSONA commitments)
1400
+ const currentMessage = requirements.systemMessage.trim();
1401
+ let cleanedMessage = currentMessage;
1402
+ // Check if current message starts with persona content or is just the basic format
1403
+ const basicFormatRegex = /^You are .+$/;
1404
+ const isBasicFormat = basicFormatRegex.test(currentMessage) && !currentMessage.includes('\n');
1405
+ if (isBasicFormat) {
1406
+ // Replace the basic format entirely
1407
+ cleanedMessage = '';
1408
+ }
1409
+ else if (currentMessage.startsWith('# PERSONA')) {
1410
+ // Remove existing persona section by finding where it ends
1411
+ const lines = currentMessage.split('\n');
1412
+ let personaEndIndex = lines.length;
1413
+ // Find the end of the PERSONA section (next comment or end of message)
1414
+ for (let i = 1; i < lines.length; i++) {
1415
+ const line = lines[i].trim();
1416
+ if (line.startsWith('#') && !line.startsWith('# PERSONA')) {
1417
+ personaEndIndex = i;
1418
+ break;
1419
+ }
1420
+ }
1421
+ // Keep everything after the PERSONA section
1422
+ cleanedMessage = lines.slice(personaEndIndex).join('\n').trim();
1423
+ }
1424
+ // Create new system message with persona at the beginning
1425
+ // Format: "You are {agentName}\n{personaContent}"
1426
+ // The # PERSONA comment will be removed later by removeCommentsFromSystemMessage
1427
+ const personaSection = `# PERSONA\nYou are ${agentName}\n${mergedPersonaContent}`; // <- TODO: Use spaceTrim
1428
+ const newSystemMessage = cleanedMessage ? `${personaSection}\n\n${cleanedMessage}` : personaSection;
1429
+ return {
1430
+ ...requirements,
1431
+ systemMessage: newSystemMessage,
1432
+ metadata: updatedMetadata,
1433
+ };
1434
+ }
1435
+ }
1436
+ /**
1437
+ * Singleton instance of the PERSONA commitment definition
1438
+ *
1439
+ * @private [🪔] Maybe export the commitments through some package
1440
+ */
1441
+ new PersonaCommitmentDefinition();
1442
+ /**
1443
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1444
+ */
1445
+
1446
+ /**
1447
+ * RULE commitment definition
1448
+ *
1449
+ * The RULE/RULES commitment adds behavioral constraints and guidelines that the agent must follow.
1450
+ * These are specific instructions about what the agent should or shouldn't do.
1451
+ *
1452
+ * Example usage in agent source:
1453
+ *
1454
+ * ```book
1455
+ * RULE Always ask for clarification if the user's request is ambiguous
1456
+ * RULES Never provide medical advice, always refer to healthcare professionals
1457
+ * ```
1458
+ *
1459
+ * @private [🪔] Maybe export the commitments through some package
1460
+ */
1461
+ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
1462
+ constructor(type = 'RULE') {
1463
+ super(type);
1464
+ }
1465
+ /**
1466
+ * Short one-line description of RULE/RULES.
1467
+ */
1468
+ get description() {
1469
+ return 'Add behavioral rules the agent must follow.';
1470
+ }
1471
+ /**
1472
+ * Markdown documentation for RULE/RULES commitment.
1473
+ */
1474
+ get documentation() {
1475
+ return spaceTrim.spaceTrim(`
1476
+ # ${this.type}
1477
+
1478
+ Adds behavioral constraints and guidelines that the agent must follow.
1479
+
1480
+ ## Key behaviors
1481
+
1482
+ - Multiple \`RULE\` and \`RULES\` commitments are applied sequentially.
1483
+ - All rules are treated equally regardless of singular/plural form.
1484
+ - Rules define what the agent must or must not do.
1485
+
1486
+ ## Examples
1487
+
1488
+ \`\`\`book
1489
+ Customer Support Agent
1490
+
1491
+ PERSONA You are a helpful customer support representative
1492
+ RULE Always ask for clarification if the user's request is ambiguous
1493
+ RULE Be polite and professional in all interactions
1494
+ RULES Never provide medical or legal advice
1495
+ STYLE Maintain a friendly and helpful tone
1496
+ \`\`\`
1497
+
1498
+ \`\`\`book
1499
+ Educational Tutor
1500
+
1501
+ PERSONA You are a patient and knowledgeable tutor
1502
+ RULE Break down complex concepts into simple steps
1503
+ RULE Always encourage students and celebrate their progress
1504
+ RULE If you don't know something, admit it and suggest resources
1505
+ SAMPLE When explaining math: "Let's work through this step by step..."
1506
+ \`\`\`
1507
+ `);
1508
+ }
1509
+ applyToAgentModelRequirements(requirements, content) {
1510
+ const trimmedContent = content.trim();
1511
+ if (!trimmedContent) {
1512
+ return requirements;
1513
+ }
1514
+ // Add rule to the system message
1515
+ const ruleSection = `Rule: ${trimmedContent}`;
1516
+ return this.appendToSystemMessage(requirements, ruleSection, '\n\n');
1517
+ }
1518
+ }
1519
+ /**
1520
+ * Singleton instances of the RULE commitment definitions
1521
+ *
1522
+ * @private [🪔] Maybe export the commitments through some package
1523
+ */
1524
+ new RuleCommitmentDefinition('RULE');
1525
+ /**
1526
+ * Singleton instances of the RULE commitment definitions
1527
+ *
1528
+ * @private [🪔] Maybe export the commitments through some package
1529
+ */
1530
+ new RuleCommitmentDefinition('RULES');
1531
+ /**
1532
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1533
+ */
1534
+
1535
+ /**
1536
+ * SAMPLE commitment definition
1537
+ *
1538
+ * The SAMPLE/EXAMPLE commitment provides examples of how the agent should respond
1539
+ * or behave in certain situations. These examples help guide the agent's responses.
1540
+ *
1541
+ * Example usage in agent source:
1542
+ *
1543
+ * ```book
1544
+ * SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
1545
+ * EXAMPLE For code questions, always include working code snippets
1546
+ * ```
1547
+ *
1548
+ * @private [🪔] Maybe export the commitments through some package
1549
+ */
1550
+ class SampleCommitmentDefinition extends BaseCommitmentDefinition {
1551
+ constructor(type = 'SAMPLE') {
1552
+ super(type);
1553
+ }
1554
+ /**
1555
+ * Short one-line description of SAMPLE/EXAMPLE.
1556
+ */
1557
+ get description() {
1558
+ return 'Provide example responses to guide behavior.';
1559
+ }
1560
+ /**
1561
+ * Markdown documentation for SAMPLE/EXAMPLE commitment.
1562
+ */
1563
+ get documentation() {
1564
+ return spaceTrim.spaceTrim(`
1565
+ # ${this.type}
1566
+
1567
+ Provides examples of how the agent should respond or behave in certain situations.
1568
+
1569
+ ## Key behaviors
1570
+
1571
+ - Multiple \`SAMPLE\` and \`EXAMPLE\` commitments are applied sequentially.
1572
+ - Both terms work identically and can be used interchangeably.
1573
+ - Examples help guide the agent's response patterns and style.
1574
+
1575
+ ## Examples
1576
+
1577
+ \`\`\`book
1578
+ Sales Assistant
1579
+
1580
+ PERSONA You are a knowledgeable sales representative
1581
+ SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
1582
+ SAMPLE For feature comparisons, create a clear comparison table
1583
+ RULE Always be honest about limitations
1584
+ \`\`\`
1585
+
1586
+ \`\`\`book
1587
+ Code Reviewer
1588
+
1589
+ PERSONA You are an experienced software engineer
1590
+ EXAMPLE For code questions, always include working code snippets
1591
+ EXAMPLE When suggesting improvements: "Here's a more efficient approach..."
1592
+ RULE Explain the reasoning behind your suggestions
1593
+ STYLE Be constructive and encouraging in feedback
1594
+ \`\`\`
1595
+ `);
1596
+ }
1597
+ applyToAgentModelRequirements(requirements, content) {
1598
+ const trimmedContent = content.trim();
1599
+ if (!trimmedContent) {
1600
+ return requirements;
1601
+ }
1602
+ // Add example to the system message
1603
+ const exampleSection = `Example: ${trimmedContent}`;
1604
+ return this.appendToSystemMessage(requirements, exampleSection, '\n\n');
1605
+ }
1606
+ }
1607
+ /**
1608
+ * Singleton instances of the SAMPLE commitment definitions
1609
+ *
1610
+ * @private [🪔] Maybe export the commitments through some package
1611
+ */
1612
+ new SampleCommitmentDefinition('SAMPLE');
1613
+ /**
1614
+ * Singleton instances of the SAMPLE commitment definitions
1615
+ *
1616
+ * @private [🪔] Maybe export the commitments through some package
1617
+ */
1618
+ new SampleCommitmentDefinition('EXAMPLE');
1619
+ /**
1620
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1621
+ */
1622
+
1623
+ /**
1624
+ * STYLE commitment definition
1625
+ *
1626
+ * The STYLE commitment defines how the agent should format and present its responses.
1627
+ * This includes tone, writing style, formatting preferences, and communication patterns.
1628
+ *
1629
+ * Example usage in agent source:
1630
+ *
1631
+ * ```book
1632
+ * STYLE Write in a professional but friendly tone, use bullet points for lists
1633
+ * STYLE Always provide code examples when explaining programming concepts
1634
+ * ```
1635
+ *
1636
+ * @private [🪔] Maybe export the commitments through some package
1637
+ */
1638
+ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
1639
+ constructor() {
1640
+ super('STYLE');
1641
+ }
1642
+ /**
1643
+ * Short one-line description of STYLE.
1644
+ */
1645
+ get description() {
1646
+ return 'Control the tone and writing style of responses.';
1647
+ }
1648
+ /**
1649
+ * Markdown documentation for STYLE commitment.
1650
+ */
1651
+ get documentation() {
1652
+ return spaceTrim.spaceTrim(`
1653
+ # STYLE
1654
+
1655
+ Defines how the agent should format and present its responses (tone, writing style, formatting).
1656
+
1657
+ ## Key behaviors
1658
+
1659
+ - Multiple \`STYLE\` commitments are applied sequentially.
1660
+ - Later style instructions can override earlier ones.
1661
+ - Style affects both tone and presentation format.
1662
+
1663
+ ## Examples
1664
+
1665
+ \`\`\`book
1666
+ Technical Writer
1667
+
1668
+ PERSONA You are a technical documentation expert
1669
+ STYLE Write in a professional but friendly tone, use bullet points for lists
1670
+ STYLE Always provide code examples when explaining programming concepts
1671
+ FORMAT Use markdown formatting with clear headings
1672
+ \`\`\`
1673
+
1674
+ \`\`\`book
1675
+ Creative Assistant
1676
+
1677
+ PERSONA You are a creative writing helper
1678
+ STYLE Be enthusiastic and encouraging in your responses
1679
+ STYLE Use vivid metaphors and analogies to explain concepts
1680
+ STYLE Keep responses conversational and engaging
1681
+ RULE Always maintain a positive and supportive tone
1682
+ \`\`\`
1683
+ `);
1684
+ }
1685
+ applyToAgentModelRequirements(requirements, content) {
1686
+ const trimmedContent = content.trim();
1687
+ if (!trimmedContent) {
1688
+ return requirements;
1689
+ }
1690
+ // Add style instructions to the system message
1691
+ const styleSection = `Style: ${trimmedContent}`;
1692
+ return this.appendToSystemMessage(requirements, styleSection, '\n\n');
1693
+ }
1694
+ }
1695
+ /**
1696
+ * Singleton instance of the STYLE commitment definition
1697
+ *
1698
+ * @private [🪔] Maybe export the commitments through some package
1699
+ */
1700
+ new StyleCommitmentDefinition();
1701
+ /**
1702
+ * [💞] Ignore a discrepancy between file name and entity name
1703
+ */
1704
+
1705
+ /**
1706
+ * Placeholder commitment definition for commitments that are not yet implemented
1707
+ *
1708
+ * This commitment simply adds its content 1:1 into the system message,
1709
+ * preserving the original behavior until proper implementation is added.
1710
+ *
1711
+ * @public exported from `@promptbook/core`
1712
+ */
1713
+ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
1714
+ constructor(type) {
1715
+ super(type);
1716
+ }
1717
+ /**
1718
+ * Short one-line description of a placeholder commitment.
1719
+ */
1720
+ get description() {
1721
+ return 'Placeholder commitment that appends content verbatim to the system message.';
1722
+ }
1723
+ /**
1724
+ * Markdown documentation available at runtime.
1725
+ */
1726
+ get documentation() {
1727
+ return spaceTrim.spaceTrim(`
1728
+ # ${this.type}
1729
+
1730
+ This commitment is not yet fully implemented.
1731
+
1732
+ ## Key behaviors
1733
+
1734
+ - Content is appended directly to the system message.
1735
+ - No special processing or validation is performed.
1736
+ - Behavior preserved until proper implementation is added.
1737
+
1738
+ ## Status
1739
+
1740
+ - **Status:** Placeholder implementation
1741
+ - **Effect:** Appends content prefixed by commitment type
1742
+ - **Future:** Will be replaced with specialized logic
1743
+
1744
+ ## Examples
1745
+
1746
+ \`\`\`book
1747
+ Example Agent
1748
+
1749
+ PERSONA You are a helpful assistant
1750
+ ${this.type} Your content here
1751
+ RULE Always be helpful
1752
+ \`\`\`
1753
+ `);
1754
+ }
1755
+ applyToAgentModelRequirements(requirements, content) {
1756
+ const trimmedContent = content.trim();
1757
+ if (!trimmedContent) {
1758
+ return requirements;
1759
+ }
1760
+ // Add the commitment content 1:1 to the system message
1761
+ const commitmentLine = `${this.type} ${trimmedContent}`;
1762
+ return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
1763
+ }
1764
+ }
1765
+
1766
+ // Import all commitment definition classes
1767
+ /**
1768
+ * Registry of all available commitment definitions
1769
+ * This array contains instances of all commitment definitions
1770
+ * This is the single source of truth for all commitments in the system
1771
+ *
1772
+ * @private Use functions to access commitments instead of this array directly
1773
+ */
1774
+ const COMMITMENT_REGISTRY = [
1775
+ // Fully implemented commitments
1776
+ new PersonaCommitmentDefinition(),
1777
+ new KnowledgeCommitmentDefinition(),
1778
+ new StyleCommitmentDefinition(),
1779
+ new RuleCommitmentDefinition('RULE'),
1780
+ new RuleCommitmentDefinition('RULES'),
1781
+ new SampleCommitmentDefinition('SAMPLE'),
1782
+ new SampleCommitmentDefinition('EXAMPLE'),
1783
+ new FormatCommitmentDefinition(),
1784
+ new ModelCommitmentDefinition(),
1785
+ new ActionCommitmentDefinition(),
1786
+ new MetaImageCommitmentDefinition(),
1787
+ new MetaLinkCommitmentDefinition(),
1788
+ new NoteCommitmentDefinition(),
1789
+ // Not yet implemented commitments (using placeholder)
1790
+ new NotYetImplementedCommitmentDefinition('EXPECT'),
1791
+ new NotYetImplementedCommitmentDefinition('SCENARIO'),
1792
+ new NotYetImplementedCommitmentDefinition('SCENARIOS'),
1793
+ new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
1794
+ new NotYetImplementedCommitmentDefinition('BEHAVIOURS'),
1795
+ new NotYetImplementedCommitmentDefinition('AVOID'),
1796
+ new NotYetImplementedCommitmentDefinition('AVOIDANCE'),
1797
+ new NotYetImplementedCommitmentDefinition('GOAL'),
1798
+ new NotYetImplementedCommitmentDefinition('GOALS'),
1799
+ new NotYetImplementedCommitmentDefinition('CONTEXT'),
1800
+ ];
1801
+ /**
1802
+ * Gets all available commitment definitions
1803
+ * @returns Array of all commitment definitions
1804
+ *
1805
+ * @public exported from `@promptbook/core`
1806
+ */
1807
+ function getAllCommitmentDefinitions() {
1808
+ return $deepFreeze([...COMMITMENT_REGISTRY]);
1809
+ }
1810
+ /**
1811
+ * TODO: !!!! Maybe create through standardized $register
1812
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1813
+ */
1814
+
1815
+ /**
1816
+ * Escape HTML to safely render user text inside a <pre> with dangerouslySetInnerHTML.
1817
+ *
1818
+ * @private within the BookEditor component
1819
+ */
1820
+ function escapeHtml(input) {
1821
+ return input.replaceAll(/&/g, '&amp;').replaceAll(/</g, '&lt;').replaceAll(/>/g, '&gt;');
1822
+ }
1823
+ /**
1824
+ * Escape text for safe use inside a RegExp pattern.
1825
+ *
1826
+ * @private within the BookEditor component
1827
+ */
1828
+ function escapeRegex(input) {
1829
+ return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1830
+ }
1831
+ /**
1832
+ * Renders a book editor
1833
+ *
1834
+ * @public exported from `@promptbook/components`
1835
+ */
1836
+ function BookEditor(props) {
1837
+ const { className = '', value: controlledValue, onChange, fontClassName = '' } = props;
1838
+ const [internalValue, setInternalValue] = react.useState(DEFAULT_BOOK);
1839
+ const value = controlledValue !== undefined ? controlledValue : internalValue;
1840
+ const textareaRef = react.useRef(null);
1841
+ const highlightRef = react.useRef(null);
1842
+ const [lineHeight, setLineHeight] = react.useState(32);
1843
+ const handleChange = react.useCallback((event) => {
1844
+ const newValue = event.target.value;
1845
+ if (controlledValue !== undefined) {
1846
+ onChange === null || onChange === void 0 ? void 0 : onChange(validateBook(newValue));
1847
+ }
1848
+ else {
1849
+ setInternalValue(validateBook(newValue));
1850
+ }
1851
+ }, [controlledValue, onChange]);
1852
+ const handleScroll = react.useCallback((event) => {
1853
+ const t = event.currentTarget;
1854
+ if (highlightRef.current) {
1855
+ highlightRef.current.scrollTop = t.scrollTop;
1856
+ highlightRef.current.scrollLeft = t.scrollLeft;
1857
+ }
1858
+ }, []);
1859
+ react.useEffect(() => {
1860
+ var _a;
1861
+ const el = textareaRef.current;
1862
+ if (!el)
1863
+ return;
1864
+ const measure = () => {
1865
+ const cs = window.getComputedStyle(el);
1866
+ const lh = parseFloat(cs.lineHeight || '0');
1867
+ if (!Number.isNaN(lh) && lh > 0) {
1868
+ setLineHeight(lh);
1869
+ }
1870
+ };
1871
+ // Initial measure
1872
+ measure();
1873
+ // Re-measure after fonts load (metrics can change once font renders)
1874
+ const fontsReady = (_a = document.fonts) === null || _a === void 0 ? void 0 : _a.ready;
1875
+ if (fontsReady && typeof fontsReady.then === 'function') {
1876
+ fontsReady
1877
+ .then(() => {
1878
+ measure();
1879
+ })
1880
+ .catch(() => {
1881
+ /* ignore */
1882
+ });
1883
+ }
1884
+ // Re-measure on resize
1885
+ window.addEventListener('resize', measure);
1886
+ return () => {
1887
+ window.removeEventListener('resize', measure);
1888
+ };
1889
+ }, []);
1890
+ // Build the regex for commitment types
1891
+ const typeRegex = react.useMemo(() => {
1892
+ const allTypes = getAllCommitmentDefinitions().map(({ type }) => String(type));
1893
+ const pattern = `\\b(?:${allTypes.map((t) => escapeRegex(t)).join('|')})\\b`;
1894
+ return new RegExp(pattern, 'gmi');
1895
+ }, []);
1896
+ // Generate highlighted HTML version of the current text
1897
+ const highlightedHtml = react.useMemo(() => {
1898
+ const text = value !== null && value !== void 0 ? value : '';
1899
+ const r = typeRegex;
1900
+ let lastIndex = 0;
1901
+ let out = '';
1902
+ text.replace(r, (match, ...args) => {
1903
+ const index = args[args.length - 2]; // offset
1904
+ out += escapeHtml(text.slice(lastIndex, index));
1905
+ out += `<span class="text-indigo-700">${escapeHtml(match)}</span>`;
1906
+ lastIndex = index + match.length;
1907
+ return match;
1908
+ });
1909
+ out += escapeHtml(text.slice(lastIndex));
1910
+ return out;
1911
+ }, [value, typeRegex]);
1912
+ return (jsxRuntime.jsx("div", { className: `w-full ${className}`, children: jsxRuntime.jsxs("div", { className: [
1913
+ 'relative overflow-hidden rounded-2xl border border-gray-300/80 bg-white shadow-sm focus-within:ring-2 focus-within:ring-indigo-300/40',
1914
+ 'transition-shadow duration-200 hover:shadow-md',
1915
+ fontClassName,
1916
+ // [7] libreBaskerville.className,
1917
+ ].join(' '), children: [jsxRuntime.jsx("div", { "aria-hidden": true, className: "pointer-events-none absolute inset-0",
1918
+ // Two background layers:
1919
+ // 1) center fold line
1920
+ // 2) horizontal repeating lines (lined paper)
1921
+ style: {
1922
+ backgroundImage: 'none',
1923
+ } }), jsxRuntime.jsx("pre", { ref: highlightRef, "aria-hidden": true, className: [
1924
+ 'absolute inset-0 overflow-auto pointer-events-none',
1925
+ 'whitespace-pre-wrap',
1926
+ 'text-gray-900',
1927
+ 'text-lg md:text-xl',
1928
+ 'py-6 md:py-8',
1929
+ 'pl-[46px] pr-[46px]',
1930
+ // Ensure highlighted text sits below the textarea but remains visible
1931
+ 'z-10',
1932
+ fontClassName,
1933
+ ].join(' '), style: {
1934
+ lineHeight: `${lineHeight}px`,
1935
+ backgroundImage: `linear-gradient(90deg, transparent 30px, rgba(59,130,246,0.3) 30px, rgba(59,130,246,0.3) 31px, transparent 31px), repeating-linear-gradient(0deg, transparent, transparent calc(${lineHeight}px - 1px), rgba(0,0,0,0.06) ${lineHeight}px)`,
1936
+ backgroundAttachment: 'local',
1937
+ backgroundOrigin: 'padding-box, content-box',
1938
+ backgroundClip: 'padding-box, content-box',
1939
+ overflowWrap: 'break-word',
1940
+ scrollbarWidth: 'none',
1941
+ msOverflowStyle: 'none',
1942
+ }, dangerouslySetInnerHTML: { __html: highlightedHtml } }), jsxRuntime.jsx("textarea", { ref: textareaRef, value: value, onChange: handleChange, onScroll: handleScroll, className: [
1943
+ 'relative z-20 w-full',
1944
+ // Taller editor area
1945
+ 'h-[28rem] md:h-[36rem]',
1946
+ // Typography
1947
+ 'text-transparent caret-gray-900 selection:bg-indigo-200/60',
1948
+ 'text-lg md:text-xl',
1949
+ fontClassName,
1950
+ // [7] libreBaskerville.className,
1951
+ // Layout and visuals
1952
+ 'bg-transparent outline-none resize-none',
1953
+ 'py-6 md:py-8',
1954
+ 'pl-[46px] pr-[46px]',
1955
+ ].join(' '), style: { lineHeight: `${lineHeight}px` }, spellCheck: false })] }) }));
1956
+ }
1957
+
1958
+ exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
1959
+ exports.BookEditor = BookEditor;
1960
+ exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
1961
+
1962
+ Object.defineProperty(exports, '__esModule', { value: true });
1963
+
1964
+ }));
1965
+ //# sourceMappingURL=index.umd.js.map