@promptbook/node 0.92.0-26 → 0.92.0-28

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 (50) hide show
  1. package/esm/index.es.js +85 -39
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +4 -4
  4. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +0 -2
  5. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
  6. package/esm/typings/src/constants.d.ts +35 -0
  7. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -1
  8. package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +2 -1
  9. package/esm/typings/src/executables/apps/locatePandoc.d.ts +2 -1
  10. package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +2 -1
  11. package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +2 -1
  12. package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +2 -1
  13. package/esm/typings/src/execution/AbstractTaskResult.d.ts +1 -1
  14. package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +2 -1
  15. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +1 -1
  16. package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +12 -9
  17. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +20 -14
  18. package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +7 -6
  19. package/esm/typings/src/execution/createPipelineExecutor/getContextForTask.d.ts +5 -1
  20. package/esm/typings/src/execution/createPipelineExecutor/getExamplesForTask.d.ts +1 -1
  21. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +8 -11
  22. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +4 -4
  23. package/esm/typings/src/execution/utils/uncertainNumber.d.ts +3 -2
  24. package/esm/typings/src/formats/csv/CsvSettings.d.ts +2 -2
  25. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +16 -7
  26. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +3 -1
  27. package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +2 -2
  28. package/esm/typings/src/formfactors/completion/CompletionFormfactorDefinition.d.ts +1 -1
  29. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +2 -1
  30. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +2 -2
  31. package/esm/typings/src/formfactors/index.d.ts +5 -5
  32. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +4 -2
  33. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +3 -2
  34. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +4 -3
  35. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +17 -4
  36. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +11 -4
  37. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +21 -42
  38. package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +5 -1
  39. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +12 -3
  40. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +5 -0
  41. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  42. package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
  43. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  44. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  45. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -2
  46. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -2
  47. package/esm/typings/src/version.d.ts +1 -1
  48. package/package.json +2 -2
  49. package/umd/index.umd.js +85 -39
  50. package/umd/index.umd.js.map +1 -1
package/esm/index.es.js CHANGED
@@ -30,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-26';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-28';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2534,7 +2534,7 @@ function union(...sets) {
2534
2534
  }
2535
2535
 
2536
2536
  /**
2537
- * @@@
2537
+ * Contains configuration options for parsing and generating CSV files, such as delimiters and quoting rules.
2538
2538
  *
2539
2539
  * @public exported from `@promptbook/core`
2540
2540
  */
@@ -3721,8 +3721,12 @@ function checkExpectations(expectations, value) {
3721
3721
  */
3722
3722
 
3723
3723
  /**
3724
- * @@@
3724
+ * Executes a pipeline task with multiple attempts, including joker and retry logic. Handles different task types
3725
+ * (prompt, script, dialog, etc.), applies postprocessing, checks expectations, and updates the execution report.
3726
+ * Throws errors if execution fails after all attempts.
3725
3727
  *
3728
+ * @param options - The options for execution, including task, parameters, pipeline, and configuration.
3729
+ * @returns The result string of the executed task.
3726
3730
  * @private internal utility of `createPipelineExecutor`
3727
3731
  */
3728
3732
  async function executeAttempts(options) {
@@ -4180,8 +4184,12 @@ async function executeFormatSubvalues(options) {
4180
4184
  }
4181
4185
 
4182
4186
  /**
4183
- * @@@
4187
+ * Returns the context for a given task, typically used to provide additional information or variables
4188
+ * required for the execution of the task within a pipeline. The context is returned as a string value
4189
+ * that may include markdown formatting.
4184
4190
  *
4191
+ * @param task - The task for which the context is being generated. This should be a deeply immutable TaskJson object.
4192
+ * @returns The context as a string, formatted as markdown and parameter value.
4185
4193
  * @private internal utility of `createPipelineExecutor`
4186
4194
  */
4187
4195
  async function getContextForTask(task) {
@@ -4189,7 +4197,7 @@ async function getContextForTask(task) {
4189
4197
  }
4190
4198
 
4191
4199
  /**
4192
- * @@@
4200
+ * Retrieves example values or templates for a given task, used to guide or validate pipeline execution.
4193
4201
  *
4194
4202
  * @private internal utility of `createPipelineExecutor`
4195
4203
  */
@@ -4236,9 +4244,8 @@ function knowledgePiecesToString(knowledgePieces) {
4236
4244
  }
4237
4245
 
4238
4246
  /**
4239
- * @@@
4240
- *
4241
- * Here is the place where RAG (retrieval-augmented generation) happens
4247
+ * Retrieves the most relevant knowledge pieces for a given task using embedding-based similarity search.
4248
+ * This is where retrieval-augmented generation (RAG) is performed to enhance the task with external knowledge.
4242
4249
  *
4243
4250
  * @private internal utility of `createPipelineExecutor`
4244
4251
  */
@@ -4457,7 +4464,8 @@ async function executeTask(options) {
4457
4464
  */
4458
4465
 
4459
4466
  /**
4460
- * @@@
4467
+ * Filters and returns only the output parameters from the provided pipeline execution options.
4468
+ * Adds warnings for any expected output parameters that are missing.
4461
4469
  *
4462
4470
  * @private internal utility of `createPipelineExecutor`
4463
4471
  */
@@ -6223,7 +6231,7 @@ const sectionCommandParser = {
6223
6231
  /**
6224
6232
  * Parses the boilerplate command
6225
6233
  *
6226
- * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book` file
6234
+ * Note: @@ This command is used as boilerplate for new commands - it should NOT be used in any `.book` file
6227
6235
  *
6228
6236
  * @see `documentationUrl` for more details
6229
6237
  * @private within the commands folder
@@ -6761,8 +6769,6 @@ function validateParameterName(parameterName) {
6761
6769
  /**
6762
6770
  * Parses the foreach command
6763
6771
  *
6764
- * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book` file
6765
- *
6766
6772
  * @see `documentationUrl` for more details
6767
6773
  * @public exported from `@promptbook/editable`
6768
6774
  */
@@ -7003,14 +7009,14 @@ const formatCommandParser = {
7003
7009
  };
7004
7010
 
7005
7011
  /**
7006
- * @@@
7012
+ * Chatbot form factor definition for conversational interfaces that interact with users in a chat-like manner.
7007
7013
  *
7008
7014
  * @public exported from `@promptbook/core`
7009
7015
  */
7010
7016
  const ChatbotFormfactorDefinition = {
7011
7017
  name: 'CHATBOT',
7012
7018
  aliasNames: ['CHAT'],
7013
- description: `@@@`,
7019
+ description: `A chatbot form factor for conversational user interfaces.`,
7014
7020
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/174`,
7015
7021
  pipelineInterface: {
7016
7022
  inputParameters: [
@@ -7043,7 +7049,7 @@ const ChatbotFormfactorDefinition = {
7043
7049
  */
7044
7050
  const CompletionFormfactorDefinition = {
7045
7051
  name: 'COMPLETION',
7046
- description: `@@@`,
7052
+ description: `Completion is formfactor that emulates completion models`,
7047
7053
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
7048
7054
  // <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
7049
7055
  // "🔠 Completion Formfactor"
@@ -7074,7 +7080,8 @@ const CompletionFormfactorDefinition = {
7074
7080
  };
7075
7081
 
7076
7082
  /**
7077
- * Generator is form of app that @@@
7083
+ * Generator form factor represents an application that generates content or data based on user input or predefined rules.
7084
+ * This form factor is used for apps that produce outputs, such as text, images, or other media, based on provided input.
7078
7085
  *
7079
7086
  * @public exported from `@promptbook/core`
7080
7087
  */
@@ -7118,13 +7125,13 @@ const GENERIC_PIPELINE_INTERFACE = {
7118
7125
  */
7119
7126
 
7120
7127
  /**
7121
- * @@@
7128
+ * A generic pipeline
7122
7129
  *
7123
7130
  * @public exported from `@promptbook/core`
7124
7131
  */
7125
7132
  const GenericFormfactorDefinition = {
7126
7133
  name: 'GENERIC',
7127
- description: `@@@`,
7134
+ description: `A generic pipeline`,
7128
7135
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/173`,
7129
7136
  pipelineInterface: GENERIC_PIPELINE_INTERFACE,
7130
7137
  };
@@ -7159,17 +7166,20 @@ const ImageGeneratorFormfactorDefinition = {
7159
7166
  };
7160
7167
 
7161
7168
  /**
7162
- * Matcher is form of app that @@@
7169
+ * Matcher is form of app that evaluates (spreadsheet) content against defined criteria or patterns,
7170
+ * determining if it matches or meets specific requirements. Used for classification,
7171
+ * validation, filtering, and quality assessment of inputs.
7163
7172
  *
7164
7173
  * @public exported from `@promptbook/core`
7165
7174
  */
7166
7175
  const MatcherFormfactorDefinition = {
7167
7176
  name: 'EXPERIMENTAL_MATCHER',
7168
- description: `@@@`,
7177
+ description: `An evaluation system that determines whether content meets specific criteria or patterns.
7178
+ Used for content validation, quality assessment, and intelligent filtering tasks. Currently in experimental phase.`,
7169
7179
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
7170
7180
  pipelineInterface: {
7171
7181
  inputParameters: [
7172
- /* @@@ */
7182
+ /* Input parameters for content to be matched and criteria to match against */
7173
7183
  {
7174
7184
  name: 'nonce',
7175
7185
  description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
@@ -7178,7 +7188,7 @@ const MatcherFormfactorDefinition = {
7178
7188
  },
7179
7189
  ],
7180
7190
  outputParameters: [
7181
- /* @@@ */
7191
+ /* Output parameters containing match results, confidence scores, and relevant metadata */
7182
7192
  ],
7183
7193
  },
7184
7194
  };
@@ -7215,13 +7225,16 @@ const SheetsFormfactorDefinition = {
7215
7225
  };
7216
7226
 
7217
7227
  /**
7218
- * Translator is form of app that @@@
7228
+ * Translator is form of app that transforms input text from one form to another,
7229
+ * such as language translation, style conversion, tone modification, or other text transformations.
7219
7230
  *
7220
7231
  * @public exported from `@promptbook/core`
7221
7232
  */
7222
7233
  const TranslatorFormfactorDefinition = {
7223
7234
  name: 'TRANSLATOR',
7224
- description: `@@@`,
7235
+ description: `A text transformation system that converts input content into different forms,
7236
+ including language translations, paraphrasing, style conversions, and tone adjustments.
7237
+ This form factor takes one input and produces one transformed output.`,
7225
7238
  documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
7226
7239
  pipelineInterface: {
7227
7240
  inputParameters: [
@@ -8348,7 +8361,10 @@ function parseCommand(raw, usagePlace) {
8348
8361
  `));
8349
8362
  }
8350
8363
  /**
8351
- * @@@
8364
+ * Generates a markdown-formatted message listing all supported commands
8365
+ * with their descriptions and documentation links
8366
+ *
8367
+ * @returns A formatted markdown string containing all available commands and their details
8352
8368
  */
8353
8369
  function getSupportedCommandsMessage() {
8354
8370
  return COMMANDS.flatMap(({ name, aliasNames, description, documentationUrl }) =>
@@ -8359,7 +8375,10 @@ function getSupportedCommandsMessage() {
8359
8375
  ]).join('\n');
8360
8376
  }
8361
8377
  /**
8362
- * @@@
8378
+ * Attempts to parse a command variant using the provided input parameters
8379
+ *
8380
+ * @param input Object containing command parsing information including raw command text and normalized values
8381
+ * @returns A parsed Command object if successful, or null if the command cannot be parsed
8363
8382
  */
8364
8383
  function parseCommandVariant(input) {
8365
8384
  const { commandNameRaw, usagePlace, normalized, args, raw, rawArgs } = input;
@@ -9578,7 +9597,8 @@ function $execCommand(options) {
9578
9597
  */
9579
9598
 
9580
9599
  /**
9581
- * @@@
9600
+ * Attempts to locate the specified application on a Linux system using the 'which' command.
9601
+ * Returns the path to the executable if found, or null otherwise.
9582
9602
  *
9583
9603
  * @private within the repository
9584
9604
  */
@@ -9645,7 +9665,8 @@ async function isExecutable(path, fs) {
9645
9665
  // eslint-disable-next-line @typescript-eslint/no-var-requires
9646
9666
  const userhome = require('userhome');
9647
9667
  /**
9648
- * @@@
9668
+ * Attempts to locate the specified application on a macOS system by checking standard application paths and using mdfind.
9669
+ * Returns the path to the executable if found, or null otherwise.
9649
9670
  *
9650
9671
  * @private within the repository
9651
9672
  */
@@ -9677,7 +9698,8 @@ async function locateAppOnMacOs({ macOsName, }) {
9677
9698
  */
9678
9699
 
9679
9700
  /**
9680
- * @@@
9701
+ * Attempts to locate the specified application on a Windows system by searching common installation directories.
9702
+ * Returns the path to the executable if found, or null otherwise.
9681
9703
  *
9682
9704
  * @private within the repository
9683
9705
  */
@@ -9748,7 +9770,8 @@ function locateApp(options) {
9748
9770
  */
9749
9771
 
9750
9772
  /**
9751
- * @@@
9773
+ * Locates the LibreOffice executable on the current system by searching platform-specific paths.
9774
+ * Returns the path to the executable if found, or null otherwise.
9752
9775
  *
9753
9776
  * @private within the repository
9754
9777
  */
@@ -9766,7 +9789,8 @@ function locateLibreoffice() {
9766
9789
  */
9767
9790
 
9768
9791
  /**
9769
- * @@@
9792
+ * Locates the Pandoc executable on the current system by searching platform-specific paths.
9793
+ * Returns the path to the executable if found, or null otherwise.
9770
9794
  *
9771
9795
  * @private within the repository
9772
9796
  */
@@ -9784,7 +9808,7 @@ function locatePandoc() {
9784
9808
  */
9785
9809
 
9786
9810
  /**
9787
- * @@@
9811
+ * Provides paths to required executables (i.e. as Pandoc and LibreOffice) for Node.js environments.
9788
9812
  *
9789
9813
  * @public exported from `@promptbook/node`
9790
9814
  */
@@ -10063,11 +10087,16 @@ async function $provideLlmToolsConfigurationFromEnv() {
10063
10087
  */
10064
10088
 
10065
10089
  /**
10066
- * @@@
10090
+ * Creates LLM execution tools from provided configuration objects
10091
+ *
10092
+ * Instantiates and configures LLM tool instances for each configuration entry,
10093
+ * combining them into a unified interface via MultipleLlmExecutionTools.
10067
10094
  *
10068
10095
  * Note: This function is not cached, every call creates new instance of `MultipleLlmExecutionTools`
10069
10096
  *
10070
- * @returns @@@
10097
+ * @param configuration Array of LLM tool configurations to instantiate
10098
+ * @param options Additional options for configuring the LLM tools
10099
+ * @returns A unified interface combining all successfully instantiated LLM tools
10071
10100
  * @public exported from `@promptbook/core`
10072
10101
  */
10073
10102
  function createLlmToolsFromConfiguration(configuration, options = {}) {
@@ -10106,7 +10135,11 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
10106
10135
  /**
10107
10136
  * TODO: [🎌] Together with `createLlmToolsFromConfiguration` + 'EXECUTION_TOOLS_CLASSES' gets to `@promptbook/core` ALL model providers, make this more efficient
10108
10137
  * TODO: [🧠][🎌] Dynamically install required providers
10109
- * TODO: @@@ write discussion about this - wizzard
10138
+ * TODO: We should implement an interactive configuration wizard that would:
10139
+ * 1. Detect which LLM providers are available in the environment
10140
+ * 2. Guide users through required configuration settings for each provider
10141
+ * 3. Allow testing connections before completing setup
10142
+ * 4. Generate appropriate configuration code for application integration
10110
10143
  * TODO: [🧠][🍛] Which name is better `createLlmToolsFromConfig` or `createLlmToolsFromConfiguration`?
10111
10144
  * TODO: [🧠] Is there some meaningfull way how to test this util
10112
10145
  * TODO: This should be maybe not under `_common` but under `utils`
@@ -10114,11 +10147,14 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
10114
10147
  */
10115
10148
 
10116
10149
  /**
10117
- * @@@
10150
+ * Automatically configures LLM tools from environment variables in Node.js
10151
+ *
10152
+ * This utility function detects available LLM providers based on environment variables
10153
+ * and creates properly configured LLM execution tools for each detected provider.
10118
10154
  *
10119
10155
  * Note: This function is not cached, every call creates new instance of `MultipleLlmExecutionTools`
10120
10156
  *
10121
- * @@@ .env
10157
+ * Supports environment variables from .env files when dotenv is configured
10122
10158
  * Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access `.env` file
10123
10159
  *
10124
10160
  * It looks for environment variables:
@@ -10126,7 +10162,8 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
10126
10162
  * - `process.env.ANTHROPIC_CLAUDE_API_KEY`
10127
10163
  * - ...
10128
10164
  *
10129
- * @returns @@@
10165
+ * @param options Configuration options for the LLM tools
10166
+ * @returns A unified interface containing all detected and configured LLM tools
10130
10167
  * @public exported from `@promptbook/node`
10131
10168
  */
10132
10169
  async function $provideLlmToolsFromEnv(options = {}) {
@@ -10152,7 +10189,16 @@ async function $provideLlmToolsFromEnv(options = {}) {
10152
10189
  return createLlmToolsFromConfiguration(configuration, options);
10153
10190
  }
10154
10191
  /**
10155
- * TODO: @@@ write `$provideLlmToolsFromEnv` vs `$provideLlmToolsConfigurationFromEnv` vs `createLlmToolsFromConfiguration`
10192
+ * TODO: The architecture for LLM tools configuration consists of three key functions:
10193
+ * 1. `$provideLlmToolsFromEnv` - High-level function that detects available providers from env vars and returns ready-to-use LLM tools
10194
+ * 2. `$provideLlmToolsConfigurationFromEnv` - Middle layer that extracts configuration objects from environment variables
10195
+ * 3. `createLlmToolsFromConfiguration` - Low-level function that instantiates LLM tools from explicit configuration
10196
+ *
10197
+ * This layered approach allows flexibility in how tools are configured:
10198
+ * - Use $provideLlmToolsFromEnv for automatic detection and setup in Node.js environments
10199
+ * - Use $provideLlmToolsConfigurationFromEnv to extract config objects for modification before instantiation
10200
+ * - Use createLlmToolsFromConfiguration for explicit control over tool configurations
10201
+ *
10156
10202
  * TODO: [🧠][🍛] Which name is better `$provideLlmToolsFromEnv` or `$provideLlmToolsFromEnvironment`?
10157
10203
  * TODO: [🧠] Is there some meaningfull way how to test this util
10158
10204
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment