@promptbook/legacy-documents 0.72.0-15 → 0.72.0-26

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 (22) hide show
  1. package/esm/index.es.js +50 -44
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  4. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  5. package/esm/typings/src/{scrapers/_common/register → executables}/$provideExecutablesForNode.d.ts +3 -3
  6. package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
  7. package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
  8. package/esm/typings/src/executables/locateApp.d.ts +33 -0
  9. package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
  10. package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
  11. package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
  12. package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
  13. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +0 -1
  14. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -4
  15. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +0 -4
  16. package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
  17. package/package.json +2 -2
  18. package/umd/index.umd.js +50 -44
  19. package/umd/index.umd.js.map +1 -1
  20. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +0 -7
  21. /package/esm/typings/src/{scrapers/website/WebsiteScraper.test.d.ts → executables/apps/locateLibreoffice.test.d.ts} +0 -0
  22. /package/esm/typings/src/{scrapers/website/utils/createShowdownConverter.test.d.ts → executables/apps/locatePandoc.test.d.ts} +0 -0
@@ -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
  */
@@ -24,10 +24,6 @@ export declare class WebsiteScraper implements Converter, Scraper {
24
24
  * Markdown scraper is used internally
25
25
  */
26
26
  private readonly markdownScraper;
27
- /**
28
- * Showdown converter is used internally
29
- */
30
- private readonly showdownConverter;
31
27
  constructor(tools: Pick<ExecutionTools, 'fs' | 'llm'>, options: PrepareAndScrapeOptions);
32
28
  /**
33
29
  * Convert the website to `.md` file and returns intermediate source
@@ -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/legacy-documents",
3
- "version": "0.72.0-15",
3
+ "version": "0.72.0-26",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -52,7 +52,7 @@
52
52
  "module": "./esm/index.es.js",
53
53
  "typings": "./esm/typings/src/_packages/legacy-documents.index.d.ts",
54
54
  "peerDependencies": {
55
- "@promptbook/core": "0.72.0-15"
55
+ "@promptbook/core": "0.72.0-26"
56
56
  },
57
57
  "dependencies": {
58
58
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -15,7 +15,7 @@
15
15
  /**
16
16
  * The version of the Promptbook library
17
17
  */
18
- var PROMPTBOOK_VERSION = '0.72.0-14';
18
+ var PROMPTBOOK_VERSION = '0.72.0-25';
19
19
  // TODO: [main] !!!! List here all the versions and annotate + put into script
20
20
 
21
21
  /*! *****************************************************************************
@@ -3126,7 +3126,6 @@
3126
3126
  * TODO: [®] DRY Register logic
3127
3127
  */
3128
3128
 
3129
- // TODO: !!!!!!last - Maybe delete this function
3130
3129
  /**
3131
3130
  * Creates a message with all registered scrapers
3132
3131
  *
@@ -3268,7 +3267,7 @@
3268
3267
  return __awaiter(this, void 0, void 0, function () {
3269
3268
  var sourceContent, name, _b, _c, rootDirname, _d,
3270
3269
  // <- TODO: process.cwd() if running in Node.js
3271
- isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType_1;
3270
+ isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
3272
3271
  return __generator(this, function (_e) {
3273
3272
  switch (_e.label) {
3274
3273
  case 0:
@@ -3290,19 +3289,14 @@
3290
3289
  filename: null,
3291
3290
  url: url,
3292
3291
  mimeType: mimeType,
3293
- asBlob: function () {
3294
- return __awaiter(this, void 0, void 0, function () {
3295
- var content;
3296
- return __generator(this, function (_a) {
3297
- switch (_a.label) {
3298
- case 0: return [4 /*yield*/, response_1.blob()];
3299
- case 1:
3300
- content = _a.sent();
3301
- return [2 /*return*/, content];
3302
- }
3303
- });
3304
- });
3305
- },
3292
+ /*
3293
+ TODO: [🥽]
3294
+ > async asBlob() {
3295
+ > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
3296
+ > const content = await response.blob();
3297
+ > return content;
3298
+ > },
3299
+ */
3306
3300
  asJson: function () {
3307
3301
  return __awaiter(this, void 0, void 0, function () {
3308
3302
  var content;
@@ -3342,34 +3336,31 @@
3342
3336
  }
3343
3337
  filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
3344
3338
  fileExtension = getFileExtension(filename_1);
3345
- mimeType_1 = extensionToMimeType(fileExtension || '');
3339
+ mimeType = extensionToMimeType(fileExtension || '');
3346
3340
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
3347
3341
  case 3:
3348
3342
  if (!(_e.sent())) {
3349
3343
  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 "); }));
3350
3344
  }
3351
- // TODO: !!!!!! Test security file - file is scoped to the project (maybe do this in `filesystemTools`)
3345
+ // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
3352
3346
  return [2 /*return*/, {
3353
3347
  source: name,
3354
3348
  filename: filename_1,
3355
3349
  url: null,
3356
- mimeType: mimeType_1,
3357
- asBlob: function () {
3358
- return __awaiter(this, void 0, void 0, function () {
3359
- var content;
3360
- return __generator(this, function (_a) {
3361
- switch (_a.label) {
3362
- case 0: return [4 /*yield*/, tools.fs.readFile(filename_1)];
3363
- case 1:
3364
- content = _a.sent();
3365
- return [2 /*return*/, new Blob([
3366
- content,
3367
- // <- TODO: !!!!!! Test that this is working
3368
- ], { type: mimeType_1 })];
3369
- }
3370
- });
3371
- });
3372
- },
3350
+ mimeType: mimeType,
3351
+ /*
3352
+ TODO: [🥽]
3353
+ > async asBlob() {
3354
+ > const content = await tools.fs!.readFile(filename);
3355
+ > return new Blob(
3356
+ > [
3357
+ > content,
3358
+ > // <- TODO: [🥽] This is NOT tested, test it
3359
+ > ],
3360
+ > { type: mimeType },
3361
+ > );
3362
+ > },
3363
+ */
3373
3364
  asJson: function () {
3374
3365
  return __awaiter(this, void 0, void 0, function () {
3375
3366
  var _a, _b;
@@ -3405,9 +3396,14 @@
3405
3396
  asJson: function () {
3406
3397
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
3407
3398
  },
3408
- asBlob: function () {
3409
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
3410
- },
3399
+ /*
3400
+ TODO: [🥽]
3401
+ > asBlob() {
3402
+ > throw new UnexpectedError(
3403
+ > 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
3404
+ > );
3405
+ > },
3406
+ */
3411
3407
  }];
3412
3408
  }
3413
3409
  });
@@ -6062,9 +6058,14 @@
6062
6058
  asJson: function () {
6063
6059
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
6064
6060
  },
6065
- asBlob: function () {
6066
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
6067
- },
6061
+ /*
6062
+ TODO: [🥽]
6063
+ > asBlob() {
6064
+ > throw new UnexpectedError(
6065
+ > 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
6066
+ > );
6067
+ > },
6068
+ */
6068
6069
  };
6069
6070
  knowledge = this.markdownScraper.scrape(markdownSource);
6070
6071
  return [4 /*yield*/, cacheFilehandler.destroy()];
@@ -6230,9 +6231,14 @@
6230
6231
  asJson: function () {
6231
6232
  throw new UnexpectedError('Did not expect that `documentScraper` would need to get the content `asJson`');
6232
6233
  },
6233
- asBlob: function () {
6234
- throw new UnexpectedError('Did not expect that `documentScraper` would need to get the content `asBlob`');
6235
- },
6234
+ /*
6235
+ TODO: [🥽]
6236
+ > asBlob() {
6237
+ > throw new UnexpectedError(
6238
+ > 'Did not expect that `documentScraper` would need to get the content `asBlob`',
6239
+ > );
6240
+ > },
6241
+ */
6236
6242
  };
6237
6243
  knowledge = this.documentScraper.scrape(markdownSource);
6238
6244
  return [4 /*yield*/, cacheFilehandler.destroy()];