@promptbook/node 0.89.0-9 โ†’ 0.92.0-3

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 (41) hide show
  1. package/README.md +9 -7
  2. package/esm/index.es.js +146 -66
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/servers.d.ts +40 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +10 -4
  6. package/esm/typings/src/_packages/types.index.d.ts +18 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/login.d.ts +0 -1
  9. package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +16 -3
  10. package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
  11. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -0
  12. package/esm/typings/src/config.d.ts +10 -19
  13. package/esm/typings/src/errors/0-index.d.ts +7 -4
  14. package/esm/typings/src/errors/PipelineExecutionError.d.ts +1 -1
  15. package/esm/typings/src/errors/WrappedError.d.ts +10 -0
  16. package/esm/typings/src/errors/assertsError.d.ts +11 -0
  17. package/esm/typings/src/execution/PromptbookFetch.d.ts +1 -1
  18. package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +9 -0
  19. package/esm/typings/src/formats/csv/utils/isValidCsvString.test.d.ts +1 -0
  20. package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +3 -0
  21. package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +9 -0
  22. package/esm/typings/src/formats/xml/utils/isValidXmlString.test.d.ts +1 -0
  23. package/esm/typings/src/llm-providers/_common/filterModels.d.ts +15 -0
  24. package/esm/typings/src/llm-providers/_common/register/{$provideEnvFilepath.d.ts โ†’ $provideEnvFilename.d.ts} +2 -2
  25. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
  26. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  27. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +11 -2
  28. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
  29. package/esm/typings/src/remote-server/openapi-types.d.ts +284 -0
  30. package/esm/typings/src/remote-server/openapi.d.ts +187 -0
  31. package/esm/typings/src/remote-server/socket-types/_subtypes/Identification.d.ts +7 -1
  32. package/esm/typings/src/remote-server/socket-types/_subtypes/identificationToPromptbookToken.d.ts +11 -0
  33. package/esm/typings/src/remote-server/socket-types/_subtypes/promptbookTokenToIdentification.d.ts +10 -0
  34. package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -2
  35. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +15 -9
  36. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +40 -0
  37. package/esm/typings/src/types/typeAliases.d.ts +26 -0
  38. package/package.json +9 -5
  39. package/umd/index.umd.js +146 -66
  40. package/umd/index.umd.js.map +1 -1
  41. package/esm/typings/src/cli/test/ptbk2.d.ts +0 -5
package/README.md CHANGED
@@ -248,6 +248,10 @@ But unlike programming languages, it is designed to be understandable by non-pro
248
248
 
249
249
 
250
250
 
251
+ ## ๐Ÿ”’ Security
252
+
253
+ For information on reporting security vulnerabilities, see our [Security Policy](./SECURITY.md).
254
+
251
255
  ## ๐Ÿ“ฆ Packages _(for developers)_
252
256
 
253
257
  This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
@@ -304,7 +308,7 @@ The following glossary is used to clarify certain concepts:
304
308
  ### General LLM / AI terms
305
309
 
306
310
  - **Prompt drift** is a phenomenon where the AI model starts to generate outputs that are not aligned with the original prompt. This can happen due to the model's training data, the prompt's wording, or the model's architecture.
307
- - **Pipeline, workflow or chain** is a sequence of tasks that are executed in a specific order. In the context of AI, a pipeline can refer to a sequence of AI models that are used to process data.
311
+ - [**Pipeline, workflow scenario or chain** is a sequence of tasks that are executed in a specific order. In the context of AI, a pipeline can refer to a sequence of AI models that are used to process data.](https://github.com/webgptorg/promptbook/discussions/88)
308
312
  - **Fine-tuning** is a process where a pre-trained AI model is further trained on a specific dataset to improve its performance on a specific task.
309
313
  - **Zero-shot learning** is a machine learning paradigm where a model is trained to perform a task without any labeled examples. Instead, the model is provided with a description of the task and is expected to generate the correct output.
310
314
  - **Few-shot learning** is a machine learning paradigm where a model is trained to perform a task with only a few labeled examples. This is in contrast to traditional machine learning, where models are trained on large datasets.
@@ -312,10 +316,6 @@ The following glossary is used to clarify certain concepts:
312
316
  - **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
313
317
  - **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
314
318
 
315
-
316
-
317
-
318
-
319
319
  _Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
320
320
 
321
321
 
@@ -429,6 +429,8 @@ See [TODO.md](./TODO.md)
429
429
 
430
430
  ## ๐Ÿ–‹๏ธ Contributing
431
431
 
432
- We are open to pull requests, feedback, and suggestions.
432
+ You can also โญ star the project, [follow us on GitHub](https://github.com/hejny) or [various other social networks](https://www.pavolhejny.com/contact/).We are open to [pull requests, feedback, and suggestions](./CONTRIBUTING.md).
433
+
434
+ ## ๐Ÿ“ž Support
433
435
 
434
- You can also โญ star the project, [follow us on GitHub](https://github.com/hejny) or [various other social networks](https://www.pavolhejny.com/contact/).
436
+ If you need help or have questions, please check our [Support Resources](./SUPPORT.md).
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.89.0-9';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-3';
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
@@ -76,6 +76,7 @@ const ADMIN_EMAIL = 'pavol@ptbk.io';
76
76
  * @public exported from `@promptbook/core`
77
77
  */
78
78
  const ADMIN_GITHUB_NAME = 'hejny';
79
+ // <- TODO: [๐ŸŠ] Pick the best claim
79
80
  /**
80
81
  * When the title is not provided, the default title is used
81
82
  *
@@ -120,6 +121,7 @@ const VALUE_STRINGS = {
120
121
  infinity: '(infinity; โˆž)',
121
122
  negativeInfinity: '(negative infinity; -โˆž)',
122
123
  unserializable: '(unserializable value)',
124
+ circular: '(circular JSON)',
123
125
  };
124
126
  /**
125
127
  * Small number limit
@@ -159,7 +161,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
159
161
  */
160
162
  const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
161
163
  // <- TODO: [๐Ÿ•] Make also `BOOKS_DIRNAME_ALTERNATIVES`
162
- // TODO: !!!!!! Just .promptbook dir, hardocode others
164
+ // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
163
165
  /**
164
166
  * Where to store the temporary downloads
165
167
  *
@@ -339,6 +341,54 @@ function $deepFreeze(objectValue) {
339
341
  * TODO: [๐Ÿง ] Is there a way how to meaningfully test this utility
340
342
  */
341
343
 
344
+ /**
345
+ * This error type indicates that somewhere in the code non-Error object was thrown and it was wrapped into the `WrappedError`
346
+ *
347
+ * @public exported from `@promptbook/core`
348
+ */
349
+ class WrappedError extends Error {
350
+ constructor(whatWasThrown) {
351
+ const tag = `[๐Ÿคฎ]`;
352
+ console.error(tag, whatWasThrown);
353
+ super(spaceTrim$1(`
354
+ Non-Error object was thrown
355
+
356
+ Note: Look for ${tag} in the console for more details
357
+ Please report issue on ${ADMIN_EMAIL}
358
+ `));
359
+ this.name = 'WrappedError';
360
+ Object.setPrototypeOf(this, WrappedError.prototype);
361
+ }
362
+ }
363
+
364
+ /**
365
+ * Helper used in catch blocks to assert that the error is an instance of `Error`
366
+ *
367
+ * @param whatWasThrown Any object that was thrown
368
+ * @returns Nothing if the error is an instance of `Error`
369
+ * @throws `WrappedError` or `UnexpectedError` if the error is not standard
370
+ *
371
+ * @private within the repository
372
+ */
373
+ function assertsError(whatWasThrown) {
374
+ // Case 1: Handle error which was rethrown as `WrappedError`
375
+ if (whatWasThrown instanceof WrappedError) {
376
+ const wrappedError = whatWasThrown;
377
+ throw wrappedError;
378
+ }
379
+ // Case 2: Handle unexpected errors
380
+ if (whatWasThrown instanceof UnexpectedError) {
381
+ const unexpectedError = whatWasThrown;
382
+ throw unexpectedError;
383
+ }
384
+ // Case 3: Handle standard errors - keep them up to consumer
385
+ if (whatWasThrown instanceof Error) {
386
+ return;
387
+ }
388
+ // Case 4: Handle non-standard errors - wrap them into `WrappedError` and throw
389
+ throw new WrappedError(whatWasThrown);
390
+ }
391
+
342
392
  /**
343
393
  * Checks if the value is [๐Ÿš‰] serializable as JSON
344
394
  * If not, throws an UnexpectedError with a rich error message and tracking
@@ -430,9 +480,7 @@ function checkSerializableAsJson(options) {
430
480
  JSON.stringify(value); // <- TODO: [0]
431
481
  }
432
482
  catch (error) {
433
- if (!(error instanceof Error)) {
434
- throw error;
435
- }
483
+ assertsError(error);
436
484
  throw new UnexpectedError(spaceTrim((block) => `
437
485
  \`${name}\` is not serializable
438
486
 
@@ -1119,6 +1167,9 @@ function isValidFilePath(filename) {
1119
1167
  /**
1120
1168
  * Function isValidJsonString will tell you if the string is valid JSON or not
1121
1169
  *
1170
+ * @param value The string to check
1171
+ * @returns True if the string is a valid JSON string, false otherwise
1172
+ *
1122
1173
  * @public exported from `@promptbook/utils`
1123
1174
  */
1124
1175
  function isValidJsonString(value /* <- [๐Ÿ‘จโ€โš–๏ธ] */) {
@@ -1127,9 +1178,7 @@ function isValidJsonString(value /* <- [๐Ÿ‘จโ€โš–๏ธ] */) {
1127
1178
  return true;
1128
1179
  }
1129
1180
  catch (error) {
1130
- if (!(error instanceof Error)) {
1131
- throw error;
1132
- }
1181
+ assertsError(error);
1133
1182
  if (error.message.includes('Unexpected token')) {
1134
1183
  return false;
1135
1184
  }
@@ -1661,7 +1710,7 @@ class PipelineExecutionError extends Error {
1661
1710
  }
1662
1711
  }
1663
1712
  /**
1664
- * TODO: !!!!!! Add id to all errors
1713
+ * TODO: [๐Ÿง ][๐ŸŒ‚] Add id to all errors
1665
1714
  */
1666
1715
 
1667
1716
  /**
@@ -1831,7 +1880,10 @@ const PROMPTBOOK_ERRORS = {
1831
1880
  PipelineExecutionError,
1832
1881
  PipelineLogicError,
1833
1882
  PipelineUrlError,
1883
+ AuthenticationError,
1884
+ PromptbookFetchError,
1834
1885
  UnexpectedError,
1886
+ WrappedError,
1835
1887
  // TODO: [๐Ÿช‘]> VersionMismatchError,
1836
1888
  };
1837
1889
  /**
@@ -1848,8 +1900,6 @@ const COMMON_JAVASCRIPT_ERRORS = {
1848
1900
  TypeError,
1849
1901
  URIError,
1850
1902
  AggregateError,
1851
- AuthenticationError,
1852
- PromptbookFetchError,
1853
1903
  /*
1854
1904
  Note: Not widely supported
1855
1905
  > InternalError,
@@ -1972,8 +2022,8 @@ function createTask(options) {
1972
2022
  updatedAt = new Date();
1973
2023
  errors.push(...executionResult.errors);
1974
2024
  warnings.push(...executionResult.warnings);
1975
- // <- TODO: !!! Only unique errors and warnings should be added (or filtered)
1976
- // TODO: [๐Ÿง ] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
2025
+ // <- TODO: [๐ŸŒ‚] Only unique errors and warnings should be added (or filtered)
2026
+ // TODO: [๐Ÿง ] !! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
1977
2027
  // Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
1978
2028
  // And delete `ExecutionTask.currentValue.preparedPipeline`
1979
2029
  assertsTaskSuccessful(executionResult);
@@ -1983,6 +2033,7 @@ function createTask(options) {
1983
2033
  partialResultSubject.next(executionResult);
1984
2034
  }
1985
2035
  catch (error) {
2036
+ assertsError(error);
1986
2037
  status = 'ERROR';
1987
2038
  errors.push(error);
1988
2039
  partialResultSubject.error(error);
@@ -2128,13 +2179,19 @@ function valueToString(value) {
2128
2179
  return value.toISOString();
2129
2180
  }
2130
2181
  else {
2131
- return JSON.stringify(value);
2182
+ try {
2183
+ return JSON.stringify(value);
2184
+ }
2185
+ catch (error) {
2186
+ if (error instanceof TypeError && error.message.includes('circular structure')) {
2187
+ return VALUE_STRINGS.circular;
2188
+ }
2189
+ throw error;
2190
+ }
2132
2191
  }
2133
2192
  }
2134
2193
  catch (error) {
2135
- if (!(error instanceof Error)) {
2136
- throw error;
2137
- }
2194
+ assertsError(error);
2138
2195
  console.error(error);
2139
2196
  return VALUE_STRINGS.unserializable;
2140
2197
  }
@@ -2306,9 +2363,7 @@ function extractVariablesFromJavascript(script) {
2306
2363
  }
2307
2364
  }
2308
2365
  catch (error) {
2309
- if (!(error instanceof Error)) {
2310
- throw error;
2311
- }
2366
+ assertsError(error);
2312
2367
  throw new ParseError(spaceTrim$1((block) => `
2313
2368
  Can not extract variables from the script
2314
2369
  ${block(error.stack || error.message)}
@@ -2427,6 +2482,28 @@ const MANDATORY_CSV_SETTINGS = Object.freeze({
2427
2482
  // encoding: 'utf-8',
2428
2483
  });
2429
2484
 
2485
+ /**
2486
+ * Function to check if a string is valid CSV
2487
+ *
2488
+ * @param value The string to check
2489
+ * @returns True if the string is a valid CSV string, false otherwise
2490
+ *
2491
+ * @public exported from `@promptbook/utils`
2492
+ */
2493
+ function isValidCsvString(value) {
2494
+ try {
2495
+ // A simple check for CSV format: at least one comma and no invalid characters
2496
+ if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
2497
+ return true;
2498
+ }
2499
+ return false;
2500
+ }
2501
+ catch (error) {
2502
+ assertsError(error);
2503
+ return false;
2504
+ }
2505
+ }
2506
+
2430
2507
  /**
2431
2508
  * Definition for CSV spreadsheet
2432
2509
  *
@@ -2437,7 +2514,7 @@ const CsvFormatDefinition = {
2437
2514
  formatName: 'CSV',
2438
2515
  aliases: ['SPREADSHEET', 'TABLE'],
2439
2516
  isValid(value, settings, schema) {
2440
- return true;
2517
+ return isValidCsvString(value);
2441
2518
  },
2442
2519
  canBeValid(partialValue, settings, schema) {
2443
2520
  return true;
@@ -2591,6 +2668,30 @@ const TextFormatDefinition = {
2591
2668
  * TODO: [๐Ÿข] Allow to expect something inside each item of list and other formats
2592
2669
  */
2593
2670
 
2671
+ /**
2672
+ * Function to check if a string is valid XML
2673
+ *
2674
+ * @param value
2675
+ * @returns True if the string is a valid XML string, false otherwise
2676
+ *
2677
+ * @public exported from `@promptbook/utils`
2678
+ */
2679
+ function isValidXmlString(value) {
2680
+ try {
2681
+ const parser = new DOMParser();
2682
+ const parsedDocument = parser.parseFromString(value, 'application/xml');
2683
+ const parserError = parsedDocument.getElementsByTagName('parsererror');
2684
+ if (parserError.length > 0) {
2685
+ return false;
2686
+ }
2687
+ return true;
2688
+ }
2689
+ catch (error) {
2690
+ assertsError(error);
2691
+ return false;
2692
+ }
2693
+ }
2694
+
2594
2695
  /**
2595
2696
  * Definition for XML format
2596
2697
  *
@@ -2600,7 +2701,7 @@ const XmlFormatDefinition = {
2600
2701
  formatName: 'XML',
2601
2702
  mimeType: 'application/xml',
2602
2703
  isValid(value, settings, schema) {
2603
- return true;
2704
+ return isValidXmlString(value);
2604
2705
  },
2605
2706
  canBeValid(partialValue, settings, schema) {
2606
2707
  return true;
@@ -2797,14 +2898,15 @@ class MultipleLlmExecutionTools {
2797
2898
  }
2798
2899
  }
2799
2900
  catch (error) {
2800
- if (!(error instanceof Error) || error instanceof UnexpectedError) {
2901
+ assertsError(error);
2902
+ if (error instanceof UnexpectedError) {
2801
2903
  throw error;
2802
2904
  }
2803
2905
  errors.push({ llmExecutionTools, error });
2804
2906
  }
2805
2907
  }
2806
2908
  if (errors.length === 1) {
2807
- throw errors[0];
2909
+ throw errors[0].error;
2808
2910
  }
2809
2911
  else if (errors.length > 1) {
2810
2912
  throw new PipelineExecutionError(
@@ -3661,9 +3763,7 @@ async function executeAttempts(options) {
3661
3763
  break scripts;
3662
3764
  }
3663
3765
  catch (error) {
3664
- if (!(error instanceof Error)) {
3665
- throw error;
3666
- }
3766
+ assertsError(error);
3667
3767
  if (error instanceof UnexpectedError) {
3668
3768
  throw error;
3669
3769
  }
@@ -3733,9 +3833,7 @@ async function executeAttempts(options) {
3733
3833
  break scripts;
3734
3834
  }
3735
3835
  catch (error) {
3736
- if (!(error instanceof Error)) {
3737
- throw error;
3738
- }
3836
+ assertsError(error);
3739
3837
  if (error instanceof UnexpectedError) {
3740
3838
  throw error;
3741
3839
  }
@@ -4356,9 +4454,7 @@ async function executePipeline(options) {
4356
4454
  await Promise.all(resolving);
4357
4455
  }
4358
4456
  catch (error /* <- Note: [3] */) {
4359
- if (!(error instanceof Error)) {
4360
- throw error;
4361
- }
4457
+ assertsError(error);
4362
4458
  // Note: No need to rethrow UnexpectedError
4363
4459
  // if (error instanceof UnexpectedError) {
4364
4460
  // Note: Count usage, [๐Ÿง ] Maybe put to separate function executionReportJsonToUsage + DRY [๐Ÿคนโ€โ™‚๏ธ]
@@ -5068,9 +5164,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
5068
5164
  return await fetch(urlOrRequest, init);
5069
5165
  }
5070
5166
  catch (error) {
5071
- if (!(error instanceof Error)) {
5072
- throw error;
5073
- }
5167
+ assertsError(error);
5074
5168
  let url;
5075
5169
  if (typeof urlOrRequest === 'string') {
5076
5170
  url = urlOrRequest;
@@ -5301,9 +5395,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
5301
5395
  knowledgePreparedUnflatten[index] = pieces;
5302
5396
  }
5303
5397
  catch (error) {
5304
- if (!(error instanceof Error)) {
5305
- throw error;
5306
- }
5398
+ assertsError(error);
5307
5399
  console.warn(error);
5308
5400
  // <- TODO: [๐Ÿฎ] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
5309
5401
  }
@@ -6101,6 +6193,8 @@ function parseNumber(value) {
6101
6193
  */
6102
6194
 
6103
6195
  /**
6196
+ import { WrappedError } from '../../errors/WrappedError';
6197
+ import { assertsError } from '../../errors/assertsError';
6104
6198
  * Parses the expect command
6105
6199
  *
6106
6200
  * @see `documentationUrl` for more details
@@ -6192,9 +6286,7 @@ const expectCommandParser = {
6192
6286
  };
6193
6287
  }
6194
6288
  catch (error) {
6195
- if (!(error instanceof Error)) {
6196
- throw error;
6197
- }
6289
+ assertsError(error);
6198
6290
  throw new ParseError(spaceTrim((block) => `
6199
6291
  Invalid FORMAT command
6200
6292
  ${block(error.message)}:
@@ -9175,9 +9267,7 @@ async function locateAppOnLinux({ linuxWhich, }) {
9175
9267
  return result.trim();
9176
9268
  }
9177
9269
  catch (error) {
9178
- if (!(error instanceof Error)) {
9179
- throw error;
9180
- }
9270
+ assertsError(error);
9181
9271
  return null;
9182
9272
  }
9183
9273
  }
@@ -9255,9 +9345,7 @@ async function locateAppOnMacOs({ macOsName, }) {
9255
9345
  return result.trim() + toExec;
9256
9346
  }
9257
9347
  catch (error) {
9258
- if (!(error instanceof Error)) {
9259
- throw error;
9260
- }
9348
+ assertsError(error);
9261
9349
  return null;
9262
9350
  }
9263
9351
  }
@@ -9288,9 +9376,7 @@ async function locateAppOnWindows({ appName, windowsSuffix, }) {
9288
9376
  throw new Error(`Can not locate app ${appName} on Windows.`);
9289
9377
  }
9290
9378
  catch (error) {
9291
- if (!(error instanceof Error)) {
9292
- throw error;
9293
- }
9379
+ assertsError(error);
9294
9380
  return null;
9295
9381
  }
9296
9382
  }
@@ -9581,13 +9667,13 @@ function $registeredLlmToolsMessage() {
9581
9667
  /**
9582
9668
  * Provides the path to the `.env` file
9583
9669
  *
9584
- * Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
9670
+ * Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access `.env` file
9585
9671
  *
9586
9672
  * @private within the repository - for CLI utils
9587
9673
  */
9588
- async function $provideEnvFilepath() {
9674
+ async function $provideEnvFilename() {
9589
9675
  if (!$isRunningInNode()) {
9590
- throw new EnvironmentMismatchError('Function `$provideEnvFilepath` works only in Node.js environment');
9676
+ throw new EnvironmentMismatchError('Function `$provideEnvFilename` works only in Node.js environment');
9591
9677
  }
9592
9678
  const envFilePatterns = [
9593
9679
  '.env',
@@ -9626,7 +9712,7 @@ async function $provideEnvFilepath() {
9626
9712
  * @@@
9627
9713
  *
9628
9714
  * @@@ .env
9629
- * Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
9715
+ * Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access `.env` file
9630
9716
  *
9631
9717
  * It looks for environment variables:
9632
9718
  * - `process.env.OPENAI_API_KEY`
@@ -9640,7 +9726,7 @@ async function $provideLlmToolsConfigurationFromEnv() {
9640
9726
  if (!$isRunningInNode()) {
9641
9727
  throw new EnvironmentMismatchError('Function `$provideLlmToolsFromEnv` works only in Node.js environment');
9642
9728
  }
9643
- const envFilepath = await $provideEnvFilepath();
9729
+ const envFilepath = await $provideEnvFilename();
9644
9730
  if (envFilepath !== null) {
9645
9731
  dotenv.config({ path: envFilepath });
9646
9732
  }
@@ -9711,7 +9797,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
9711
9797
  * Note: This function is not cached, every call creates new instance of `MultipleLlmExecutionTools`
9712
9798
  *
9713
9799
  * @@@ .env
9714
- * Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
9800
+ * Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access `.env` file
9715
9801
  *
9716
9802
  * It looks for environment variables:
9717
9803
  * - `process.env.OPENAI_API_KEY`
@@ -10245,9 +10331,7 @@ class JavascriptEvalExecutionTools {
10245
10331
  }
10246
10332
  }
10247
10333
  catch (error) {
10248
- if (!(error instanceof Error)) {
10249
- throw error;
10250
- }
10334
+ assertsError(error);
10251
10335
  if (error instanceof ReferenceError) {
10252
10336
  const undefinedName = error.message.split(' ')[0];
10253
10337
  /*
@@ -10522,9 +10606,7 @@ async function createCollectionFromDirectory(rootPath, tools, options) {
10522
10606
  // ---
10523
10607
  }
10524
10608
  catch (error) {
10525
- if (!(error instanceof Error)) {
10526
- throw error;
10527
- }
10609
+ assertsError(error);
10528
10610
  // TODO: [7] DRY
10529
10611
  const wrappedErrorMessage = spaceTrim((block) => `
10530
10612
  ${error.name} in pipeline ${fileName.split('\\').join('/')}โ :
@@ -10615,9 +10697,7 @@ async function createCollectionFromDirectory(rootPath, tools, options) {
10615
10697
  }
10616
10698
  }
10617
10699
  catch (error) {
10618
- if (!(error instanceof Error)) {
10619
- throw error;
10620
- }
10700
+ assertsError(error);
10621
10701
  // TODO: [7] DRY
10622
10702
  const wrappedErrorMessage = spaceTrim((block) => `
10623
10703
  ${error.name} in pipeline ${fileName.split('\\').join('/')}โ :