@promptbook/remote-client 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 +225 -137
  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 +225 -137
  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
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-8';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -73,7 +73,7 @@
73
73
  }
74
74
 
75
75
  /**
76
- * This error indicates that the pipeline collection cannot be propperly loaded
76
+ * This error indicates that the pipeline collection cannot be properly loaded
77
77
  *
78
78
  * @public exported from `@promptbook/core`
79
79
  */
@@ -150,7 +150,7 @@
150
150
  super(spaceTrim.spaceTrim((block) => `
151
151
  ${block(message)}
152
152
 
153
- Note: You have probbably forgot to provide some tools for pipeline execution or preparation
153
+ Note: You have probably forgot to provide some tools for pipeline execution or preparation
154
154
 
155
155
  `));
156
156
  this.name = 'MissingToolsError';
@@ -236,7 +236,7 @@
236
236
  super(message);
237
237
  this.name = 'PipelineExecutionError';
238
238
  // TODO: [🐙] DRY - Maybe $randomId
239
- this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
239
+ this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
240
240
  Object.setPrototypeOf(this, PipelineExecutionError.prototype);
241
241
  }
242
242
  }
@@ -287,7 +287,7 @@
287
287
  * Returns the same value that is passed as argument.
288
288
  * No side effects.
289
289
  *
290
- * Note: It can be usefull for:
290
+ * Note: It can be useful for:
291
291
  *
292
292
  * 1) Leveling indentation
293
293
  * 2) Putting always-true or always-false conditions without getting eslint errors
@@ -364,7 +364,7 @@
364
364
  const CONNECTION_RETRIES_LIMIT = 5;
365
365
  // <- TODO: [🧜‍♂️]
366
366
  /**
367
- * @@@
367
+ * Default settings for parsing and generating CSV files in Promptbook.
368
368
  *
369
369
  * @public exported from `@promptbook/core`
370
370
  */
@@ -434,7 +434,7 @@
434
434
  ${block(message)}
435
435
 
436
436
  Note: This error should not happen.
437
- It's probbably a bug in the pipeline collection
437
+ It's probably a bug in the pipeline collection
438
438
 
439
439
  Please report issue:
440
440
  ${block(getErrorReportUrl(new Error(message)).href)}
@@ -559,7 +559,7 @@
559
559
  * Tests if given string is valid URL.
560
560
  *
561
561
  * Note: Dataurl are considered perfectly valid.
562
- * Note: There are two simmilar functions:
562
+ * Note: There are two similar functions:
563
563
  * - `isValidUrl` which tests any URL
564
564
  * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
565
565
  *
@@ -996,10 +996,10 @@
996
996
  */
997
997
 
998
998
  /**
999
- * @@@
999
+ * Removes diacritic marks (accents) from characters in a string.
1000
1000
  *
1001
- * @param input @@@
1002
- * @returns @@@
1001
+ * @param input The string containing diacritics to be normalized.
1002
+ * @returns The string with diacritics removed or normalized.
1003
1003
  * @public exported from `@promptbook/utils`
1004
1004
  */
1005
1005
  function removeDiacritics(input) {
@@ -1013,10 +1013,10 @@
1013
1013
  */
1014
1014
 
1015
1015
  /**
1016
- * @@@
1016
+ * Converts a given text to kebab-case format.
1017
1017
  *
1018
- * @param text @@@
1019
- * @returns @@@
1018
+ * @param text The text to be converted.
1019
+ * @returns The kebab-case formatted string.
1020
1020
  * @example 'hello-world'
1021
1021
  * @example 'i-love-promptbook'
1022
1022
  * @public exported from `@promptbook/utils`
@@ -1302,7 +1302,7 @@
1302
1302
  throw new ParseError(`Task section and example section must end with return statement -> {parameterName}`);
1303
1303
  };
1304
1304
  if ($taskJson.content === undefined) {
1305
- throw new UnexpectedError(`Content is missing in the taskJson - probbably commands are applied in wrong order`);
1305
+ throw new UnexpectedError(`Content is missing in the taskJson - probably commands are applied in wrong order`);
1306
1306
  }
1307
1307
  if (command.taskType === 'EXAMPLE') {
1308
1308
  expectResultingParameterName();
@@ -1370,7 +1370,7 @@
1370
1370
  /**
1371
1371
  * Parses the boilerplate command
1372
1372
  *
1373
- * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book` file
1373
+ * Note: @@ This command is used as boilerplate for new commands - it should NOT be used in any `.book` file
1374
1374
  *
1375
1375
  * @see `documentationUrl` for more details
1376
1376
  * @private within the commands folder
@@ -1463,7 +1463,7 @@
1463
1463
  /**
1464
1464
  * Tests if given string is valid semantic version
1465
1465
  *
1466
- * Note: There are two simmilar functions:
1466
+ * Note: There are two similar functions:
1467
1467
  * - `isValidSemanticVersion` which tests any semantic version
1468
1468
  * - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
1469
1469
  *
@@ -1485,7 +1485,7 @@
1485
1485
  *
1486
1486
  * @see https://www.npmjs.com/package/promptbook?activeTab=versions
1487
1487
  * 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.
1488
- * Note: There are two simmilar functions:
1488
+ * Note: There are two similar functions:
1489
1489
  * - `isValidSemanticVersion` which tests any semantic version
1490
1490
  * - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
1491
1491
  *
@@ -1828,7 +1828,7 @@
1828
1828
  };
1829
1829
 
1830
1830
  /**
1831
- * @@@
1831
+ * Contains configuration options for parsing and generating CSV files, such as delimiters and quoting rules.
1832
1832
  *
1833
1833
  * @public exported from `@promptbook/core`
1834
1834
  */
@@ -1837,11 +1837,29 @@
1837
1837
  // encoding: 'utf-8',
1838
1838
  });
1839
1839
 
1840
+ /**
1841
+ * Converts a CSV string into an object
1842
+ *
1843
+ * Note: This is wrapper around `papaparse.parse()` with better autohealing
1844
+ *
1845
+ * @private - for now until `@promptbook/csv` is released
1846
+ */
1847
+ function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO: Make CSV Schemas */) {
1848
+ settings = { ...settings, ...MANDATORY_CSV_SETTINGS };
1849
+ // Note: Autoheal invalid '\n' characters
1850
+ if (settings.newline && !settings.newline.includes('\r') && value.includes('\r')) {
1851
+ console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
1852
+ value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
1853
+ }
1854
+ const csv = papaparse.parse(value, settings);
1855
+ return csv;
1856
+ }
1857
+
1840
1858
  /**
1841
1859
  * Function to check if a string is valid CSV
1842
1860
  *
1843
1861
  * @param value The string to check
1844
- * @returns True if the string is a valid CSV string, false otherwise
1862
+ * @returns `true` if the string is a valid CSV string, false otherwise
1845
1863
  *
1846
1864
  * @public exported from `@promptbook/utils`
1847
1865
  */
@@ -1865,7 +1883,7 @@
1865
1883
  * @public exported from `@promptbook/core`
1866
1884
  * <- TODO: [🏢] Export from package `@promptbook/csv`
1867
1885
  */
1868
- const CsvFormatDefinition = {
1886
+ const CsvFormatParser = {
1869
1887
  formatName: 'CSV',
1870
1888
  aliases: ['SPREADSHEET', 'TABLE'],
1871
1889
  isValid(value, settings, schema) {
@@ -1877,12 +1895,12 @@
1877
1895
  heal(value, settings, schema) {
1878
1896
  throw new Error('Not implemented');
1879
1897
  },
1880
- subvalueDefinitions: [
1898
+ subvalueParsers: [
1881
1899
  {
1882
1900
  subvalueName: 'ROW',
1883
- async mapValues(value, outputParameterName, settings, mapCallback) {
1884
- // TODO: [👨🏾‍🤝‍👨🏼] DRY csv parsing
1885
- const csv = papaparse.parse(value, { ...settings, ...MANDATORY_CSV_SETTINGS });
1901
+ async mapValues(options) {
1902
+ const { value, outputParameterName, settings, mapCallback, onProgress } = options;
1903
+ const csv = csvParse(value, settings);
1886
1904
  if (csv.errors.length !== 0) {
1887
1905
  throw new CsvFormatError(spaceTrim__default["default"]((block) => `
1888
1906
  CSV parsing error
@@ -1897,23 +1915,37 @@
1897
1915
  ${block(value)}
1898
1916
  `));
1899
1917
  }
1900
- const mappedData = await Promise.all(csv.data.map(async (row, index) => {
1918
+ const mappedData = [];
1919
+ const length = csv.data.length;
1920
+ for (let index = 0; index < length; index++) {
1921
+ const row = csv.data[index];
1901
1922
  if (row[outputParameterName]) {
1902
1923
  throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
1903
1924
  }
1904
- return {
1925
+ const mappedRow = {
1905
1926
  ...row,
1906
- [outputParameterName]: await mapCallback(row, index),
1927
+ [outputParameterName]: await mapCallback(row, index, length),
1907
1928
  };
1908
- }));
1929
+ mappedData.push(mappedRow);
1930
+ if (onProgress) {
1931
+ // Note: Report the CSV with all rows mapped so far
1932
+ /*
1933
+ // TODO: [🛕] Report progress with all the rows including the pending ones
1934
+ const progressData = mappedData.map((row, i) =>
1935
+ i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
1936
+ );
1937
+ */
1938
+ await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
1939
+ }
1940
+ }
1909
1941
  return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
1910
1942
  },
1911
1943
  },
1912
1944
  {
1913
1945
  subvalueName: 'CELL',
1914
- async mapValues(value, outputParameterName, settings, mapCallback) {
1915
- // TODO: [👨🏾‍🤝‍👨🏼] DRY csv parsing
1916
- const csv = papaparse.parse(value, { ...settings, ...MANDATORY_CSV_SETTINGS });
1946
+ async mapValues(options) {
1947
+ const { value, settings, mapCallback, onProgress } = options;
1948
+ const csv = csvParse(value, settings);
1917
1949
  if (csv.errors.length !== 0) {
1918
1950
  throw new CsvFormatError(spaceTrim__default["default"]((block) => `
1919
1951
  CSV parsing error
@@ -1929,9 +1961,9 @@
1929
1961
  `));
1930
1962
  }
1931
1963
  const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
1932
- return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
1964
+ return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
1933
1965
  const index = rowIndex * Object.keys(row).length + columnIndex;
1934
- return /* not await */ mapCallback({ [key]: value }, index);
1966
+ return /* not await */ mapCallback({ [key]: value }, index, array.length);
1935
1967
  }));
1936
1968
  }));
1937
1969
  return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
@@ -1940,10 +1972,10 @@
1940
1972
  ],
1941
1973
  };
1942
1974
  /**
1943
- * TODO: [🍓] In `CsvFormatDefinition` implement simple `isValid`
1944
- * TODO: [🍓] In `CsvFormatDefinition` implement partial `canBeValid`
1945
- * TODO: [🍓] In `CsvFormatDefinition` implement `heal
1946
- * TODO: [🍓] In `CsvFormatDefinition` implement `subvalueDefinitions`
1975
+ * TODO: [🍓] In `CsvFormatParser` implement simple `isValid`
1976
+ * TODO: [🍓] In `CsvFormatParser` implement partial `canBeValid`
1977
+ * TODO: [🍓] In `CsvFormatParser` implement `heal
1978
+ * TODO: [🍓] In `CsvFormatParser` implement `subvalueParsers`
1947
1979
  * TODO: [🏢] Allow to expect something inside CSV objects and other formats
1948
1980
  */
1949
1981
 
@@ -1951,7 +1983,7 @@
1951
1983
  * Function isValidJsonString will tell you if the string is valid JSON or not
1952
1984
  *
1953
1985
  * @param value The string to check
1954
- * @returns True if the string is a valid JSON string, false otherwise
1986
+ * @returns `true` if the string is a valid JSON string, false otherwise
1955
1987
  *
1956
1988
  * @public exported from `@promptbook/utils`
1957
1989
  */
@@ -1974,7 +2006,7 @@
1974
2006
  *
1975
2007
  * @private still in development [🏢]
1976
2008
  */
1977
- const JsonFormatDefinition = {
2009
+ const JsonFormatParser = {
1978
2010
  formatName: 'JSON',
1979
2011
  mimeType: 'application/json',
1980
2012
  isValid(value, settings, schema) {
@@ -1986,28 +2018,28 @@
1986
2018
  heal(value, settings, schema) {
1987
2019
  throw new Error('Not implemented');
1988
2020
  },
1989
- subvalueDefinitions: [],
2021
+ subvalueParsers: [],
1990
2022
  };
1991
2023
  /**
1992
- * TODO: [🧠] Maybe propper instance of object
2024
+ * TODO: [🧠] Maybe proper instance of object
1993
2025
  * TODO: [0] Make string_serialized_json
1994
2026
  * TODO: [1] Make type for JSON Settings and Schema
1995
2027
  * TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
1996
- * TODO: [🍓] In `JsonFormatDefinition` implement simple `isValid`
1997
- * TODO: [🍓] In `JsonFormatDefinition` implement partial `canBeValid`
1998
- * TODO: [🍓] In `JsonFormatDefinition` implement `heal
1999
- * TODO: [🍓] In `JsonFormatDefinition` implement `subvalueDefinitions`
2028
+ * TODO: [🍓] In `JsonFormatParser` implement simple `isValid`
2029
+ * TODO: [🍓] In `JsonFormatParser` implement partial `canBeValid`
2030
+ * TODO: [🍓] In `JsonFormatParser` implement `heal
2031
+ * TODO: [🍓] In `JsonFormatParser` implement `subvalueParsers`
2000
2032
  * TODO: [🏢] Allow to expect something inside JSON objects and other formats
2001
2033
  */
2002
2034
 
2003
2035
  /**
2004
2036
  * Definition for any text - this will be always valid
2005
2037
  *
2006
- * Note: This is not useful for validation, but for splitting and mapping with `subvalueDefinitions`
2038
+ * Note: This is not useful for validation, but for splitting and mapping with `subvalueParsers`
2007
2039
  *
2008
2040
  * @public exported from `@promptbook/core`
2009
2041
  */
2010
- const TextFormatDefinition = {
2042
+ const TextFormatParser = {
2011
2043
  formatName: 'TEXT',
2012
2044
  isValid(value) {
2013
2045
  return typeof value === 'string';
@@ -2016,19 +2048,20 @@
2016
2048
  return typeof partialValue === 'string';
2017
2049
  },
2018
2050
  heal() {
2019
- throw new UnexpectedError('It does not make sense to call `TextFormatDefinition.heal`');
2051
+ throw new UnexpectedError('It does not make sense to call `TextFormatParser.heal`');
2020
2052
  },
2021
- subvalueDefinitions: [
2053
+ subvalueParsers: [
2022
2054
  {
2023
2055
  subvalueName: 'LINE',
2024
- async mapValues(value, outputParameterName, settings, mapCallback) {
2056
+ async mapValues(options) {
2057
+ const { value, mapCallback, onProgress } = options;
2025
2058
  const lines = value.split('\n');
2026
- const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
2059
+ const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
2027
2060
  // TODO: [🧠] Maybe option to skip empty line
2028
2061
  /* not await */ mapCallback({
2029
2062
  lineContent,
2030
2063
  // TODO: [🧠] Maybe also put here `lineNumber`
2031
- }, lineNumber)));
2064
+ }, lineNumber, array.length)));
2032
2065
  return mappedLines.join('\n');
2033
2066
  },
2034
2067
  },
@@ -2038,10 +2071,10 @@
2038
2071
  /**
2039
2072
  * TODO: [1] Make type for XML Text and Schema
2040
2073
  * TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
2041
- * TODO: [🍓] In `TextFormatDefinition` implement simple `isValid`
2042
- * TODO: [🍓] In `TextFormatDefinition` implement partial `canBeValid`
2043
- * TODO: [🍓] In `TextFormatDefinition` implement `heal
2044
- * TODO: [🍓] In `TextFormatDefinition` implement `subvalueDefinitions`
2074
+ * TODO: [🍓] In `TextFormatParser` implement simple `isValid`
2075
+ * TODO: [🍓] In `TextFormatParser` implement partial `canBeValid`
2076
+ * TODO: [🍓] In `TextFormatParser` implement `heal
2077
+ * TODO: [🍓] In `TextFormatParser` implement `subvalueParsers`
2045
2078
  * TODO: [🏢] Allow to expect something inside each item of list and other formats
2046
2079
  */
2047
2080
 
@@ -2049,7 +2082,7 @@
2049
2082
  * Function to check if a string is valid XML
2050
2083
  *
2051
2084
  * @param value
2052
- * @returns True if the string is a valid XML string, false otherwise
2085
+ * @returns `true` if the string is a valid XML string, false otherwise
2053
2086
  *
2054
2087
  * @public exported from `@promptbook/utils`
2055
2088
  */
@@ -2074,7 +2107,7 @@
2074
2107
  *
2075
2108
  * @private still in development [🏢]
2076
2109
  */
2077
- const XmlFormatDefinition = {
2110
+ const XmlFormatParser = {
2078
2111
  formatName: 'XML',
2079
2112
  mimeType: 'application/xml',
2080
2113
  isValid(value, settings, schema) {
@@ -2086,17 +2119,17 @@
2086
2119
  heal(value, settings, schema) {
2087
2120
  throw new Error('Not implemented');
2088
2121
  },
2089
- subvalueDefinitions: [],
2122
+ subvalueParsers: [],
2090
2123
  };
2091
2124
  /**
2092
- * TODO: [🧠] Maybe propper instance of object
2125
+ * TODO: [🧠] Maybe proper instance of object
2093
2126
  * TODO: [0] Make string_serialized_xml
2094
2127
  * TODO: [1] Make type for XML Settings and Schema
2095
2128
  * TODO: [🧠] What to use for validating XMLs - XSD,...
2096
- * TODO: [🍓] In `XmlFormatDefinition` implement simple `isValid`
2097
- * TODO: [🍓] In `XmlFormatDefinition` implement partial `canBeValid`
2098
- * TODO: [🍓] In `XmlFormatDefinition` implement `heal
2099
- * TODO: [🍓] In `XmlFormatDefinition` implement `subvalueDefinitions`
2129
+ * TODO: [🍓] In `XmlFormatParser` implement simple `isValid`
2130
+ * TODO: [🍓] In `XmlFormatParser` implement partial `canBeValid`
2131
+ * TODO: [🍓] In `XmlFormatParser` implement `heal
2132
+ * TODO: [🍓] In `XmlFormatParser` implement `subvalueParsers`
2100
2133
  * TODO: [🏢] Allow to expect something inside XML and other formats
2101
2134
  */
2102
2135
 
@@ -2105,21 +2138,16 @@
2105
2138
  *
2106
2139
  * @private internal index of `...` <- TODO [🏢]
2107
2140
  */
2108
- const FORMAT_DEFINITIONS = [
2109
- JsonFormatDefinition,
2110
- XmlFormatDefinition,
2111
- TextFormatDefinition,
2112
- CsvFormatDefinition,
2113
- ];
2141
+ const FORMAT_DEFINITIONS = [JsonFormatParser, XmlFormatParser, TextFormatParser, CsvFormatParser];
2114
2142
  /**
2115
2143
  * Note: [💞] Ignore a discrepancy between file name and entity name
2116
2144
  */
2117
2145
 
2118
2146
  /**
2119
- * @@@
2147
+ * Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
2120
2148
  *
2121
- * @param text @@@
2122
- * @returns @@@
2149
+ * @param text The text string to be converted to SCREAMING_CASE format.
2150
+ * @returns The normalized text in SCREAMING_CASE format.
2123
2151
  * @example 'HELLO_WORLD'
2124
2152
  * @example 'I_LOVE_PROMPTBOOK'
2125
2153
  * @public exported from `@promptbook/utils`
@@ -2351,8 +2379,12 @@
2351
2379
  */
2352
2380
 
2353
2381
  /**
2354
- * @@@
2382
+ * Creates a deep clone of the given object
2355
2383
  *
2384
+ * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
2385
+ *
2386
+ * @param objectValue The object to clone.
2387
+ * @returns A deep, writable clone of the input object.
2356
2388
  * @public exported from `@promptbook/utils`
2357
2389
  */
2358
2390
  function deepClone(objectValue) {
@@ -2452,11 +2484,11 @@
2452
2484
  */
2453
2485
 
2454
2486
  /**
2455
- * @@@
2487
+ * Normalizes a given text to camelCase format.
2456
2488
  *
2457
- * @param text @@@
2458
- * @param _isFirstLetterCapital @@@
2459
- * @returns @@@
2489
+ * @param text The text to be normalized.
2490
+ * @param _isFirstLetterCapital Whether the first letter should be capitalized.
2491
+ * @returns The camelCase formatted string.
2460
2492
  * @example 'helloWorld'
2461
2493
  * @example 'iLovePromptbook'
2462
2494
  * @public exported from `@promptbook/utils`
@@ -2522,9 +2554,9 @@
2522
2554
  /**
2523
2555
  * Removes quotes from a string
2524
2556
  *
2525
- * Tip: This is very usefull for post-processing of the result of the LLM model
2557
+ * Tip: This is very useful for post-processing of the result of the LLM model
2526
2558
  * Note: This function removes only the same quotes from the beginning and the end of the string
2527
- * Note: There are two simmilar functions:
2559
+ * Note: There are two similar functions:
2528
2560
  * - `removeQuotes` which removes only bounding quotes
2529
2561
  * - `unwrapResult` which removes whole introduce sentence
2530
2562
  *
@@ -2536,18 +2568,19 @@
2536
2568
  if (text.startsWith('"') && text.endsWith('"')) {
2537
2569
  return text.slice(1, -1);
2538
2570
  }
2539
- if (text.startsWith('\'') && text.endsWith('\'')) {
2571
+ if (text.startsWith("'") && text.endsWith("'")) {
2540
2572
  return text.slice(1, -1);
2541
2573
  }
2542
2574
  return text;
2543
2575
  }
2544
2576
 
2545
2577
  /**
2546
- * Function `validateParameterName` will @@@
2578
+ * Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
2579
+ * It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
2547
2580
  *
2548
- * @param parameterName @@@
2549
- * @returns @@@
2550
- * @throws {ParseError} @@@
2581
+ * @param parameterName The parameter name to validate and normalize.
2582
+ * @returns The validated and normalized parameter name.
2583
+ * @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
2551
2584
  * @private within the repository
2552
2585
  */
2553
2586
  function validateParameterName(parameterName) {
@@ -2617,8 +2650,6 @@
2617
2650
  /**
2618
2651
  * Parses the foreach command
2619
2652
  *
2620
- * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book` file
2621
- *
2622
2653
  * @see `documentationUrl` for more details
2623
2654
  * @public exported from `@promptbook/editable`
2624
2655
  */
@@ -2675,14 +2706,14 @@
2675
2706
  `));
2676
2707
  // <- TODO: [🏢] List all supported format names
2677
2708
  }
2678
- const subvalueDefinition = formatDefinition.subvalueDefinitions.find((subvalueDefinition) => [subvalueDefinition.subvalueName, ...(subvalueDefinition.aliases || [])].includes(subformatName));
2679
- if (subvalueDefinition === undefined) {
2709
+ const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
2710
+ if (subvalueParser === undefined) {
2680
2711
  throw new ParseError(spaceTrim__default["default"]((block) => `
2681
2712
  Unsupported subformat name "${subformatName}" for format "${formatName}"
2682
2713
 
2683
2714
  Available subformat names for format "${formatDefinition.formatName}":
2684
- ${block(formatDefinition.subvalueDefinitions
2685
- .map((subvalueDefinition) => subvalueDefinition.subvalueName)
2715
+ ${block(formatDefinition.subvalueParsers
2716
+ .map((subvalueParser) => subvalueParser.subvalueName)
2686
2717
  .map((subvalueName) => `- ${subvalueName}`)
2687
2718
  .join('\n'))}
2688
2719
  `));
@@ -2859,14 +2890,14 @@
2859
2890
  };
2860
2891
 
2861
2892
  /**
2862
- * @@@
2893
+ * Chatbot form factor definition for conversational interfaces that interact with users in a chat-like manner.
2863
2894
  *
2864
2895
  * @public exported from `@promptbook/core`
2865
2896
  */
2866
2897
  const ChatbotFormfactorDefinition = {
2867
2898
  name: 'CHATBOT',
2868
2899
  aliasNames: ['CHAT'],
2869
- description: `@@@`,
2900
+ description: `A chatbot form factor for conversational user interfaces.`,
2870
2901
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/174`,
2871
2902
  pipelineInterface: {
2872
2903
  inputParameters: [
@@ -2893,7 +2924,45 @@
2893
2924
  };
2894
2925
 
2895
2926
  /**
2896
- * Generator is form of app that @@@
2927
+ * Completion is formfactor that emulates completion models
2928
+ *
2929
+ * @public exported from `@promptbook/core`
2930
+ */
2931
+ const CompletionFormfactorDefinition = {
2932
+ name: 'COMPLETION',
2933
+ description: `Completion is formfactor that emulates completion models`,
2934
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
2935
+ // <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
2936
+ // "🔠 Completion Formfactor"
2937
+ pipelineInterface: {
2938
+ inputParameters: [
2939
+ {
2940
+ name: 'inputText',
2941
+ description: `Input text to be completed`,
2942
+ isInput: true,
2943
+ isOutput: false,
2944
+ },
2945
+ {
2946
+ name: 'instructions',
2947
+ description: `Additional instructions for the model, for example the required length, empty by default`,
2948
+ isInput: true,
2949
+ isOutput: false,
2950
+ },
2951
+ ],
2952
+ outputParameters: [
2953
+ {
2954
+ name: 'followingText',
2955
+ description: `Text that follows the input text`,
2956
+ isInput: false,
2957
+ isOutput: true,
2958
+ },
2959
+ ],
2960
+ },
2961
+ };
2962
+
2963
+ /**
2964
+ * Generator form factor represents an application that generates content or data based on user input or predefined rules.
2965
+ * This form factor is used for apps that produce outputs, such as text, images, or other media, based on provided input.
2897
2966
  *
2898
2967
  * @public exported from `@promptbook/core`
2899
2968
  */
@@ -2922,7 +2991,7 @@
2922
2991
  };
2923
2992
 
2924
2993
  /**
2925
- * @@@
2994
+ * Pipeline interface which is equivalent to `any`
2926
2995
  *
2927
2996
  * @see https://github.com/webgptorg/promptbook/discussions/171
2928
2997
  *
@@ -2937,13 +3006,13 @@
2937
3006
  */
2938
3007
 
2939
3008
  /**
2940
- * @@@
3009
+ * A generic pipeline
2941
3010
  *
2942
3011
  * @public exported from `@promptbook/core`
2943
3012
  */
2944
3013
  const GenericFormfactorDefinition = {
2945
3014
  name: 'GENERIC',
2946
- description: `@@@`,
3015
+ description: `A generic pipeline`,
2947
3016
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/173`,
2948
3017
  pipelineInterface: GENERIC_PIPELINE_INTERFACE,
2949
3018
  };
@@ -2978,17 +3047,20 @@
2978
3047
  };
2979
3048
 
2980
3049
  /**
2981
- * Matcher is form of app that @@@
3050
+ * Matcher is form of app that evaluates (spreadsheet) content against defined criteria or patterns,
3051
+ * determining if it matches or meets specific requirements. Used for classification,
3052
+ * validation, filtering, and quality assessment of inputs.
2982
3053
  *
2983
3054
  * @public exported from `@promptbook/core`
2984
3055
  */
2985
3056
  const MatcherFormfactorDefinition = {
2986
3057
  name: 'EXPERIMENTAL_MATCHER',
2987
- description: `@@@`,
3058
+ description: `An evaluation system that determines whether content meets specific criteria or patterns.
3059
+ Used for content validation, quality assessment, and intelligent filtering tasks. Currently in experimental phase.`,
2988
3060
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
2989
3061
  pipelineInterface: {
2990
3062
  inputParameters: [
2991
- /* @@@ */
3063
+ /* Input parameters for content to be matched and criteria to match against */
2992
3064
  {
2993
3065
  name: 'nonce',
2994
3066
  description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
@@ -2997,20 +3069,21 @@
2997
3069
  },
2998
3070
  ],
2999
3071
  outputParameters: [
3000
- /* @@@ */
3072
+ /* Output parameters containing match results, confidence scores, and relevant metadata */
3001
3073
  ],
3002
3074
  },
3003
3075
  };
3004
3076
 
3005
3077
  /**
3006
- * Sheets is form of app that @@@
3078
+ * Sheets is form of app that processes tabular data in CSV format, allowing transformation
3079
+ * and analysis of structured data through AI-powered operations
3007
3080
  *
3008
3081
  * @public exported from `@promptbook/core`
3009
3082
  */
3010
3083
  const SheetsFormfactorDefinition = {
3011
3084
  name: 'SHEETS',
3012
3085
  aliasNames: ['SHEETS', 'SHEET'],
3013
- description: `@@@`,
3086
+ description: `A formfactor for processing spreadsheet-like data in CSV format, enabling AI transformations on tabular data`,
3014
3087
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/176`,
3015
3088
  pipelineInterface: {
3016
3089
  inputParameters: [
@@ -3033,13 +3106,16 @@
3033
3106
  };
3034
3107
 
3035
3108
  /**
3036
- * Translator is form of app that @@@
3109
+ * Translator is form of app that transforms input text from one form to another,
3110
+ * such as language translation, style conversion, tone modification, or other text transformations.
3037
3111
  *
3038
3112
  * @public exported from `@promptbook/core`
3039
3113
  */
3040
3114
  const TranslatorFormfactorDefinition = {
3041
3115
  name: 'TRANSLATOR',
3042
- description: `@@@`,
3116
+ description: `A text transformation system that converts input content into different forms,
3117
+ including language translations, paraphrasing, style conversions, and tone adjustments.
3118
+ This form factor takes one input and produces one transformed output.`,
3043
3119
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
3044
3120
  pipelineInterface: {
3045
3121
  inputParameters: [
@@ -3076,6 +3152,8 @@
3076
3152
  MatcherFormfactorDefinition,
3077
3153
  GeneratorFormfactorDefinition,
3078
3154
  ImageGeneratorFormfactorDefinition,
3155
+ CompletionFormfactorDefinition,
3156
+ // <- [🛬] When making new formfactor, copy the _boilerplate and link it here
3079
3157
  ];
3080
3158
  /**
3081
3159
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3084,7 +3162,7 @@
3084
3162
  /**
3085
3163
  * Parses the formfactor command
3086
3164
  *
3087
- * Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book` file
3165
+ * Note: This command is used as a formfactor for new commands and defines the app type format - it should NOT be used in any `.book` file
3088
3166
  *
3089
3167
  * @see `documentationUrl` for more details
3090
3168
  * @public exported from `@promptbook/editable`
@@ -3106,7 +3184,7 @@
3106
3184
  /**
3107
3185
  * Description of the FORMFACTOR command
3108
3186
  */
3109
- description: `@@`,
3187
+ description: `Specifies the application type and interface requirements that this promptbook should conform to`,
3110
3188
  /**
3111
3189
  * Link to documentation
3112
3190
  */
@@ -3249,8 +3327,7 @@
3249
3327
  };
3250
3328
 
3251
3329
  /**
3252
- * @@@
3253
- *
3330
+ * @see {@link ModelVariant}
3254
3331
  * @public exported from `@promptbook/core`
3255
3332
  */
3256
3333
  const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
@@ -3682,10 +3759,10 @@
3682
3759
  }
3683
3760
 
3684
3761
  /**
3685
- * @@@
3762
+ * Checks if the given value is a valid JavaScript identifier name.
3686
3763
  *
3687
- * @param javascriptName @@@
3688
- * @returns @@@
3764
+ * @param javascriptName The value to check for JavaScript identifier validity.
3765
+ * @returns `true` if the value is a valid JavaScript name, false otherwise.
3689
3766
  * @public exported from `@promptbook/utils`
3690
3767
  */
3691
3768
  function isValidJavascriptName(javascriptName) {
@@ -3776,7 +3853,7 @@
3776
3853
  /**
3777
3854
  * Tests if given string is valid pipeline URL URL.
3778
3855
  *
3779
- * Note: There are two simmilar functions:
3856
+ * Note: There are two similar functions:
3780
3857
  * - `isValidUrl` which tests any URL
3781
3858
  * - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
3782
3859
  *
@@ -4178,7 +4255,7 @@
4178
4255
  // Arg1 Arg2 Arg3 | FOO
4179
4256
  {
4180
4257
  const commandNameRaw = items.slice(-1).join('_');
4181
- const args = items.slice(0, -1); // <- Note: This is probbably not correct
4258
+ const args = items.slice(0, -1); // <- Note: This is probably not correct
4182
4259
  const rawArgs = raw
4183
4260
  .substring(0, raw.length - commandNameRaw.length)
4184
4261
  .trim();
@@ -4197,7 +4274,10 @@
4197
4274
  `));
4198
4275
  }
4199
4276
  /**
4200
- * @@@
4277
+ * Generates a markdown-formatted message listing all supported commands
4278
+ * with their descriptions and documentation links
4279
+ *
4280
+ * @returns A formatted markdown string containing all available commands and their details
4201
4281
  */
4202
4282
  function getSupportedCommandsMessage() {
4203
4283
  return COMMANDS.flatMap(({ name, aliasNames, description, documentationUrl }) =>
@@ -4208,7 +4288,10 @@
4208
4288
  ]).join('\n');
4209
4289
  }
4210
4290
  /**
4211
- * @@@
4291
+ * Attempts to parse a command variant using the provided input parameters
4292
+ *
4293
+ * @param input Object containing command parsing information including raw command text and normalized values
4294
+ * @returns A parsed Command object if successful, or null if the command cannot be parsed
4212
4295
  */
4213
4296
  function parseCommandVariant(input) {
4214
4297
  const { commandNameRaw, usagePlace, normalized, args, raw, rawArgs } = input;
@@ -4255,7 +4338,7 @@
4255
4338
  }
4256
4339
 
4257
4340
  /**
4258
- * @@@
4341
+ * Extracts the interface (input and output parameters) from a pipeline.
4259
4342
  *
4260
4343
  * @deprecated https://github.com/webgptorg/promptbook/pull/186
4261
4344
  * @see https://github.com/webgptorg/promptbook/discussions/171
@@ -4288,7 +4371,7 @@
4288
4371
  }
4289
4372
 
4290
4373
  /**
4291
- * @@@
4374
+ * Checks if two pipeline interfaces are structurally identical.
4292
4375
  *
4293
4376
  * @deprecated https://github.com/webgptorg/promptbook/pull/186
4294
4377
  * @see https://github.com/webgptorg/promptbook/discussions/171
@@ -4320,10 +4403,11 @@
4320
4403
  }
4321
4404
 
4322
4405
  /**
4323
- * @@@
4406
+ * Checks if a given pipeline satisfies the requirements of a specified pipeline interface.
4324
4407
  *
4325
4408
  * @deprecated https://github.com/webgptorg/promptbook/pull/186
4326
4409
  * @see https://github.com/webgptorg/promptbook/discussions/171
4410
+ * @returns `true` if the pipeline implements the interface, `false` otherwise.
4327
4411
  *
4328
4412
  * @public exported from `@promptbook/core`
4329
4413
  */
@@ -4553,7 +4637,8 @@
4553
4637
  }
4554
4638
 
4555
4639
  /**
4556
- * @@@
4640
+ * Utility to determine if a pipeline string is in flat format.
4641
+ * A flat pipeline is a simple text without proper structure (headers, blocks, etc).
4557
4642
  *
4558
4643
  * @public exported from `@promptbook/editable`
4559
4644
  */
@@ -4574,7 +4659,10 @@
4574
4659
  }
4575
4660
 
4576
4661
  /**
4577
- * @@@
4662
+ * Converts a pipeline structure to its string representation.
4663
+ *
4664
+ * Transforms a flat, simple pipeline into a properly formatted pipeline string
4665
+ * with sections for title, prompt, and return statement.
4578
4666
  *
4579
4667
  * @public exported from `@promptbook/editable`
4580
4668
  */
@@ -4631,7 +4719,7 @@
4631
4719
  * Note: It can not work with html syntax and comments
4632
4720
  *
4633
4721
  * @param markdown any valid markdown
4634
- * @returns @@@
4722
+ * @returns An array of strings, each representing an individual list item found in the markdown
4635
4723
  * @public exported from `@promptbook/markdown-utils`
4636
4724
  */
4637
4725
  function extractAllListItemsFromMarkdown(markdown) {
@@ -4663,8 +4751,8 @@
4663
4751
  /**
4664
4752
  * Extracts all code blocks from markdown.
4665
4753
  *
4666
- * Note: There are multiple simmilar function:
4667
- * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
4754
+ * Note: There are multiple similar functions:
4755
+ * - `extractBlock` just extracts the content of the code block which is also used as built-in function for postprocessing
4668
4756
  * - `extractJsonBlock` extracts exactly one valid JSON code block
4669
4757
  * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
4670
4758
  * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
@@ -4714,7 +4802,7 @@
4714
4802
  if (currentCodeBlock.content !== '') {
4715
4803
  currentCodeBlock.content += '\n';
4716
4804
  }
4717
- currentCodeBlock.content += line.split('\\`\\`\\`').join('```') /* <- TODO: Maybe make propper unescape */;
4805
+ currentCodeBlock.content += line.split('\\`\\`\\`').join('```') /* <- TODO: Maybe make proper unescape */;
4718
4806
  }
4719
4807
  }
4720
4808
  if (currentCodeBlock !== null) {
@@ -4731,8 +4819,8 @@
4731
4819
  *
4732
4820
  * - When there are multiple or no code blocks the function throws a `ParseError`
4733
4821
  *
4734
- * Note: There are multiple simmilar function:
4735
- * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
4822
+ * Note: There are multiple similar functions:
4823
+ * - `extractBlock` just extracts the content of the code block which is also used as built-in function for postprocessing
4736
4824
  * - `extractJsonBlock` extracts exactly one valid JSON code block
4737
4825
  * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
4738
4826
  * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
@@ -4884,11 +4972,11 @@
4884
4972
  */
4885
4973
 
4886
4974
  /**
4887
- * @@@
4975
+ * Converts a title string into a normalized name.
4888
4976
  *
4889
- * @param value @@@
4890
- * @returns @@@
4891
- * @example @@@
4977
+ * @param value The title string to be converted to a name.
4978
+ * @returns A normalized name derived from the input title.
4979
+ * @example 'Hello World!' -> 'hello-world'
4892
4980
  * @public exported from `@promptbook/utils`
4893
4981
  */
4894
4982
  function titleToName(value) {
@@ -5053,7 +5141,7 @@
5053
5141
  * Compile pipeline from string (markdown) format to JSON format synchronously
5054
5142
  *
5055
5143
  * Note: There are 3 similar functions:
5056
- * - `compilePipeline` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
5144
+ * - `compilePipeline` **(preferred)** - which properly compiles the promptbook and uses embedding for external knowledge
5057
5145
  * - `parsePipeline` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
5058
5146
  * - `preparePipeline` - just one step in the compilation process
5059
5147
  *
@@ -5490,7 +5578,7 @@
5490
5578
  * TODO: Use spaceTrim more effectively
5491
5579
  * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
5492
5580
  * TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
5493
- * TODO: [♈] Probbably move expectations from tasks to parameters
5581
+ * TODO: [♈] Probably move expectations from tasks to parameters
5494
5582
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
5495
5583
  * TODO: [🍙] Make some standard order of json properties
5496
5584
  */
@@ -5535,10 +5623,10 @@
5535
5623
  }
5536
5624
  get title() {
5537
5625
  // TODO: [🧠] Maybe fetch title+description from the remote server (as well as if model methods are defined)
5538
- return 'Remote server';
5626
+ return 'Promptbook remote server';
5539
5627
  }
5540
5628
  get description() {
5541
- return 'Use all models by your remote server';
5629
+ return `Models from Promptbook remote server ${this.options.remoteServerUrl}`;
5542
5630
  }
5543
5631
  /**
5544
5632
  * Check the configuration of all execution tools
@@ -5553,7 +5641,7 @@
5553
5641
  * List all available models that can be used
5554
5642
  */
5555
5643
  async listModels() {
5556
- // TODO: [👒] Listing models (and checking configuration) probbably should go through REST API not Socket.io
5644
+ // TODO: [👒] Listing models (and checking configuration) probably should go through REST API not Socket.io
5557
5645
  const socket = await createRemoteClient(this.options);
5558
5646
  socket.emit('listModels-request', {
5559
5647
  identification: this.options.identification,