@promptbook/core 0.72.0-15 → 0.72.0-23

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 (29) hide show
  1. package/esm/index.es.js +36 -63
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/cli.index.d.ts +0 -4
  4. package/esm/typings/src/_packages/core.index.d.ts +0 -2
  5. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  7. package/esm/typings/src/{scrapers/_common/register → executables}/$provideExecutablesForNode.d.ts +3 -3
  8. package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
  9. package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
  10. package/esm/typings/src/executables/locateApp.d.ts +33 -0
  11. package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
  12. package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
  13. package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
  14. package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
  15. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +0 -1
  16. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -4
  17. package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
  18. package/package.json +1 -1
  19. package/umd/index.umd.js +35 -63
  20. package/umd/index.umd.js.map +1 -1
  21. package/esm/typings/src/_packages/website-crawler.index.d.ts +0 -8
  22. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +0 -50
  23. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +0 -20
  24. package/esm/typings/src/scrapers/website/playground/website-scraper-playground.d.ts +0 -5
  25. package/esm/typings/src/scrapers/website/register-constructor.d.ts +0 -13
  26. package/esm/typings/src/scrapers/website/register-metadata.d.ts +0 -24
  27. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +0 -7
  28. /package/esm/typings/src/{scrapers/website/WebsiteScraper.test.d.ts → executables/apps/locateLibreoffice.test.d.ts} +0 -0
  29. /package/esm/typings/src/{scrapers/website/utils/createShowdownConverter.test.d.ts → executables/apps/locatePandoc.test.d.ts} +0 -0
@@ -16,8 +16,6 @@ import { _MarkdownScraperRegistration } from '../scrapers/markdown/register-cons
16
16
  import { _MarkdownScraperMetadataRegistration } from '../scrapers/markdown/register-metadata';
17
17
  import { _PdfScraperRegistration } from '../scrapers/pdf/register-constructor';
18
18
  import { _PdfScraperMetadataRegistration } from '../scrapers/pdf/register-metadata';
19
- import { _WebsiteScraperRegistration } from '../scrapers/website/register-constructor';
20
- import { _WebsiteScraperMetadataRegistration } from '../scrapers/website/register-metadata';
21
19
  export { PROMPTBOOK_VERSION };
22
20
  export { _CLI };
23
21
  export { _AnthropicClaudeMetadataRegistration };
@@ -36,5 +34,3 @@ export { _MarkdownScraperRegistration };
36
34
  export { _MarkdownScraperMetadataRegistration };
37
35
  export { _PdfScraperRegistration };
38
36
  export { _PdfScraperMetadataRegistration };
39
- export { _WebsiteScraperRegistration };
40
- export { _WebsiteScraperMetadataRegistration };
@@ -83,7 +83,6 @@ import { _LegacyDocumentScraperMetadataRegistration } from '../scrapers/document
83
83
  import { _DocumentScraperMetadataRegistration } from '../scrapers/document/register-metadata';
84
84
  import { _MarkdownScraperMetadataRegistration } from '../scrapers/markdown/register-metadata';
85
85
  import { _PdfScraperMetadataRegistration } from '../scrapers/pdf/register-metadata';
86
- import { _WebsiteScraperMetadataRegistration } from '../scrapers/website/register-metadata';
87
86
  import { MemoryStorage } from '../storage/memory/MemoryStorage';
88
87
  import { PrefixStorage } from '../storage/memory/utils/PrefixStorage';
89
88
  import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
@@ -176,7 +175,6 @@ export { _LegacyDocumentScraperMetadataRegistration };
176
175
  export { _DocumentScraperMetadataRegistration };
177
176
  export { _MarkdownScraperMetadataRegistration };
178
177
  export { _PdfScraperMetadataRegistration };
179
- export { _WebsiteScraperMetadataRegistration };
180
178
  export { MemoryStorage };
181
179
  export { PrefixStorage };
182
180
  export { executionReportJsonToString };
@@ -1,9 +1,9 @@
1
1
  import { PROMPTBOOK_VERSION } from '../version';
2
2
  import { createCollectionFromDirectory } from '../collection/constructors/createCollectionFromDirectory';
3
+ import { $provideExecutablesForNode } from '../executables/$provideExecutablesForNode';
3
4
  import { $provideExecutionToolsForNode } from '../execution/utils/$provideExecutionToolsForNode';
4
5
  import { $provideLlmToolsConfigurationFromEnv } from '../llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv';
5
6
  import { $provideLlmToolsFromEnv } from '../llm-providers/_common/register/$provideLlmToolsFromEnv';
6
- import { $provideExecutablesForNode } from '../scrapers/_common/register/$provideExecutablesForNode';
7
7
  import { $provideFilesystemForNode } from '../scrapers/_common/register/$provideFilesystemForNode';
8
8
  import { $provideScrapersForNode } from '../scrapers/_common/register/$provideScrapersForNode';
9
9
  import { FileCacheStorage } from '../storage/file-cache-storage/FileCacheStorage';
@@ -11,10 +11,10 @@ import { $execCommand } from '../utils/execCommand/$execCommand';
11
11
  import { $execCommands } from '../utils/execCommand/$execCommands';
12
12
  export { PROMPTBOOK_VERSION };
13
13
  export { createCollectionFromDirectory };
14
+ export { $provideExecutablesForNode };
14
15
  export { $provideExecutionToolsForNode };
15
16
  export { $provideLlmToolsConfigurationFromEnv };
16
17
  export { $provideLlmToolsFromEnv };
17
- export { $provideExecutablesForNode };
18
18
  export { $provideFilesystemForNode };
19
19
  export { $provideScrapersForNode };
20
20
  export { FileCacheStorage };
@@ -14,6 +14,7 @@ import type { PrettifyOptions } from '../conversion/prettify/PrettifyOptions';
14
14
  import type { renderPipelineMermaidOptions } from '../conversion/prettify/renderPipelineMermaidOptions';
15
15
  import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
16
16
  import type { ErrorJson } from '../errors/utils/ErrorJson';
17
+ import type { LocateAppOptions } from '../executables/locateApp';
17
18
  import type { AvailableModel } from '../execution/AvailableModel';
18
19
  import type { CommonToolsOptions } from '../execution/CommonToolsOptions';
19
20
  import type { CreatePipelineExecutorOptions } from '../execution/createPipelineExecutor/00-CreatePipelineExecutorOptions';
@@ -257,6 +258,7 @@ export type { PrettifyOptions };
257
258
  export type { renderPipelineMermaidOptions };
258
259
  export type { CallbackInterfaceToolsOptions };
259
260
  export type { ErrorJson };
261
+ export type { LocateAppOptions };
260
262
  export type { AvailableModel };
261
263
  export type { CommonToolsOptions };
262
264
  export type { CreatePipelineExecutorOptions };
@@ -1,5 +1,5 @@
1
- import type { Executables } from '../../../execution/Executables';
2
- import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeOptions';
1
+ import type { Executables } from '../execution/Executables';
2
+ import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
3
3
  /**
4
4
  * @@@
5
5
  *
@@ -7,6 +7,6 @@ import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeO
7
7
  */
8
8
  export declare function $provideExecutablesForNode(options?: PrepareAndScrapeOptions): Promise<Executables>;
9
9
  /**
10
- * TODO: [🧠] THis should be maybe in different folder
10
+ * TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
11
11
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
12
12
  */
@@ -0,0 +1,11 @@
1
+ import type { string_executable_path } from '../../types/typeAliases';
2
+ /**
3
+ * @@@
4
+ *
5
+ * @private within the repository
6
+ */
7
+ export declare function locateLibreoffice(): Promise<string_executable_path>;
8
+ /**
9
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
10
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
11
+ */
@@ -0,0 +1,11 @@
1
+ import type { string_executable_path } from '../../types/typeAliases';
2
+ /**
3
+ * @@@
4
+ *
5
+ * @private within the repository
6
+ */
7
+ export declare function locatePandoc(): Promise<string_executable_path>;
8
+ /**
9
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
10
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
11
+ */
@@ -0,0 +1,33 @@
1
+ import type { RequireAtLeastOne } from 'type-fest';
2
+ import type { string_executable_path } from '../types/typeAliases';
3
+ /**
4
+ * Options for locating any application
5
+ */
6
+ export interface LocateAppOptions {
7
+ /**
8
+ * Name of the application
9
+ */
10
+ appName: string;
11
+ /**
12
+ * Name of the executable on Linux
13
+ */
14
+ linuxWhich?: string;
15
+ /**
16
+ * Path suffix on Windows
17
+ */
18
+ windowsSuffix?: string;
19
+ /**
20
+ * Name of the application on macOS
21
+ */
22
+ macOsName?: string;
23
+ }
24
+ /**
25
+ * Locates an application on the system
26
+ *
27
+ * @private within the repository
28
+ */
29
+ export declare function locateApp(options: RequireAtLeastOne<LocateAppOptions, 'linuxWhich' | 'windowsSuffix' | 'macOsName'>): Promise<string_executable_path>;
30
+ /**
31
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node`
32
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
33
+ */
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { LocateAppOptions } from '../locateApp';
2
+ import type { string_executable_path } from '../../types/typeAliases';
3
+ /**
4
+ * @@@
5
+ *
6
+ * @private within the repository
7
+ */
8
+ export declare function locateAppOnLinux({ appName, linuxWhich, }: Pick<Required<LocateAppOptions>, 'appName' | 'linuxWhich'>): Promise<string_executable_path>;
9
+ /**
10
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node`
11
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
12
+ */
@@ -0,0 +1,12 @@
1
+ import type { string_executable_path } from '../../types/typeAliases';
2
+ import type { LocateAppOptions } from '../locateApp';
3
+ /**
4
+ * @@@
5
+ *
6
+ * @private within the repository
7
+ */
8
+ export declare function locateAppOnMacOs({ appName, macOsName, }: Pick<Required<LocateAppOptions>, 'appName' | 'macOsName'>): Promise<string_executable_path>;
9
+ /**
10
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node`
11
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
12
+ */
@@ -0,0 +1,12 @@
1
+ import type { string_executable_path } from '../../types/typeAliases';
2
+ import type { LocateAppOptions } from '../locateApp';
3
+ /**
4
+ * @@@
5
+ *
6
+ * @private within the repository
7
+ */
8
+ export declare function locateAppOnWindows({ appName, windowsSuffix, }: Pick<Required<LocateAppOptions>, 'appName' | 'windowsSuffix'>): Promise<string_executable_path>;
9
+ /**
10
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node`
11
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
12
+ */
@@ -29,7 +29,6 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
29
29
  callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
30
30
  }
31
31
  /**
32
- * TODO: !!!!!! DO not use colors - can be used in browser
33
32
  * TODO: [🧠][🧙‍♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
34
33
  * TODO: Maybe make custom OpenAiError
35
34
  * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
@@ -51,12 +51,9 @@ export type ScraperSourceHandler = {
51
51
  * Get the content as a utf-8 string
52
52
  */
53
53
  asText(): Promisable<string>;
54
- /**
55
- * Get the content as a blob
56
- */
57
- asBlob(): Promisable<Blob>;
58
54
  };
59
55
  /**
56
+ * TODO: [🥽] Add ` asBlob(): Promisable<Blob>;` or asFile
60
57
  * TODO: [🐝] @@@ Annotate all
61
58
  * TODO: [🔼] Export via types
62
59
  */
@@ -0,0 +1,11 @@
1
+ import type { FilesystemTools } from '../../execution/FilesystemTools';
2
+ /**
3
+ * Checks if the file is executable
4
+ *
5
+ * @private within the repository
6
+ */
7
+ export declare function isExecutable(path: string, fs: FilesystemTools): Promise<boolean>;
8
+ /**
9
+ * Note: Not [~🟢~] because it is not directly dependent on `fs
10
+ * TODO: [🖇] What about symlinks?
11
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.72.0-15",
3
+ "version": "0.72.0-23",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -16,7 +16,7 @@
16
16
  /**
17
17
  * The version of the Promptbook library
18
18
  */
19
- var PROMPTBOOK_VERSION = '0.72.0-14';
19
+ var PROMPTBOOK_VERSION = '0.72.0-22';
20
20
  // TODO: [main] !!!! List here all the versions and annotate + put into script
21
21
 
22
22
  /*! *****************************************************************************
@@ -5095,7 +5095,6 @@
5095
5095
  * TODO: [®] DRY Register logic
5096
5096
  */
5097
5097
 
5098
- // TODO: !!!!!!last - Maybe delete this function
5099
5098
  /**
5100
5099
  * Creates a message with all registered scrapers
5101
5100
  *
@@ -5368,7 +5367,7 @@
5368
5367
  return __awaiter(this, void 0, void 0, function () {
5369
5368
  var sourceContent, name, _b, _c, rootDirname, _d,
5370
5369
  // <- TODO: process.cwd() if running in Node.js
5371
- isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType_1;
5370
+ isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
5372
5371
  return __generator(this, function (_e) {
5373
5372
  switch (_e.label) {
5374
5373
  case 0:
@@ -5390,19 +5389,14 @@
5390
5389
  filename: null,
5391
5390
  url: url,
5392
5391
  mimeType: mimeType,
5393
- asBlob: function () {
5394
- return __awaiter(this, void 0, void 0, function () {
5395
- var content;
5396
- return __generator(this, function (_a) {
5397
- switch (_a.label) {
5398
- case 0: return [4 /*yield*/, response_1.blob()];
5399
- case 1:
5400
- content = _a.sent();
5401
- return [2 /*return*/, content];
5402
- }
5403
- });
5404
- });
5405
- },
5392
+ /*
5393
+ TODO: [🥽]
5394
+ > async asBlob() {
5395
+ > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
5396
+ > const content = await response.blob();
5397
+ > return content;
5398
+ > },
5399
+ */
5406
5400
  asJson: function () {
5407
5401
  return __awaiter(this, void 0, void 0, function () {
5408
5402
  var content;
@@ -5442,34 +5436,31 @@
5442
5436
  }
5443
5437
  filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
5444
5438
  fileExtension = getFileExtension(filename_1);
5445
- mimeType_1 = extensionToMimeType(fileExtension || '');
5439
+ mimeType = extensionToMimeType(fileExtension || '');
5446
5440
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
5447
5441
  case 3:
5448
5442
  if (!(_e.sent())) {
5449
5443
  throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
5450
5444
  }
5451
- // TODO: !!!!!! Test security file - file is scoped to the project (maybe do this in `filesystemTools`)
5445
+ // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
5452
5446
  return [2 /*return*/, {
5453
5447
  source: name,
5454
5448
  filename: filename_1,
5455
5449
  url: null,
5456
- mimeType: mimeType_1,
5457
- asBlob: function () {
5458
- return __awaiter(this, void 0, void 0, function () {
5459
- var content;
5460
- return __generator(this, function (_a) {
5461
- switch (_a.label) {
5462
- case 0: return [4 /*yield*/, tools.fs.readFile(filename_1)];
5463
- case 1:
5464
- content = _a.sent();
5465
- return [2 /*return*/, new Blob([
5466
- content,
5467
- // <- TODO: !!!!!! Test that this is working
5468
- ], { type: mimeType_1 })];
5469
- }
5470
- });
5471
- });
5472
- },
5450
+ mimeType: mimeType,
5451
+ /*
5452
+ TODO: [🥽]
5453
+ > async asBlob() {
5454
+ > const content = await tools.fs!.readFile(filename);
5455
+ > return new Blob(
5456
+ > [
5457
+ > content,
5458
+ > // <- TODO: [🥽] This is NOT tested, test it
5459
+ > ],
5460
+ > { type: mimeType },
5461
+ > );
5462
+ > },
5463
+ */
5473
5464
  asJson: function () {
5474
5465
  return __awaiter(this, void 0, void 0, function () {
5475
5466
  var _a, _b;
@@ -5505,9 +5496,14 @@
5505
5496
  asJson: function () {
5506
5497
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
5507
5498
  },
5508
- asBlob: function () {
5509
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
5510
- },
5499
+ /*
5500
+ TODO: [🥽]
5501
+ > asBlob() {
5502
+ > throw new UnexpectedError(
5503
+ > 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
5504
+ > );
5505
+ > },
5506
+ */
5511
5507
  }];
5512
5508
  }
5513
5509
  });
@@ -5832,6 +5828,7 @@
5832
5828
  'KNOWLEDGE ./hejny-cv.md',
5833
5829
  'KNOWLEDGE ./hejny-cv.pdf',
5834
5830
  'KNOWLEDGE ./hejny-cv.docx',
5831
+ // <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
5835
5832
  ],
5836
5833
  /**
5837
5834
  * Parses the KNOWLEDGE command
@@ -9475,30 +9472,6 @@
9475
9472
  */
9476
9473
  var _PdfScraperMetadataRegistration = $scrapersMetadataRegister.register(pdfScraperMetadata);
9477
9474
 
9478
- /**
9479
- * Metadata of the scraper
9480
- *
9481
- * @private within the scraper directory
9482
- */
9483
- var websiteScraperMetadata = $deepFreeze({
9484
- title: 'Website scraper',
9485
- packageName: '@promptbook/website-crawler',
9486
- className: 'WebsiteScraper',
9487
- mimeTypes: ['text/html'],
9488
- documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
9489
- isAvilableInBrowser: false,
9490
- requiredExecutables: [],
9491
- }); /* <- TODO: [🤛] */
9492
- /**
9493
- * Registration of known scraper metadata
9494
- *
9495
- * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
9496
- *
9497
- * @public exported from `@promptbook/core`
9498
- * @public exported from `@promptbook/cli`
9499
- */
9500
- var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
9501
-
9502
9475
  /**
9503
9476
  * This class behaves like LocalStorage but separates keys by prefix
9504
9477
  *
@@ -9907,7 +9880,6 @@
9907
9880
  exports._OpenAiAssistantMetadataRegistration = _OpenAiAssistantMetadataRegistration;
9908
9881
  exports._OpenAiMetadataRegistration = _OpenAiMetadataRegistration;
9909
9882
  exports._PdfScraperMetadataRegistration = _PdfScraperMetadataRegistration;
9910
- exports._WebsiteScraperMetadataRegistration = _WebsiteScraperMetadataRegistration;
9911
9883
  exports.addUsage = addUsage;
9912
9884
  exports.assertsExecutionSuccessful = assertsExecutionSuccessful;
9913
9885
  exports.cacheLlmTools = cacheLlmTools;