@promptbook/remote-server 0.72.0-7 → 0.72.0-9

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 (118) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +111 -13
  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/cli.index.d.ts +20 -0
  6. package/esm/typings/src/_packages/core.index.d.ts +20 -16
  7. package/esm/typings/src/_packages/documents.index.d.ts +8 -0
  8. package/esm/typings/src/_packages/legacy-documents.index.d.ts +8 -0
  9. package/esm/typings/src/_packages/markdown-utils.index.d.ts +6 -0
  10. package/esm/typings/src/_packages/node.index.d.ts +10 -4
  11. package/esm/typings/src/_packages/pdf.index.d.ts +8 -0
  12. package/esm/typings/src/_packages/types.index.d.ts +15 -5
  13. package/esm/typings/src/_packages/website-crawler.index.d.ts +8 -0
  14. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +5 -3
  15. package/esm/typings/src/config.d.ts +6 -0
  16. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +3 -1
  17. package/esm/typings/src/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +2 -2
  18. package/esm/typings/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -3
  19. package/esm/typings/src/execution/{CommonExecutionToolsOptions.d.ts → CommonToolsOptions.d.ts} +1 -1
  20. package/esm/typings/src/execution/ExecutionTools.d.ts +26 -6
  21. package/esm/typings/src/execution/FilesystemTools.d.ts +9 -0
  22. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +1 -1
  23. package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +1 -6
  24. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -6
  25. package/esm/typings/src/execution/translation/automatic-translate/translateMessages.d.ts +1 -0
  26. package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +13 -0
  27. package/esm/typings/src/llm-providers/_common/{$llmToolsMetadataRegister.d.ts → register/$llmToolsMetadataRegister.d.ts} +4 -1
  28. package/esm/typings/src/llm-providers/_common/{$llmToolsRegister.d.ts → register/$llmToolsRegister.d.ts} +5 -2
  29. package/esm/typings/src/llm-providers/_common/{createLlmToolsFromConfigurationFromEnv.d.ts → register/$provideLlmToolsConfigurationFromEnv.d.ts} +3 -3
  30. package/esm/typings/src/llm-providers/_common/{getLlmToolsForCli.d.ts → register/$provideLlmToolsForCli.d.ts} +4 -11
  31. package/esm/typings/src/llm-providers/_common/{getLlmToolsForTestingAndScriptsAndPlayground.d.ts → register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts} +4 -3
  32. package/esm/typings/src/llm-providers/_common/{createLlmToolsFromEnv.d.ts → register/$provideLlmToolsFromEnv.d.ts} +6 -5
  33. package/esm/typings/src/llm-providers/_common/{$registeredLlmToolsMessage.d.ts → register/$registeredLlmToolsMessage.d.ts} +5 -2
  34. package/esm/typings/src/llm-providers/_common/{LlmToolsConfiguration.d.ts → register/LlmToolsConfiguration.d.ts} +5 -4
  35. package/esm/typings/src/llm-providers/_common/{LlmToolsMetadata.d.ts → register/LlmToolsMetadata.d.ts} +5 -4
  36. package/esm/typings/src/llm-providers/_common/{LlmToolsOptions.d.ts → register/LlmToolsOptions.d.ts} +4 -1
  37. package/esm/typings/src/llm-providers/_common/{createLlmToolsFromConfiguration.d.ts → register/createLlmToolsFromConfiguration.d.ts} +5 -4
  38. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +3 -3
  39. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +4 -3
  40. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +4 -3
  41. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -2
  42. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +4 -3
  43. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +4 -3
  44. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +3 -3
  45. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +3 -3
  46. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +1 -0
  47. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
  48. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +5 -4
  49. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +5 -4
  50. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +1 -1
  51. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +1 -1
  52. package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +3 -3
  53. package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +2 -2
  54. package/esm/typings/src/personas/preparePersona.d.ts +2 -1
  55. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +8 -7
  56. package/esm/typings/src/prepare/preparePipeline.d.ts +2 -1
  57. package/esm/typings/src/prepare/prepareTemplates.d.ts +2 -1
  58. package/esm/typings/src/scrapers/_common/Converter.d.ts +4 -10
  59. package/esm/typings/src/scrapers/_common/Scraper.d.ts +4 -9
  60. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +2 -1
  61. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +11 -0
  62. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +12 -0
  63. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +15 -0
  64. package/esm/typings/src/scrapers/_common/register/$registeredScrapersMessage.d.ts +12 -0
  65. package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +13 -0
  66. package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +13 -0
  67. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +41 -0
  68. package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +12 -0
  69. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +1 -0
  70. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +2 -1
  71. package/esm/typings/src/scrapers/document/{documentScraper.d.ts → DocumentScraper.d.ts} +18 -12
  72. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +20 -0
  73. package/esm/typings/src/scrapers/document/register-constructor.d.ts +13 -0
  74. package/esm/typings/src/scrapers/document/register-metadata.d.ts +24 -0
  75. package/esm/typings/src/scrapers/document-legacy/{legacyDocumentScraper.d.ts → LegacyDocumentScraper.d.ts} +18 -12
  76. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +20 -0
  77. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +13 -0
  78. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +24 -0
  79. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +29 -0
  80. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +20 -0
  81. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +13 -0
  82. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +24 -0
  83. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +40 -0
  84. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +20 -0
  85. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +13 -0
  86. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +24 -0
  87. package/esm/typings/src/scrapers/website/{websiteScraper.d.ts → WebsiteScraper.d.ts} +18 -14
  88. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +20 -0
  89. package/esm/typings/src/scrapers/website/register-constructor.d.ts +13 -0
  90. package/esm/typings/src/scrapers/website/register-metadata.d.ts +24 -0
  91. package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
  92. package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +3 -3
  93. package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +3 -3
  94. package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +5 -3
  95. package/esm/typings/src/storage/{utils → memory/utils}/PrefixStorage.d.ts +1 -1
  96. package/esm/typings/src/storage/{utils → memory/utils}/makePromptbookStorageFromWebStorage.d.ts +1 -1
  97. package/esm/typings/src/types/typeAliases.d.ts +7 -0
  98. package/esm/typings/src/utils/$Register.d.ts +19 -6
  99. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +1 -1
  100. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -1
  101. package/esm/typings/src/utils/files/isDirectoryExisting.d.ts +14 -0
  102. package/esm/typings/src/utils/files/isFileExisting.d.ts +13 -0
  103. package/esm/typings/src/utils/files/{$listAllFiles.d.ts → listAllFiles.d.ts} +3 -4
  104. package/package.json +2 -2
  105. package/umd/index.umd.js +111 -13
  106. package/umd/index.umd.js.map +1 -1
  107. package/esm/typings/src/scrapers/index.d.ts +0 -7
  108. package/esm/typings/src/scrapers/markdown/markdownScraper.d.ts +0 -29
  109. package/esm/typings/src/scrapers/pdf/pdfScraper.d.ts +0 -35
  110. package/esm/typings/src/utils/files/$isDirectoryExisting.d.ts +0 -15
  111. package/esm/typings/src/utils/files/$isFileExisting.d.ts +0 -14
  112. /package/esm/typings/src/scrapers/document/{documentScraper.test.d.ts → DocumentScraper.test.d.ts} +0 -0
  113. /package/esm/typings/src/scrapers/document-legacy/{legacyDocumentScraper.test.d.ts → LegacyDocumentScraper.test.d.ts} +0 -0
  114. /package/esm/typings/src/scrapers/markdown/{markdownScraper.test.d.ts → MarkdownScraper.test.d.ts} +0 -0
  115. /package/esm/typings/src/scrapers/website/{websiteScraper.test.d.ts → WebsiteScraper.test.d.ts} +0 -0
  116. /package/esm/typings/src/utils/files/{$isDirectoryExisting.test.d.ts → isDirectoryExisting.test.d.ts} +0 -0
  117. /package/esm/typings/src/utils/files/{$isFileExisting.test.d.ts → isFileExisting.test.d.ts} +0 -0
  118. /package/esm/typings/src/utils/files/{$listAllFiles.test.d.ts → listAllFiles.test.d.ts} +0 -0
@@ -0,0 +1,8 @@
1
+ import { PROMPTBOOK_VERSION } from '../version';
2
+ import { createPdfScraper } from '../scrapers/pdf/createPdfScraper';
3
+ import { PdfScraper } from '../scrapers/pdf/PdfScraper';
4
+ import { _PdfScraperRegistration } from '../scrapers/pdf/register-constructor';
5
+ export { PROMPTBOOK_VERSION };
6
+ export { createPdfScraper };
7
+ export { PdfScraper };
8
+ export { _PdfScraperRegistration };
@@ -15,11 +15,12 @@ import type { renderPipelineMermaidOptions } from '../conversion/prettify/render
15
15
  import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
16
16
  import type { ErrorJson } from '../errors/utils/ErrorJson';
17
17
  import type { AvailableModel } from '../execution/AvailableModel';
18
- import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
18
+ import type { CommonToolsOptions } from '../execution/CommonToolsOptions';
19
19
  import type { CreatePipelineExecutorOptions } from '../execution/createPipelineExecutor/00-CreatePipelineExecutorOptions';
20
20
  import type { CreatePipelineExecutorSettings } from '../execution/createPipelineExecutor/00-CreatePipelineExecutorSettings';
21
21
  import type { EmbeddingVector } from '../execution/EmbeddingVector';
22
22
  import type { ExecutionTools } from '../execution/ExecutionTools';
23
+ import type { FilesystemTools } from '../execution/FilesystemTools';
23
24
  import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
24
25
  import type { LlmExecutionToolsConstructor } from '../execution/LlmExecutionToolsConstructor';
25
26
  import type { PipelineExecutor } from '../execution/PipelineExecutor';
@@ -37,9 +38,9 @@ import type { UserInterfaceTools } from '../execution/UserInterfaceTools';
37
38
  import type { UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
38
39
  import type { FormatSubvalueDefinition } from '../formats/_common/FormatSubvalueDefinition';
39
40
  import type { CsvSettings } from '../formats/csv/CsvSettings';
40
- import type { LlmToolsConfiguration } from '../llm-providers/_common/LlmToolsConfiguration';
41
- import type { LlmToolsMetadata } from '../llm-providers/_common/LlmToolsMetadata';
42
- import type { LlmToolsOptions } from '../llm-providers/_common/LlmToolsOptions';
41
+ import type { LlmToolsConfiguration } from '../llm-providers/_common/register/LlmToolsConfiguration';
42
+ import type { LlmToolsMetadata } from '../llm-providers/_common/register/LlmToolsMetadata';
43
+ import type { LlmToolsOptions } from '../llm-providers/_common/register/LlmToolsOptions';
43
44
  import type { CacheItem } from '../llm-providers/_common/utils/cache/CacheItem';
44
45
  import type { CacheLlmToolsOptions } from '../llm-providers/_common/utils/cache/CacheLlmToolsOptions';
45
46
  import type { LlmExecutionToolsWithTotalUsage } from '../llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
@@ -67,6 +68,8 @@ import type { AnonymousRemoteServerOptions } from '../llm-providers/remote/inter
67
68
  import type { CollectionRemoteServerOptions } from '../llm-providers/remote/interfaces/RemoteServerOptions';
68
69
  import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
69
70
  import type { Converter } from '../scrapers/_common/Converter';
71
+ import type { ScraperAndConverterMetadata } from '../scrapers/_common/register/ScraperAndConverterMetadata';
72
+ import type { ScraperConstructor } from '../scrapers/_common/register/ScraperConstructor';
70
73
  import type { Scraper } from '../scrapers/_common/Scraper';
71
74
  import type { ScraperSourceHandler } from '../scrapers/_common/Scraper';
72
75
  import type { ScraperIntermediateSource } from '../scrapers/_common/ScraperIntermediateSource';
@@ -156,6 +159,7 @@ import type { string_data_url } from '../types/typeAliases';
156
159
  import type { string_base64 } from '../types/typeAliases';
157
160
  import type { string_href } from '../types/typeAliases';
158
161
  import type { string_url_image } from '../types/typeAliases';
162
+ import type { string_executable_path } from '../types/typeAliases';
159
163
  import type { string_uri } from '../types/typeAliases';
160
164
  import type { string_uri_part } from '../types/typeAliases';
161
165
  import type { string_uriid } from '../types/typeAliases';
@@ -218,6 +222,7 @@ import type { number_megabytes } from '../types/typeAliases';
218
222
  import type { number_gigabytes } from '../types/typeAliases';
219
223
  import type { number_terabytes } from '../types/typeAliases';
220
224
  import type { Registered } from '../utils/$Register';
225
+ import type { Registration } from '../utils/$Register';
221
226
  import type { IExecCommandOptions } from '../utils/execCommand/IExecCommandOptions';
222
227
  import type { IExecCommandOptionsAdvanced } from '../utils/execCommand/IExecCommandOptions';
223
228
  import type { FromtoItems } from '../utils/FromtoItems';
@@ -251,11 +256,12 @@ export type { renderPipelineMermaidOptions };
251
256
  export type { CallbackInterfaceToolsOptions };
252
257
  export type { ErrorJson };
253
258
  export type { AvailableModel };
254
- export type { CommonExecutionToolsOptions };
259
+ export type { CommonToolsOptions };
255
260
  export type { CreatePipelineExecutorOptions };
256
261
  export type { CreatePipelineExecutorSettings };
257
262
  export type { EmbeddingVector };
258
263
  export type { ExecutionTools };
264
+ export type { FilesystemTools };
259
265
  export type { LlmExecutionTools };
260
266
  export type { LlmExecutionToolsConstructor };
261
267
  export type { PipelineExecutor };
@@ -303,6 +309,8 @@ export type { AnonymousRemoteServerOptions };
303
309
  export type { CollectionRemoteServerOptions };
304
310
  export type { PrepareAndScrapeOptions };
305
311
  export type { Converter };
312
+ export type { ScraperAndConverterMetadata };
313
+ export type { ScraperConstructor };
306
314
  export type { Scraper };
307
315
  export type { ScraperSourceHandler };
308
316
  export type { ScraperIntermediateSource };
@@ -392,6 +400,7 @@ export type { string_data_url };
392
400
  export type { string_base64 };
393
401
  export type { string_href };
394
402
  export type { string_url_image };
403
+ export type { string_executable_path };
395
404
  export type { string_uri };
396
405
  export type { string_uri_part };
397
406
  export type { string_uriid };
@@ -454,6 +463,7 @@ export type { number_megabytes };
454
463
  export type { number_gigabytes };
455
464
  export type { number_terabytes };
456
465
  export type { Registered };
466
+ export type { Registration };
457
467
  export type { IExecCommandOptions };
458
468
  export type { IExecCommandOptionsAdvanced };
459
469
  export type { FromtoItems };
@@ -0,0 +1,8 @@
1
+ import { PROMPTBOOK_VERSION } from '../version';
2
+ import { createWebsiteScraper } from '../scrapers/website/createWebsiteScraper';
3
+ import { _WebsiteScraperRegistration } from '../scrapers/website/register-constructor';
4
+ import { WebsiteScraper } from '../scrapers/website/WebsiteScraper';
5
+ export { PROMPTBOOK_VERSION };
6
+ export { createWebsiteScraper };
7
+ export { _WebsiteScraperRegistration };
8
+ export { WebsiteScraper };
@@ -1,3 +1,4 @@
1
+ import type { ExecutionTools } from '../../execution/ExecutionTools';
1
2
  import type { PrepareAndScrapeOptions } from '../../prepare/PrepareAndScrapeOptions';
2
3
  import type { string_dirname } from '../../types/typeAliases';
3
4
  import type { PipelineCollection } from '../PipelineCollection';
@@ -40,13 +41,14 @@ type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions
40
41
  * Note: Works only in Node.js environment because it reads the file system
41
42
  *
42
43
  * @param path - path to the directory with pipelines
43
- * @param options - Misc options for the collection
44
+ * @param tools - Execution tools to be used for pipeline preparation if needed - If not provided, `$provideExecutionToolsForNode` will be used
45
+ * @param options - Options for the collection creation
44
46
  * @returns PipelineCollection
45
47
  * @public exported from `@promptbook/node`
46
48
  */
47
- export declare function createCollectionFromDirectory(path: string_dirname, options?: CreatePipelineCollectionFromDirectoryOptions): Promise<PipelineCollection>;
49
+ export declare function createCollectionFromDirectory(path: string_dirname, tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options?: CreatePipelineCollectionFromDirectoryOptions): Promise<PipelineCollection>;
48
50
  export {};
49
51
  /**
50
- * Note: [🟢] Code in this file should never be published outside of `@promptbook/node` and `@promptbook/cli`
51
52
  * TODO: [🖇] What about symlinks? Maybe option isSymlinksFollowed
53
+ * TODO: Maybe move from `@promptbook/node` to `@promptbook/core` as we removes direct dependency on `fs`
52
54
  */
@@ -160,6 +160,12 @@ export declare const DEFAULT_CSV_SETTINGS: CsvSettings;
160
160
  * @public exported from `@promptbook/core`
161
161
  */
162
162
  export declare const IS_VERBOSE = false;
163
+ /**
164
+ * @@@
165
+ *
166
+ * @public exported from `@promptbook/core`
167
+ */
168
+ export declare const IS_AUTO_INSTALLED = false;
163
169
  /**
164
170
  * @@@
165
171
  *
@@ -1,3 +1,4 @@
1
+ import type { ExecutionTools } from '../execution/ExecutionTools';
1
2
  import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
2
3
  import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
3
4
  import type { PipelineString } from '../types/PipelineString';
@@ -13,12 +14,13 @@ import type { PipelineString } from '../types/PipelineString';
13
14
  * Note: This function acts as compilation process
14
15
  *
15
16
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
17
+ * @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
16
18
  * @param options - Options and tools for the compilation
17
19
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
18
20
  * @throws {ParseError} if the promptbook string is not valid
19
21
  * @public exported from `@promptbook/core`
20
22
  */
21
- export declare function pipelineStringToJson(pipelineString: PipelineString, options?: PrepareAndScrapeOptions): Promise<PipelineJson>;
23
+ export declare function pipelineStringToJson(pipelineString: PipelineString, tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options?: PrepareAndScrapeOptions): Promise<PipelineJson>;
22
24
  /**
23
25
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
24
26
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
@@ -1,12 +1,12 @@
1
1
  import type { Promisable } from 'type-fest';
2
- import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
2
+ import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
3
  import type { UserInterfaceToolsPromptDialogOptions } from '../../execution/UserInterfaceTools';
4
4
  /**
5
5
  * Options for `CallbackInterfaceTools`
6
6
  *
7
7
  * @public exported from `@promptbook/core`
8
8
  */
9
- export type CallbackInterfaceToolsOptions = CommonExecutionToolsOptions & {
9
+ export type CallbackInterfaceToolsOptions = CommonToolsOptions & {
10
10
  /**
11
11
  * The callback function to be called when promptDialog is called
12
12
  */
@@ -1,4 +1,4 @@
1
- import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
1
+ import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
2
2
  import type { UserInterfaceTools } from '../../execution/UserInterfaceTools';
3
3
  import type { UserInterfaceToolsPromptDialogOptions } from '../../execution/UserInterfaceTools';
4
4
  /**
@@ -10,8 +10,8 @@ import type { UserInterfaceToolsPromptDialogOptions } from '../../execution/User
10
10
  * @public exported from `@promptbook/browser`
11
11
  */
12
12
  export declare class SimplePromptInterfaceTools implements UserInterfaceTools {
13
- protected readonly options: CommonExecutionToolsOptions;
14
- constructor(options?: CommonExecutionToolsOptions);
13
+ protected readonly options: CommonToolsOptions;
14
+ constructor(options?: CommonToolsOptions);
15
15
  /**
16
16
  * Trigger window.DIALOG TEMPLATE
17
17
  */
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Note: Keep it public to allow people to make their own execution tools
5
5
  */
6
- export type CommonExecutionToolsOptions = {
6
+ export type CommonToolsOptions = {
7
7
  /**
8
8
  * If true, the internal executions will be logged
9
9
  */
@@ -1,4 +1,6 @@
1
+ import type { Scraper } from '../scrapers/_common/Scraper';
1
2
  import type { Arrayable } from '../types/Arrayable';
3
+ import type { FilesystemTools } from './FilesystemTools';
2
4
  import type { LlmExecutionTools } from './LlmExecutionTools';
3
5
  import type { ScriptExecutionTools } from './ScriptExecutionTools';
4
6
  import type { UserInterfaceTools } from './UserInterfaceTools';
@@ -9,20 +11,36 @@ import type { UserInterfaceTools } from './UserInterfaceTools';
9
11
  */
10
12
  export type ExecutionTools = {
11
13
  /**
12
- * Tools for executing prompts to large language models like GPT-4
14
+ * Tools for executing prompts in large language models
13
15
  *
14
- * Tip: Use `createLlmToolsFromEnv()` to use all available LLM providers you configured
15
- * @see https://github.com/webgptorg/promptbook/?tab=readme-ov-file#llm-execution-tools
16
+ * Tip: Use `$provideLlmToolsFromEnv` to use all available LLM providers you configured
17
+ *
18
+ * @default [] - If not provided, no LLM execution will be possible - it does not make sense in most cases
16
19
  */
17
20
  readonly llm?: Arrayable<LlmExecutionTools>;
21
+ /**
22
+ * Tools for filesystem operations
23
+ *
24
+ * Tip: Use `$provideFilesystemForNode` to use filesystem in Node.js
25
+ *
26
+ * @default undefined - If not provided, no filesystem operations will be possible
27
+ */
28
+ readonly fs?: FilesystemTools;
29
+ /**
30
+ * Scrapers for extracting knowledge from external sources
31
+ *
32
+ * Tip: Use `$provideScrapersForNode` OR `$provideScrapersForBrowser` to use all available scrapers
33
+ *
34
+ * @default [] - If not provided, no external knowledge extraction will be possible
35
+ */
36
+ readonly scrapers?: Arrayable<Scraper>;
18
37
  /**
19
38
  * Tools for executing scripts
20
39
  *
21
40
  * Note: You can pass multiple ScriptExecutionTools, they will be tried one by one until one of them supports the script
22
41
  * If none of them supports the script, an error is thrown
23
- * Tip: Use here `new JavascriptExecutionTools()`
42
+ * Tip: Use here `new JavascriptExecutionTools`
24
43
  *
25
- * @see https://github.com/webgptorg/promptbook/?tab=readme-ov-file#script-execution-tools
26
44
  * @default [] - If not provided, no script execution will be possible
27
45
  */
28
46
  readonly script?: Arrayable<ScriptExecutionTools>;
@@ -30,7 +48,9 @@ export type ExecutionTools = {
30
48
  * Tools for interacting with the user
31
49
  *
32
50
  * Note: When undefined, the user interface is disabled and promptbook which requires user interaction will fail
33
- * @see https://github.com/webgptorg/promptbook/?tab=readme-ov-file#user-interface-tools
34
51
  */
35
52
  readonly userInterface?: UserInterfaceTools;
36
53
  };
54
+ /**
55
+ * TODO: !!!!!! Move here also the executables and make $provideXxxxForNode
56
+ */
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ import type fs from 'fs/promises';
3
+ /**
4
+ * Container for all the tools needed to manipulate with filesystem
5
+ */
6
+ export type FilesystemTools = Pick<typeof fs, 'access' | 'constants' | 'readFile' | 'stat' | 'readdir'>;
7
+ /**
8
+ * TODO: Implement destroyable pattern to free resources
9
+ */
@@ -8,7 +8,7 @@ import type { CreatePipelineExecutorSettings } from './00-CreatePipelineExecutor
8
8
  /**
9
9
  * @@@
10
10
  *
11
- * @private internal type of `executePipelinex`
11
+ * @private internal type of `executePipeline`
12
12
  */
13
13
  type ExecutePipelineOptions = {
14
14
  /**
@@ -1,5 +1,4 @@
1
1
  import { Promisable, ReadonlyDeep } from 'type-fest';
2
- import { MultipleLlmExecutionTools } from '../../llm-providers/multiple/MultipleLlmExecutionTools';
3
2
  import type { ExecutionReportJson } from '../../types/execution-report/ExecutionReportJson';
4
3
  import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
5
4
  import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
@@ -28,11 +27,7 @@ type executeSingleTemplateOptions = {
28
27
  /**
29
28
  * @@@
30
29
  */
31
- readonly tools: Omit<ExecutionTools, 'llm'>;
32
- /**
33
- * @@@
34
- */
35
- readonly llmTools: MultipleLlmExecutionTools;
30
+ readonly tools: ExecutionTools;
36
31
  /**
37
32
  * @@@
38
33
  */
@@ -1,5 +1,4 @@
1
1
  import type { ReadonlyDeep } from 'type-fest';
2
- import { MultipleLlmExecutionTools } from '../../llm-providers/multiple/MultipleLlmExecutionTools';
3
2
  import type { ExecutionReportJson } from '../../types/execution-report/ExecutionReportJson';
4
3
  import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
5
4
  import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
@@ -45,11 +44,7 @@ export type ExecuteAttemptsOptions = {
45
44
  /**
46
45
  * @@@
47
46
  */
48
- readonly tools: Omit<ExecutionTools, 'llm'>;
49
- /**
50
- * @@@
51
- */
52
- readonly llmTools: MultipleLlmExecutionTools;
47
+ readonly tools: ExecutionTools;
53
48
  /**
54
49
  * Settings for the pipeline executor
55
50
  */
@@ -8,4 +8,5 @@ export declare function translateMessages({ automaticTranslator, from, to, }: {
8
8
  } & TranslatorOptions): Promise<void>;
9
9
  /**
10
10
  * TODO: [😶] Unite floder listing
11
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
11
12
  */
@@ -0,0 +1,13 @@
1
+ import type { PrepareAndScrapeOptions } from '../../prepare/PrepareAndScrapeOptions';
2
+ import type { ExecutionTools } from '../ExecutionTools';
3
+ /**
4
+ * Note: There is unfortunately no equivalent for this function in the browser environment
5
+ * because it is not possible automatically detect configured LLM providers
6
+ * you need to provide them manually BUT you can help by utilities like `$provideScrapersForBrowser`
7
+ *
8
+ * @public exported from `@promptbook/node`
9
+ */
10
+ export declare function $provideExecutionToolsForNode(options?: PrepareAndScrapeOptions): Promise<ExecutionTools>;
11
+ /**
12
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
13
+ */
@@ -1,4 +1,4 @@
1
- import { $Register } from '../../utils/$Register';
1
+ import { $Register } from '../../../utils/$Register';
2
2
  import type { LlmToolsMetadata } from './LlmToolsMetadata';
3
3
  /**
4
4
  * @@@
@@ -8,3 +8,6 @@ import type { LlmToolsMetadata } from './LlmToolsMetadata';
8
8
  * @public exported from `@promptbook/core`
9
9
  */
10
10
  export declare const $llmToolsMetadataRegister: $Register<LlmToolsMetadata>;
11
+ /**
12
+ * TODO: [®] DRY Register logic
13
+ */
@@ -1,5 +1,5 @@
1
- import type { LlmExecutionToolsConstructor } from '../../execution/LlmExecutionToolsConstructor';
2
- import { $Register } from '../../utils/$Register';
1
+ import type { LlmExecutionToolsConstructor } from '../../../execution/LlmExecutionToolsConstructor';
2
+ import { $Register } from '../../../utils/$Register';
3
3
  /**
4
4
  * @@@
5
5
  *
@@ -8,3 +8,6 @@ import { $Register } from '../../utils/$Register';
8
8
  * @public exported from `@promptbook/core`
9
9
  */
10
10
  export declare const $llmToolsRegister: $Register<LlmExecutionToolsConstructor>;
11
+ /**
12
+ * TODO: [®] DRY Register logic
13
+ */
@@ -11,14 +11,14 @@ import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
11
11
  * @returns @@@
12
12
  * @public exported from `@promptbook/node`
13
13
  */
14
- export declare function createLlmToolsFromConfigurationFromEnv(): LlmToolsConfiguration;
14
+ export declare function $provideLlmToolsConfigurationFromEnv(): LlmToolsConfiguration;
15
15
  /**
16
16
  * TODO: [🧠][🪁] Maybe do allow to do auto-install if package not registered and not found
17
17
  * TODO: Add Azure OpenAI
18
18
  * TODO: [🧠][🍛]
19
19
  * TODO: [🧠] Is there some meaningfull way how to test this util
20
- * Note: [🟢] Code in this file should never be published outside of `@promptbook/node` and `@promptbook/cli`
20
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
21
21
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
22
22
  * TODO: This should be maybe not under `_common` but under `utils`
23
23
  * TODO: [🧠] Maybe pass env as argument
24
- */
24
+ * TODO: [®] DRY Register logic */
@@ -1,22 +1,15 @@
1
- import type { LlmExecutionToolsWithTotalUsage } from './utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
2
- type GetLlmToolsForCliOptions = {
3
- /**
4
- * @@@
5
- *
6
- * @default false
7
- */
8
- isCacheReloaded?: boolean;
9
- };
1
+ import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeOptions';
2
+ import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
10
3
  /**
11
4
  * Returns LLM tools for CLI
12
5
  *
13
6
  * @private within the repository - for CLI utils
14
7
  */
15
- export declare function getLlmToolsForCli(options?: GetLlmToolsForCliOptions): LlmExecutionToolsWithTotalUsage;
16
- export {};
8
+ export declare function $provideLlmToolsForCli(options?: Pick<PrepareAndScrapeOptions, 'isCacheCleaned'>): LlmExecutionToolsWithTotalUsage;
17
9
  /**
18
10
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
19
11
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
20
12
  * TODO: [🥃] Allow `ptbk make` without llm tools
21
13
  * TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
14
+ * TODO: [®] DRY Register logic
22
15
  */
@@ -1,6 +1,6 @@
1
- import '../../_packages/cli.index';
1
+ import '../../../_packages/cli.index';
2
+ import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
2
3
  import type { CreateLlmToolsFromConfigurationOptions } from './createLlmToolsFromConfiguration';
3
- import type { LlmExecutionToolsWithTotalUsage } from './utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
4
4
  type GetLlmToolsForTestingAndScriptsAndPlaygroundOptions = CreateLlmToolsFromConfigurationOptions & {
5
5
  /**
6
6
  * @@@
@@ -14,10 +14,11 @@ type GetLlmToolsForTestingAndScriptsAndPlaygroundOptions = CreateLlmToolsFromCon
14
14
  *
15
15
  * @private within the repository - JUST FOR TESTS, SCRIPTS AND PLAYGROUND
16
16
  */
17
- export declare function getLlmToolsForTestingAndScriptsAndPlayground(options?: GetLlmToolsForTestingAndScriptsAndPlaygroundOptions): LlmExecutionToolsWithTotalUsage;
17
+ export declare function $provideLlmToolsForTestingAndScriptsAndPlayground(options?: GetLlmToolsForTestingAndScriptsAndPlaygroundOptions): LlmExecutionToolsWithTotalUsage;
18
18
  export {};
19
19
  /**
20
20
  * Note: [⚪] This should never be in any released package
21
21
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
22
22
  * TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
23
+ * TODO: [®] DRY Register logic
23
24
  */
@@ -1,4 +1,4 @@
1
- import { MultipleLlmExecutionTools } from '../multiple/MultipleLlmExecutionTools';
1
+ import { MultipleLlmExecutionTools } from '../../multiple/MultipleLlmExecutionTools';
2
2
  import type { CreateLlmToolsFromConfigurationOptions } from './createLlmToolsFromConfiguration';
3
3
  /**
4
4
  * @@@
@@ -14,12 +14,13 @@ import type { CreateLlmToolsFromConfigurationOptions } from './createLlmToolsFro
14
14
  * @returns @@@
15
15
  * @public exported from `@promptbook/node`
16
16
  */
17
- export declare function createLlmToolsFromEnv(options?: CreateLlmToolsFromConfigurationOptions): MultipleLlmExecutionTools;
17
+ export declare function $provideLlmToolsFromEnv(options?: CreateLlmToolsFromConfigurationOptions): MultipleLlmExecutionTools;
18
18
  /**
19
- * TODO: @@@ write `createLlmToolsFromEnv` vs `createLlmToolsFromConfigurationFromEnv` vs `createLlmToolsFromConfiguration`
20
- * TODO: [🧠][🍛] Which name is better `createLlmToolsFromEnv` or `createLlmToolsFromEnvironment`?
19
+ * TODO: @@@ write `$provideLlmToolsFromEnv` vs `$provideLlmToolsConfigurationFromEnv` vs `createLlmToolsFromConfiguration`
20
+ * TODO: [🧠][🍛] Which name is better `$provideLlmToolsFromEnv` or `$provideLlmToolsFromEnvironment`?
21
21
  * TODO: [🧠] Is there some meaningfull way how to test this util
22
- * Note: [🟢] Code in this file should never be published outside of `@promptbook/node` and `@promptbook/cli`
22
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
23
23
  * TODO: [🥃] Allow `ptbk make` without llm tools
24
24
  * TODO: This should be maybe not under `_common` but under `utils`
25
+ * TODO: [®] DRY Register logic
25
26
  */
@@ -1,9 +1,12 @@
1
- import type { string_markdown } from '../../types/typeAliases';
1
+ import type { string_markdown } from '../../../types/typeAliases';
2
2
  /**
3
3
  * Creates a message with all registered LLM tools
4
4
  *
5
5
  * Note: This function is used to create a (error) message when there is no constructor for some LLM provider
6
6
  *
7
- * @private internal function of `createLlmToolsFromConfiguration` and `createLlmToolsFromEnv`
7
+ * @private internal function of `createLlmToolsFromConfiguration` and `$provideLlmToolsFromEnv`
8
8
  */
9
9
  export declare function $registeredLlmToolsMessage(): string_markdown;
10
+ /**
11
+ * TODO: [®] DRY Register logic
12
+ */
@@ -1,5 +1,5 @@
1
- import type { string_title } from '../../types/typeAliases';
2
- import type { Registered } from '../../utils/$Register';
1
+ import type { string_title } from '../../../types/typeAliases';
2
+ import type { Registered } from '../../../utils/$Register';
3
3
  import type { LlmToolsOptions } from './LlmToolsOptions';
4
4
  /**
5
5
  * @@@
@@ -10,13 +10,14 @@ export type LlmToolsConfiguration = Array<Registered & {
10
10
  /**
11
11
  * @@@
12
12
  */
13
- title: string_title;
13
+ readonly title: string_title;
14
14
  /**
15
15
  * @@@
16
16
  */
17
- options: LlmToolsOptions;
17
+ readonly options: LlmToolsOptions;
18
18
  }>;
19
19
  /**
20
20
  * TODO: [🧠][🌰] `title` is redundant BUT maybe allow each provider pass it's own title for tracking purposes
21
21
  * TODO: Maybe instead of `LlmToolsConfiguration[number]` make `LlmToolsConfigurationItem`
22
+ * TODO: [®] DRY Register logic
22
23
  */
@@ -1,6 +1,6 @@
1
- import type { string_name } from '../../types/typeAliases';
2
- import type { string_title } from '../../types/typeAliases';
3
- import type { Registered } from '../../utils/$Register';
1
+ import type { string_name } from '../../../types/typeAliases';
2
+ import type { string_title } from '../../../types/typeAliases';
3
+ import type { Registered } from '../../../utils/$Register';
4
4
  import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
5
5
  /**
6
6
  * @@@
@@ -11,7 +11,7 @@ export type LlmToolsMetadata = Registered & {
11
11
  /**
12
12
  * @@@
13
13
  */
14
- title: string_title;
14
+ readonly title: string_title;
15
15
  /**
16
16
  * @@@
17
17
  */
@@ -24,4 +24,5 @@ export type LlmToolsMetadata = Registered & {
24
24
  /**
25
25
  * TODO: Add configuration schema and maybe some documentation link
26
26
  * TODO: Maybe constrain LlmToolsConfiguration[number] by generic to ensure that `createConfigurationFromEnv` and `getBoilerplateConfiguration` always create same `packageName` and `className`
27
+ * TODO: [®] DRY Register logic
27
28
  */
@@ -1,7 +1,10 @@
1
- import type { TODO_object } from '../../utils/organization/TODO_object';
1
+ import type { TODO_object } from '../../../utils/organization/TODO_object';
2
2
  /**
3
3
  * @@@
4
4
  *
5
5
  * @@@ `LlmToolsMetadata` vs `LlmToolsConfiguration` vs `LlmToolsOptions` (vs `Registered`)
6
6
  */
7
7
  export type LlmToolsOptions = TODO_object;
8
+ /**
9
+ * TODO: [®] DRY Register logic
10
+ */
@@ -1,9 +1,9 @@
1
- import { MultipleLlmExecutionTools } from '../multiple/MultipleLlmExecutionTools';
1
+ import { MultipleLlmExecutionTools } from '../../multiple/MultipleLlmExecutionTools';
2
2
  import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
3
3
  /**
4
- * Options for `createLlmToolsFromEnv`
4
+ * Options for `$provideLlmToolsFromEnv`
5
5
  *
6
- * @private internal type for `createLlmToolsFromEnv` and `getLlmToolsForTestingAndScriptsAndPlayground`
6
+ * @private internal type for `$provideLlmToolsFromEnv` and `$provideLlmToolsForTestingAndScriptsAndPlayground`
7
7
  */
8
8
  export type CreateLlmToolsFromConfigurationOptions = {
9
9
  /**
@@ -23,10 +23,11 @@ export type CreateLlmToolsFromConfigurationOptions = {
23
23
  */
24
24
  export declare function createLlmToolsFromConfiguration(configuration: LlmToolsConfiguration, options?: CreateLlmToolsFromConfigurationOptions): MultipleLlmExecutionTools;
25
25
  /**
26
- * TODO: [🎌] Togethere with `createLlmToolsFromConfiguration` + 'EXECUTION_TOOLS_CLASSES' gets to `@promptbook/core` ALL model providers, make this more efficient
26
+ * TODO: [🎌] Together with `createLlmToolsFromConfiguration` + 'EXECUTION_TOOLS_CLASSES' gets to `@promptbook/core` ALL model providers, make this more efficient
27
27
  * TODO: [🧠][🎌] Dynamically install required providers
28
28
  * TODO: @@@ write discussion about this - wizzard
29
29
  * TODO: [🧠][🍛] Which name is better `createLlmToolsFromConfig` or `createLlmToolsFromConfiguration`?
30
30
  * TODO: [🧠] Is there some meaningfull way how to test this util
31
31
  * TODO: This should be maybe not under `_common` but under `utils`
32
+ * TODO: [®] DRY Register logic
32
33
  */
@@ -1,5 +1,5 @@
1
1
  import type { ClientOptions } from '@anthropic-ai/sdk';
2
- import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
2
+ import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
3
  import type { RemoteLlmExecutionToolsOptions } from '../remote/interfaces/RemoteLlmExecutionToolsOptions';
4
4
  /**
5
5
  * Options for `AnthropicClaudeExecutionTools`
@@ -14,7 +14,7 @@ export type AnthropicClaudeExecutionToolsOptions = AnthropicClaudeExecutionTools
14
14
  * This extends Anthropic's `ClientOptions` with are directly passed to the Anthropic client.
15
15
  * @public exported from `@promptbook/anthropic-claude`
16
16
  */
17
- export type AnthropicClaudeExecutionToolsDirectOptions = CommonExecutionToolsOptions & ClientOptions & {
17
+ export type AnthropicClaudeExecutionToolsDirectOptions = CommonToolsOptions & ClientOptions & {
18
18
  isProxied?: false;
19
19
  };
20
20
  /**
@@ -23,7 +23,7 @@ export type AnthropicClaudeExecutionToolsDirectOptions = CommonExecutionToolsOpt
23
23
  * This extends Anthropic's `ClientOptions` with are directly passed to the Anthropic client.
24
24
  * @public exported from `@promptbook/anthropic-claude`
25
25
  */
26
- export type AnthropicClaudeExecutionToolsProxiedOptions = CommonExecutionToolsOptions & ClientOptions & {
26
+ export type AnthropicClaudeExecutionToolsProxiedOptions = CommonToolsOptions & ClientOptions & {
27
27
  isProxied: true;
28
28
  } & Pick<RemoteLlmExecutionToolsOptions, 'remoteUrl' | 'path'>;
29
29
  /**
@@ -1,9 +1,10 @@
1
+ import type { Registration } from '../../utils/$Register';
1
2
  /**
2
- * @@@ registration1 of default configuration for Anthropic Claude
3
+ * Registration of LLM provider metadata
3
4
  *
4
- * Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
5
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
5
6
  *
6
7
  * @public exported from `@promptbook/core`
7
8
  * @public exported from `@promptbook/cli`
8
9
  */
9
- export declare const _AnthropicClaudeMetadataRegistration: void;
10
+ export declare const _AnthropicClaudeMetadataRegistration: Registration;