@promptbook/browser 0.92.0-8 → 0.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/README.md +1 -5
  2. package/esm/index.es.js +134 -28
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/browser.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +26 -14
  6. package/esm/typings/src/_packages/types.index.d.ts +6 -2
  7. package/esm/typings/src/collection/PipelineCollection.d.ts +0 -2
  8. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
  9. package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -6
  10. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +0 -2
  11. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
  12. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
  13. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +36 -28
  14. package/esm/typings/src/config.d.ts +41 -11
  15. package/esm/typings/src/constants.d.ts +43 -2
  16. package/esm/typings/src/conversion/parsePipeline.d.ts +2 -2
  17. package/esm/typings/src/errors/0-BoilerplateError.d.ts +2 -2
  18. package/esm/typings/src/errors/CollectionError.d.ts +1 -1
  19. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -1
  20. package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +2 -1
  21. package/esm/typings/src/executables/apps/locatePandoc.d.ts +2 -1
  22. package/esm/typings/src/executables/locateApp.d.ts +2 -2
  23. package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +2 -1
  24. package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +2 -1
  25. package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +2 -1
  26. package/esm/typings/src/execution/AbstractTaskResult.d.ts +1 -1
  27. package/esm/typings/src/execution/CommonToolsOptions.d.ts +5 -1
  28. package/esm/typings/src/execution/ExecutionTask.d.ts +19 -1
  29. package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +2 -1
  30. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +4 -2
  31. package/esm/typings/src/execution/PromptbookFetch.d.ts +1 -1
  32. package/esm/typings/src/execution/ScriptExecutionTools.d.ts +1 -1
  33. package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +12 -9
  34. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +13 -10
  35. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +12 -9
  36. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +15 -3
  37. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +21 -15
  38. package/esm/typings/src/execution/createPipelineExecutor/computeCosineSimilarity.d.ts +13 -0
  39. package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +7 -6
  40. package/esm/typings/src/execution/createPipelineExecutor/getContextForTask.d.ts +5 -1
  41. package/esm/typings/src/execution/createPipelineExecutor/getExamplesForTask.d.ts +1 -1
  42. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +12 -9
  43. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +18 -5
  44. package/esm/typings/src/execution/createPipelineExecutor/knowledgePiecesToString.d.ts +9 -0
  45. package/esm/typings/src/execution/execution-report/ExecutionReportJson.d.ts +1 -1
  46. package/esm/typings/src/execution/execution-report/ExecutionReportString.d.ts +1 -1
  47. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +4 -4
  48. package/esm/typings/src/execution/utils/checkExpectations.d.ts +3 -3
  49. package/esm/typings/src/execution/utils/uncertainNumber.d.ts +3 -2
  50. package/esm/typings/src/execution/utils/usageToWorktime.d.ts +1 -1
  51. package/esm/typings/src/formats/_common/{FormatDefinition.d.ts → FormatParser.d.ts} +8 -6
  52. package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +66 -0
  53. package/esm/typings/src/formats/csv/CsvFormatParser.d.ts +17 -0
  54. package/esm/typings/src/formats/csv/CsvSettings.d.ts +2 -2
  55. package/esm/typings/src/formats/csv/utils/csvParse.d.ts +12 -0
  56. package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +1 -1
  57. package/esm/typings/src/formats/index.d.ts +2 -2
  58. package/esm/typings/src/formats/json/JsonFormatParser.d.ts +19 -0
  59. package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +1 -1
  60. package/esm/typings/src/formats/json/utils/jsonParse.d.ts +0 -3
  61. package/esm/typings/src/formats/text/{TextFormatDefinition.d.ts → TextFormatParser.d.ts} +7 -7
  62. package/esm/typings/src/formats/xml/XmlFormatParser.d.ts +19 -0
  63. package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +1 -1
  64. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +3 -2
  65. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +16 -7
  66. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +3 -1
  67. package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +2 -1
  68. package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +2 -2
  69. package/esm/typings/src/formfactors/completion/CompletionFormfactorDefinition.d.ts +29 -0
  70. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +2 -1
  71. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +2 -2
  72. package/esm/typings/src/formfactors/index.d.ts +33 -8
  73. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +4 -2
  74. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +3 -2
  75. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +3 -2
  76. package/esm/typings/src/high-level-abstractions/index.d.ts +2 -2
  77. package/esm/typings/src/llm-providers/_common/register/$llmToolsMetadataRegister.d.ts +3 -3
  78. package/esm/typings/src/llm-providers/_common/register/$llmToolsRegister.d.ts +3 -3
  79. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +4 -4
  80. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +4 -3
  81. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +18 -5
  82. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +11 -4
  83. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +21 -42
  84. package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +9 -2
  85. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +13 -4
  86. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +10 -5
  87. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +11 -3
  88. package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +3 -3
  89. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +5 -5
  90. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +6 -0
  91. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  92. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -1
  93. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +4 -4
  94. package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
  95. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  96. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +1 -1
  97. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
  98. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  99. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -2
  100. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -2
  101. package/esm/typings/src/migrations/migratePipeline.d.ts +9 -0
  102. package/esm/typings/src/other/templates/getBookTemplates.d.ts +2 -2
  103. package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +3 -3
  104. package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +1 -1
  105. package/esm/typings/src/pipeline/PipelineInterface/getPipelineInterface.d.ts +1 -1
  106. package/esm/typings/src/pipeline/PipelineInterface/isPipelineImplementingInterface.d.ts +5 -4
  107. package/esm/typings/src/pipeline/PipelineInterface/isPipelineInterfacesEqual.d.ts +1 -1
  108. package/esm/typings/src/pipeline/PipelineJson/CommonTaskJson.d.ts +10 -7
  109. package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +1 -1
  110. package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +3 -2
  111. package/esm/typings/src/pipeline/PipelineString.d.ts +3 -1
  112. package/esm/typings/src/pipeline/book-notation.d.ts +2 -2
  113. package/esm/typings/src/postprocessing/utils/extractBlock.d.ts +1 -1
  114. package/esm/typings/src/postprocessing/utils/extractJsonBlock.d.ts +2 -2
  115. package/esm/typings/src/prepare/prepareTasks.d.ts +8 -5
  116. package/esm/typings/src/remote-server/openapi.d.ts +1 -1
  117. package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Response.d.ts +1 -1
  118. package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -1
  119. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +7 -6
  120. package/esm/typings/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +3 -3
  121. package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -1
  122. package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -1
  123. package/esm/typings/src/scrapers/_common/Converter.d.ts +3 -1
  124. package/esm/typings/src/scrapers/_common/Scraper.d.ts +4 -3
  125. package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +4 -2
  126. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +2 -2
  127. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -1
  128. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +6 -3
  129. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +3 -5
  130. package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +3 -3
  131. package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +3 -2
  132. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +8 -5
  133. package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +2 -1
  134. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +6 -5
  135. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +3 -1
  136. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
  137. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +2 -1
  138. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +4 -1
  139. package/esm/typings/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
  140. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +2 -1
  141. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -4
  142. package/esm/typings/src/scripting/javascript/JavascriptExecutionTools.d.ts +1 -1
  143. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +5 -1
  144. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  145. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -1
  146. package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +12 -5
  147. package/esm/typings/src/storage/file-cache-storage/FileCacheStorageOptions.d.ts +4 -2
  148. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +2 -1
  149. package/esm/typings/src/storage/local-storage/getIndexedDbStorage.d.ts +11 -0
  150. package/esm/typings/src/storage/local-storage/utils/IndexedDbStorageOptions.d.ts +14 -0
  151. package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.d.ts +8 -0
  152. package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.d.ts +2 -1
  153. package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +2 -1
  154. package/esm/typings/src/types/ModelRequirements.d.ts +2 -2
  155. package/esm/typings/src/types/ModelVariant.d.ts +5 -5
  156. package/esm/typings/src/types/typeAliases.d.ts +22 -19
  157. package/esm/typings/src/utils/$Register.d.ts +8 -7
  158. package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +2 -2
  159. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +4 -1
  160. package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +2 -1
  161. package/esm/typings/src/utils/editable/utils/stringifyPipelineJson.d.ts +1 -1
  162. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -1
  163. package/esm/typings/src/utils/expectation-counters/index.d.ts +1 -1
  164. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  165. package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +1 -1
  166. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  167. package/esm/typings/src/utils/normalization/nameToUriPart.d.ts +4 -4
  168. package/esm/typings/src/utils/normalization/nameToUriParts.d.ts +4 -4
  169. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -3
  170. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +3 -3
  171. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +4 -4
  172. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +3 -3
  173. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +3 -3
  174. package/esm/typings/src/utils/normalization/searchKeywords.d.ts +4 -1
  175. package/esm/typings/src/utils/normalization/titleToName.d.ts +4 -4
  176. package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
  177. package/esm/typings/src/utils/organization/empty_object.d.ts +2 -2
  178. package/esm/typings/src/utils/organization/just.d.ts +1 -1
  179. package/esm/typings/src/utils/organization/just_empty_object.d.ts +4 -4
  180. package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
  181. package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +7 -7
  182. package/esm/typings/src/utils/removeQuotes.d.ts +2 -2
  183. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +4 -3
  184. package/esm/typings/src/utils/serialization/deepClone.d.ts +5 -1
  185. package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -1
  186. package/esm/typings/src/utils/trimEndOfCodeBlock.d.ts +1 -1
  187. package/esm/typings/src/utils/unwrapResult.d.ts +2 -2
  188. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +3 -3
  189. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +5 -4
  190. package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +1 -1
  191. package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +1 -1
  192. package/esm/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.d.ts +1 -1
  193. package/esm/typings/src/utils/validators/url/isUrlOnPrivateNetwork.d.ts +1 -1
  194. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +1 -1
  195. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -1
  196. package/esm/typings/src/version.d.ts +2 -1
  197. package/esm/typings/src/wizzard/wizzard.d.ts +1 -1
  198. package/package.json +14 -2
  199. package/umd/index.umd.js +134 -27
  200. package/umd/index.umd.js.map +1 -1
  201. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +0 -31
  202. package/esm/typings/src/formats/csv/CsvFormatDefinition.d.ts +0 -17
  203. package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +0 -19
  204. package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +0 -19
  205. /package/esm/typings/src/llm-providers/{multiple → _multiple}/MultipleLlmExecutionTools.d.ts +0 -0
  206. /package/esm/typings/src/llm-providers/{multiple → _multiple}/joinLlmExecutionTools.d.ts +0 -0
  207. /package/esm/typings/src/llm-providers/{multiple → _multiple}/playground/playground.d.ts +0 -0
@@ -1,26 +1,26 @@
1
1
  import type { string_parameter_name } from '../../types/typeAliases';
2
2
  import type { string_parameter_value } from '../../types/typeAliases';
3
3
  /**
4
- * @@@
4
+ * Options for mapping available parameters to expected parameters in a pipeline task.
5
5
  */
6
6
  type MakeapAvailableToExpectedParametersOptions = {
7
7
  /**
8
- * @@@
8
+ * The set of expected parameter names (keys) for the task, all values are null.
9
9
  */
10
10
  readonly expectedParameters: Readonly<Record<string_parameter_name, null>>;
11
11
  /**
12
- * @@@
12
+ * The set of available parameters (name-value pairs) to map to the expected parameters.
13
13
  */
14
14
  readonly availableParameters: Readonly<Record<string_parameter_name, string_parameter_value>>;
15
15
  };
16
16
  /**
17
- * Maps available parameters to expected parameters
17
+ * Maps available parameters to expected parameters for a pipeline task.
18
18
  *
19
19
  * The strategy is:
20
- * 1) @@@
21
- * 2) @@@
20
+ * 1) First, match parameters by name where both available and expected.
21
+ * 2) Then, if there are unmatched expected and available parameters, map them by order.
22
22
  *
23
- * @throws {PipelineExecutionError} @@@
23
+ * @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
24
24
  * @private within the repository used in `createPipelineExecutor`
25
25
  */
26
26
  export declare function mapAvailableToExpectedParameters(options: MakeapAvailableToExpectedParametersOptions): Readonly<Record<string_parameter_name, string_parameter_value>>;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Removes quotes from a string
3
3
  *
4
- * Tip: This is very usefull for post-processing of the result of the LLM model
4
+ * Tip: This is very useful for post-processing of the result of the LLM model
5
5
  * Note: This function removes only the same quotes from the beginning and the end of the string
6
- * Note: There are two simmilar functions:
6
+ * Note: There are two similar functions:
7
7
  * - `removeQuotes` which removes only bounding quotes
8
8
  * - `unwrapResult` which removes whole introduce sentence
9
9
  *
@@ -1,10 +1,11 @@
1
1
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
2
2
  /**
3
- * @@@
3
+ * Creates a deep clone of a PipelineJson object, copying all properties explicitly.
4
4
  *
5
- * Note: It is usefull @@@
5
+ * Note: It is useful for ensuring that modifications to the returned pipeline do not affect the original.
6
6
  *
7
- * @param pipeline
7
+ * @param pipeline The pipeline to clone.
8
+ * @returns A new PipelineJson object with the same properties as the input.
8
9
  * @public exported from `@promptbook/utils`
9
10
  */
10
11
  export declare function clonePipeline(pipeline: PipelineJson): PipelineJson;
@@ -1,7 +1,11 @@
1
1
  import type { WritableDeep } from 'type-fest';
2
2
  /**
3
- * @@@
3
+ * Creates a deep clone of the given object
4
4
  *
5
+ * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
6
+ *
7
+ * @param objectValue The object to clone.
8
+ * @returns A deep, writable clone of the input object.
5
9
  * @public exported from `@promptbook/utils`
6
10
  */
7
11
  export declare function deepClone<TObject>(objectValue: TObject): WritableDeep<TObject>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Function trimCodeBlock will trim starting and ending code block from the string if it is present.
3
3
  *
4
- * Note: This is usefull for post-processing of the result of the chat LLM model
4
+ * Note: This is useful for post-processing of the result of the chat LLM model
5
5
  * when the model wraps the result in the (markdown) code block.
6
6
  *
7
7
  * @public exported from `@promptbook/utils`
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Function trimEndOfCodeBlock will remove ending code block from the string if it is present.
3
3
  *
4
- * Note: This is usefull for post-processing of the result of the completion LLM model
4
+ * Note: This is useful for post-processing of the result of the completion LLM model
5
5
  * if you want to start code block in the prompt but you don't want to end it in the result.
6
6
  *
7
7
  * @public exported from `@promptbook/utils`
@@ -20,9 +20,9 @@ type UnwrapResultOptions = {
20
20
  /**
21
21
  * Removes quotes and optional introduce text from a string
22
22
  *
23
- * Tip: This is very usefull for post-processing of the result of the LLM model
23
+ * Tip: This is very useful for post-processing of the result of the LLM model
24
24
  * Note: This function trims the text and removes whole introduce sentence if it is present
25
- * Note: There are two simmilar functions:
25
+ * Note: There are two similar functions:
26
26
  * - `removeQuotes` which removes only bounding quotes
27
27
  * - `unwrapResult` which removes whole introduce sentence
28
28
  *
@@ -1,10 +1,10 @@
1
1
  import type { string_javascript_name } from '../../../types/typeAliases';
2
2
  import type { really_unknown } from '../../organization/really_unknown';
3
3
  /**
4
- * @@@
4
+ * Checks if the given value is a valid JavaScript identifier name.
5
5
  *
6
- * @param javascriptName @@@
7
- * @returns @@@
6
+ * @param javascriptName The value to check for JavaScript identifier validity.
7
+ * @returns `true` if the value is a valid JavaScript name, false otherwise.
8
8
  * @public exported from `@promptbook/utils`
9
9
  */
10
10
  export declare function isValidJavascriptName(javascriptName: really_unknown): javascriptName is string_javascript_name;
@@ -1,10 +1,11 @@
1
1
  import type { string_parameter_name } from '../../../types/typeAliases';
2
2
  /**
3
- * Function `validateParameterName` will @@@
3
+ * Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
4
+ * It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
4
5
  *
5
- * @param parameterName @@@
6
- * @returns @@@
7
- * @throws {ParseError} @@@
6
+ * @param parameterName The parameter name to validate and normalize.
7
+ * @returns The validated and normalized parameter name.
8
+ * @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
8
9
  * @private within the repository
9
10
  */
10
11
  export declare function validateParameterName(parameterName: string): string_parameter_name;
@@ -6,7 +6,7 @@ import type { really_unknown } from '../../organization/really_unknown';
6
6
  *
7
7
  * @see https://www.npmjs.com/package/promptbook?activeTab=versions
8
8
  * Note: When you are using for example promptbook 2.0.0 and there already is promptbook 3.0.0 it don`t know about it.
9
- * Note: There are two simmilar functions:
9
+ * Note: There are two similar functions:
10
10
  * - `isValidSemanticVersion` which tests any semantic version
11
11
  * - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
12
12
  *
@@ -3,7 +3,7 @@ import type { really_unknown } from '../../organization/really_unknown';
3
3
  /**
4
4
  * Tests if given string is valid semantic version
5
5
  *
6
- * Note: There are two simmilar functions:
6
+ * Note: There are two similar functions:
7
7
  * - `isValidSemanticVersion` which tests any semantic version
8
8
  * - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
9
9
  *
@@ -2,7 +2,7 @@ import type { string_hostname } from '../../../types/typeAliases';
2
2
  /**
3
3
  * Checks if an URL is reserved for private networks or localhost.
4
4
  *
5
- * Note: There are two simmilar functions:
5
+ * Note: There are two similar functions:
6
6
  * - `isUrlOnPrivateNetwork` which tests full URL
7
7
  * - `isHostnameOnPrivateNetwork` *(this one)* which tests just hostname
8
8
  *
@@ -2,7 +2,7 @@ import type { string_url } from '../../../types/typeAliases';
2
2
  /**
3
3
  * Checks if an IP address or hostname is reserved for private networks or localhost.
4
4
  *
5
- * Note: There are two simmilar functions:
5
+ * Note: There are two similar functions:
6
6
  * - `isUrlOnPrivateNetwork` *(this one)* which tests full URL
7
7
  * - `isHostnameOnPrivateNetwork` which tests just hostname
8
8
  *
@@ -3,7 +3,7 @@ import type { really_unknown } from '../../organization/really_unknown';
3
3
  /**
4
4
  * Tests if given string is valid pipeline URL URL.
5
5
  *
6
- * Note: There are two simmilar functions:
6
+ * Note: There are two similar functions:
7
7
  * - `isValidUrl` which tests any URL
8
8
  * - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
9
9
  *
@@ -4,7 +4,7 @@ import type { really_unknown } from '../../organization/really_unknown';
4
4
  * Tests if given string is valid URL.
5
5
  *
6
6
  * Note: Dataurl are considered perfectly valid.
7
- * Note: There are two simmilar functions:
7
+ * Note: There are two similar functions:
8
8
  * - `isValidUrl` which tests any URL
9
9
  * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
10
10
  *
@@ -14,7 +14,8 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
14
14
  */
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
- * @@@
17
+ * Represents the version string of the Promptbook engine.
18
+ * It follows semantic versioning (e.g., `0.92.0-35`).
18
19
  *
19
20
  * @generated
20
21
  */
@@ -24,7 +24,7 @@ declare class Wizzard {
24
24
  * 2) As a URL https://promptbook.studio/hejny/write-cv.book fetched from the internet
25
25
  * 3) As a string
26
26
  *
27
- * Note: This works simmilar to the `ptbk run` command
27
+ * Note: This works similar to the `ptbk run` command
28
28
  */
29
29
  execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters): Promise<{
30
30
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/browser",
3
- "version": "0.92.0-8",
3
+ "version": "0.92.0",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -47,11 +47,23 @@
47
47
  "node": ">=16.0.0",
48
48
  "npm": ">=8.0.0"
49
49
  },
50
+ "cspell": {
51
+ "version": "0.2",
52
+ "language": "en",
53
+ "ignorePaths": [
54
+ "node_modules",
55
+ ".next",
56
+ "coverage",
57
+ "dist",
58
+ ".git"
59
+ ],
60
+ "words": []
61
+ },
50
62
  "main": "./umd/index.umd.js",
51
63
  "module": "./esm/index.es.js",
52
64
  "typings": "./esm/typings/src/_packages/browser.index.d.ts",
53
65
  "peerDependencies": {
54
- "@promptbook/core": "0.92.0-8"
66
+ "@promptbook/core": "0.92.0"
55
67
  },
56
68
  "dependencies": {
57
69
  "crypto": "1.0.1",
package/umd/index.umd.js CHANGED
@@ -22,7 +22,7 @@
22
22
  * @generated
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-8';
25
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -54,7 +54,7 @@
54
54
  super(message);
55
55
  this.name = 'PipelineExecutionError';
56
56
  // TODO: [🐙] DRY - Maybe $randomId
57
- this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
57
+ this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
58
58
  Object.setPrototypeOf(this, PipelineExecutionError.prototype);
59
59
  }
60
60
  }
@@ -181,7 +181,7 @@
181
181
  const LOOP_LIMIT = 1000;
182
182
  // <- TODO: [🧜‍♂️]
183
183
  /**
184
- * @@@
184
+ * Default settings for parsing and generating CSV files in Promptbook.
185
185
  *
186
186
  * @public exported from `@promptbook/core`
187
187
  */
@@ -274,7 +274,7 @@
274
274
  ${block(message)}
275
275
 
276
276
  Note: This error should not happen.
277
- It's probbably a bug in the pipeline collection
277
+ It's probably a bug in the pipeline collection
278
278
 
279
279
  Please report issue:
280
280
  ${block(getErrorReportUrl(new Error(message)).href)}
@@ -288,7 +288,8 @@
288
288
  }
289
289
 
290
290
  /**
291
- * @@@
291
+ * Safely retrieves the global scope object (window in browser, global in Node.js)
292
+ * regardless of the JavaScript environment in which the code is running
292
293
  *
293
294
  * Note: `$` is used to indicate that this function is not a pure function - it access global scope
294
295
  *
@@ -299,10 +300,10 @@
299
300
  }
300
301
 
301
302
  /**
302
- * @@@
303
+ * Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
303
304
  *
304
- * @param text @@@
305
- * @returns @@@
305
+ * @param text The text string to be converted to SCREAMING_CASE format.
306
+ * @returns The normalized text in SCREAMING_CASE format.
306
307
  * @example 'HELLO_WORLD'
307
308
  * @example 'I_LOVE_PROMPTBOOK'
308
309
  * @public exported from `@promptbook/utils`
@@ -354,10 +355,10 @@
354
355
  */
355
356
 
356
357
  /**
357
- * @@@
358
+ * Normalizes a text string to snake_case format.
358
359
  *
359
- * @param text @@@
360
- * @returns @@@
360
+ * @param text The text string to be converted to snake_case format.
361
+ * @returns The normalized text in snake_case format.
361
362
  * @example 'hello_world'
362
363
  * @example 'i_love_promptbook'
363
364
  * @public exported from `@promptbook/utils`
@@ -367,11 +368,11 @@
367
368
  }
368
369
 
369
370
  /**
370
- * Register is @@@
371
+ * Global registry for storing and managing registered entities of a given type.
371
372
  *
372
373
  * Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
373
374
  *
374
- * @private internal utility, exported are only signleton instances of this class
375
+ * @private internal utility, exported are only singleton instances of this class
375
376
  */
376
377
  class $Register {
377
378
  constructor(registerName) {
@@ -415,10 +416,11 @@
415
416
  }
416
417
 
417
418
  /**
418
- * @@@
419
+ * Registry for all available scrapers in the system.
420
+ * Central point for registering and accessing different types of content scrapers.
419
421
  *
420
422
  * Note: `$` is used to indicate that this interacts with the global scope
421
- * @singleton Only one instance of each register is created per build, but thare can be more @@@
423
+ * @singleton Only one instance of each register is created per build, but there can be more than one in different build modules
422
424
  * @public exported from `@promptbook/core`
423
425
  */
424
426
  const $scrapersRegister = new $Register('scraper_constructors');
@@ -427,10 +429,13 @@
427
429
  */
428
430
 
429
431
  /**
430
- * @@@
432
+ * Provides a collection of scrapers optimized for browser environments.
433
+ * Only includes scrapers that can safely run in a browser context.
431
434
  *
432
- * 1) @@@
433
- * 2) @@@
435
+ * Note: Browser scrapers have limitations compared to Node.js scrapers.
436
+ *
437
+ * 1) `provideScrapersForNode` use as default
438
+ * 2) `provideScrapersForBrowser` use in limited browser environment
434
439
  *
435
440
  * @public exported from `@promptbook/browser`
436
441
  */
@@ -450,6 +455,85 @@
450
455
  return scrapers;
451
456
  }
452
457
 
458
+ /**
459
+ * Creates a PromptbookStorage backed by IndexedDB.
460
+ * Uses a single object store named 'promptbook'.
461
+ * @private for `getIndexedDbStorage`
462
+ */
463
+ function makePromptbookStorageFromIndexedDb(options) {
464
+ const { databaseName, storeName } = options;
465
+ function getDatabase() {
466
+ return new Promise((resolve, reject) => {
467
+ const request = indexedDB.open(databaseName, 1);
468
+ request.onupgradeneeded = () => {
469
+ request.result.createObjectStore(storeName);
470
+ };
471
+ request.onsuccess = () => resolve(request.result);
472
+ request.onerror = () => reject(request.error);
473
+ });
474
+ }
475
+ return {
476
+ async getItem(key) {
477
+ const database = await getDatabase();
478
+ return new Promise((resolve, reject) => {
479
+ const transaction = database.transaction(storeName, 'readonly');
480
+ const objectStore = transaction.objectStore(storeName);
481
+ const request = objectStore.get(key);
482
+ request.onsuccess = () => { var _a; return resolve((_a = request.result) !== null && _a !== void 0 ? _a : null); };
483
+ request.onerror = () => reject(request.error);
484
+ });
485
+ },
486
+ async setItem(key, value) {
487
+ const database = await getDatabase();
488
+ return new Promise((resolve, reject) => {
489
+ const transaction = database.transaction(storeName, 'readwrite');
490
+ const objectStore = transaction.objectStore(storeName);
491
+ const request = objectStore.put(value, key);
492
+ request.onsuccess = () => resolve();
493
+ request.onerror = () => reject(request.error);
494
+ });
495
+ },
496
+ async removeItem(key) {
497
+ const database = await getDatabase();
498
+ return new Promise((resolve, reject) => {
499
+ const transaction = database.transaction(storeName, 'readwrite');
500
+ const objectStore = transaction.objectStore(storeName);
501
+ const request = objectStore.delete(key);
502
+ request.onsuccess = () => resolve();
503
+ request.onerror = () => reject(request.error);
504
+ });
505
+ },
506
+ };
507
+ }
508
+
509
+ /**
510
+ * Cache storage
511
+ *
512
+ * @private internal cache for `getIndexedDbStorage`
513
+ */
514
+ const indexedDbStorageCache = new Map();
515
+ /**
516
+ * Gets wrapper around IndexedDB which can be used as PromptbookStorage
517
+ *
518
+ * @public exported from `@promptbook/browser`
519
+ */
520
+ function getIndexedDbStorage(options) {
521
+ if (!core.isRunningInBrowser()) {
522
+ throw new EnvironmentMismatchError(`You can get IndexedDB storage only in browser environment`);
523
+ }
524
+ const { databaseName, storeName } = options;
525
+ const cacheKey = `${databaseName}/${storeName}`;
526
+ if (indexedDbStorageCache.has(cacheKey)) {
527
+ return indexedDbStorageCache.get(cacheKey);
528
+ }
529
+ const storage = makePromptbookStorageFromIndexedDb({ databaseName, storeName });
530
+ indexedDbStorageCache.set(cacheKey, storage);
531
+ return storage;
532
+ }
533
+ /**
534
+ * Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
535
+ */
536
+
453
537
  /**
454
538
  * Converts a JavaScript Object Notation (JSON) string into an object.
455
539
  *
@@ -479,15 +563,12 @@
479
563
  }
480
564
  throw new Error(spaceTrim__default["default"]((block) => `
481
565
  ${block(error.message)}
482
-
566
+
483
567
  The JSON text:
484
568
  ${block(value)}
485
569
  `));
486
570
  }
487
571
  }
488
- /**
489
- * TODO: !!!! Use in Promptbook.studio
490
- */
491
572
 
492
573
  /**
493
574
  * Orders JSON object by keys
@@ -718,8 +799,12 @@
718
799
  */
719
800
 
720
801
  /**
721
- * @@@
802
+ * Creates a deep clone of the given object
722
803
  *
804
+ * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
805
+ *
806
+ * @param objectValue The object to clone.
807
+ * @returns A deep, writable clone of the input object.
723
808
  * @public exported from `@promptbook/utils`
724
809
  */
725
810
  function deepClone(objectValue) {
@@ -865,14 +950,15 @@
865
950
  return pipelineJsonStringified;
866
951
  }
867
952
  /**
868
- * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book
953
+ * TODO: [🐝] Not Working properly @see https://promptbook.studio/examples/mixed-knowledge.book
869
954
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
870
955
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
871
956
  * TODO: [🍙] Make some standard order of json properties
872
957
  */
873
958
 
874
959
  /**
875
- * @@@
960
+ * Creates a Promptbook storage interface from a web storage object.
961
+ * Facilitates using Web Storage (localStorage/sessionStorage) as a storage backend.
876
962
  *
877
963
  * @private for `getLocalStorage` and `getSessionStorage`
878
964
  */
@@ -904,6 +990,12 @@
904
990
  * TODO: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values
905
991
  */
906
992
 
993
+ /**
994
+ * Cache storage
995
+ *
996
+ * @private internal cache for `getLocalStorage`
997
+ */
998
+ let promptbookLocalStorage = null;
907
999
  /**
908
1000
  * Gets wrapper around `localStorage` object which can be used as `PromptbookStorage`
909
1001
  *
@@ -913,12 +1005,22 @@
913
1005
  if (!core.isRunningInBrowser()) {
914
1006
  throw new EnvironmentMismatchError(`You can get localStorage works only in browser environment`);
915
1007
  }
916
- return makePromptbookStorageFromWebStorage(localStorage);
1008
+ if (promptbookLocalStorage) {
1009
+ return promptbookLocalStorage;
1010
+ }
1011
+ promptbookLocalStorage = makePromptbookStorageFromWebStorage(localStorage);
1012
+ return promptbookLocalStorage;
917
1013
  }
918
1014
  /**
919
1015
  * Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
920
1016
  */
921
1017
 
1018
+ /**
1019
+ * Cache storage
1020
+ *
1021
+ * @private internal cache for `getSessionStorage`
1022
+ */
1023
+ let promptbookSessionStorage = null;
922
1024
  /**
923
1025
  * Gets wrapper around `sessionStorage` object which can be used as `PromptbookStorage`
924
1026
  *
@@ -928,7 +1030,11 @@
928
1030
  if (!core.isRunningInBrowser()) {
929
1031
  throw new EnvironmentMismatchError(`You can get sessionStorage works only in browser environment`);
930
1032
  }
931
- return makePromptbookStorageFromWebStorage(sessionStorage);
1033
+ if (promptbookSessionStorage) {
1034
+ return promptbookSessionStorage;
1035
+ }
1036
+ promptbookSessionStorage = makePromptbookStorageFromWebStorage(sessionStorage);
1037
+ return promptbookSessionStorage;
932
1038
  }
933
1039
  /**
934
1040
  * Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
@@ -938,6 +1044,7 @@
938
1044
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
939
1045
  exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
940
1046
  exports.SimplePromptInterfaceTools = SimplePromptInterfaceTools;
1047
+ exports.getIndexedDbStorage = getIndexedDbStorage;
941
1048
  exports.getLocalStorage = getLocalStorage;
942
1049
  exports.getSessionStorage = getSessionStorage;
943
1050