@promptbook/node 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.
- package/esm/index.es.js +332 -90
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +0 -4
- package/esm/typings/src/_packages/core.index.d.ts +0 -2
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/{scrapers/_common/register → executables}/$provideExecutablesForNode.d.ts +3 -3
- package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
- package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
- package/esm/typings/src/executables/locateApp.d.ts +33 -0
- package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
- package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
- package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +0 -1
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -4
- package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
- package/package.json +2 -2
- package/umd/index.umd.js +334 -93
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/_packages/website-crawler.index.d.ts +0 -8
- package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +0 -50
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +0 -20
- package/esm/typings/src/scrapers/website/playground/website-scraper-playground.d.ts +0 -5
- package/esm/typings/src/scrapers/website/register-constructor.d.ts +0 -13
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +0 -24
- package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +0 -7
- /package/esm/typings/src/{scrapers/website/WebsiteScraper.test.d.ts → executables/apps/locateLibreoffice.test.d.ts} +0 -0
- /package/esm/typings/src/{scrapers/website/utils/createShowdownConverter.test.d.ts → executables/apps/locatePandoc.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -9,15 +9,16 @@ import { unparse, parse } from 'papaparse';
|
|
|
9
9
|
import { SHA256 } from 'crypto-js';
|
|
10
10
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
11
11
|
import { lookup } from 'mime-types';
|
|
12
|
+
import { exec as exec$2, spawn } from 'child_process';
|
|
13
|
+
import { promisify } from 'util';
|
|
12
14
|
import * as dotenv from 'dotenv';
|
|
13
15
|
import sha256 from 'crypto-js/sha256';
|
|
14
|
-
import { spawn } from 'child_process';
|
|
15
16
|
|
|
16
17
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
17
18
|
/**
|
|
18
19
|
* The version of the Promptbook library
|
|
19
20
|
*/
|
|
20
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
21
|
+
var PROMPTBOOK_VERSION = '0.72.0-22';
|
|
21
22
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
22
23
|
|
|
23
24
|
/*! *****************************************************************************
|
|
@@ -4756,7 +4757,6 @@ var $scrapersRegister = new $Register('scraper_constructors');
|
|
|
4756
4757
|
* TODO: [®] DRY Register logic
|
|
4757
4758
|
*/
|
|
4758
4759
|
|
|
4759
|
-
// TODO: !!!!!!last - Maybe delete this function
|
|
4760
4760
|
/**
|
|
4761
4761
|
* Creates a message with all registered scrapers
|
|
4762
4762
|
*
|
|
@@ -5029,7 +5029,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5029
5029
|
return __awaiter(this, void 0, void 0, function () {
|
|
5030
5030
|
var sourceContent, name, _b, _c, rootDirname, _d,
|
|
5031
5031
|
// <- TODO: process.cwd() if running in Node.js
|
|
5032
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension,
|
|
5032
|
+
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5033
5033
|
return __generator(this, function (_e) {
|
|
5034
5034
|
switch (_e.label) {
|
|
5035
5035
|
case 0:
|
|
@@ -5051,19 +5051,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5051
5051
|
filename: null,
|
|
5052
5052
|
url: url,
|
|
5053
5053
|
mimeType: mimeType,
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
return [2 /*return*/, content];
|
|
5063
|
-
}
|
|
5064
|
-
});
|
|
5065
|
-
});
|
|
5066
|
-
},
|
|
5054
|
+
/*
|
|
5055
|
+
TODO: [🥽]
|
|
5056
|
+
> async asBlob() {
|
|
5057
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
5058
|
+
> const content = await response.blob();
|
|
5059
|
+
> return content;
|
|
5060
|
+
> },
|
|
5061
|
+
*/
|
|
5067
5062
|
asJson: function () {
|
|
5068
5063
|
return __awaiter(this, void 0, void 0, function () {
|
|
5069
5064
|
var content;
|
|
@@ -5103,34 +5098,31 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5103
5098
|
}
|
|
5104
5099
|
filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
|
|
5105
5100
|
fileExtension = getFileExtension(filename_1);
|
|
5106
|
-
|
|
5101
|
+
mimeType = extensionToMimeType(fileExtension || '');
|
|
5107
5102
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5108
5103
|
case 3:
|
|
5109
5104
|
if (!(_e.sent())) {
|
|
5110
5105
|
throw new NotFoundError(spaceTrim$1(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
5111
5106
|
}
|
|
5112
|
-
// TODO:
|
|
5107
|
+
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
5113
5108
|
return [2 /*return*/, {
|
|
5114
5109
|
source: name,
|
|
5115
5110
|
filename: filename_1,
|
|
5116
5111
|
url: null,
|
|
5117
|
-
mimeType:
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
});
|
|
5132
|
-
});
|
|
5133
|
-
},
|
|
5112
|
+
mimeType: mimeType,
|
|
5113
|
+
/*
|
|
5114
|
+
TODO: [🥽]
|
|
5115
|
+
> async asBlob() {
|
|
5116
|
+
> const content = await tools.fs!.readFile(filename);
|
|
5117
|
+
> return new Blob(
|
|
5118
|
+
> [
|
|
5119
|
+
> content,
|
|
5120
|
+
> // <- TODO: [🥽] This is NOT tested, test it
|
|
5121
|
+
> ],
|
|
5122
|
+
> { type: mimeType },
|
|
5123
|
+
> );
|
|
5124
|
+
> },
|
|
5125
|
+
*/
|
|
5134
5126
|
asJson: function () {
|
|
5135
5127
|
return __awaiter(this, void 0, void 0, function () {
|
|
5136
5128
|
var _a, _b;
|
|
@@ -5166,9 +5158,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5166
5158
|
asJson: function () {
|
|
5167
5159
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
5168
5160
|
},
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5161
|
+
/*
|
|
5162
|
+
TODO: [🥽]
|
|
5163
|
+
> asBlob() {
|
|
5164
|
+
> throw new UnexpectedError(
|
|
5165
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
5166
|
+
> );
|
|
5167
|
+
> },
|
|
5168
|
+
*/
|
|
5172
5169
|
}];
|
|
5173
5170
|
}
|
|
5174
5171
|
});
|
|
@@ -5493,6 +5490,7 @@ var knowledgeCommandParser = {
|
|
|
5493
5490
|
'KNOWLEDGE ./hejny-cv.md',
|
|
5494
5491
|
'KNOWLEDGE ./hejny-cv.pdf',
|
|
5495
5492
|
'KNOWLEDGE ./hejny-cv.docx',
|
|
5493
|
+
// <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
|
|
5496
5494
|
],
|
|
5497
5495
|
/**
|
|
5498
5496
|
* Parses the KNOWLEDGE command
|
|
@@ -8210,6 +8208,301 @@ function pipelineStringToJson(pipelineString, tools, options) {
|
|
|
8210
8208
|
*/
|
|
8211
8209
|
var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
|
|
8212
8210
|
|
|
8211
|
+
// Note: We want to use the `exec` as async function
|
|
8212
|
+
var exec$1 = promisify(exec$2);
|
|
8213
|
+
/**
|
|
8214
|
+
* @@@
|
|
8215
|
+
*
|
|
8216
|
+
* @private within the repository
|
|
8217
|
+
*/
|
|
8218
|
+
function locateAppOnLinux(_a) {
|
|
8219
|
+
var appName = _a.appName, linuxWhich = _a.linuxWhich;
|
|
8220
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8221
|
+
var _b, stderr, stdout;
|
|
8222
|
+
return __generator(this, function (_c) {
|
|
8223
|
+
switch (_c.label) {
|
|
8224
|
+
case 0: return [4 /*yield*/, exec$1("which ".concat(linuxWhich))];
|
|
8225
|
+
case 1:
|
|
8226
|
+
_b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
|
|
8227
|
+
if (!stderr && stdout) {
|
|
8228
|
+
return [2 /*return*/, stdout.trim()];
|
|
8229
|
+
}
|
|
8230
|
+
throw new Error("Can not locate app ".concat(appName, " on Linux.\n ").concat(stderr));
|
|
8231
|
+
}
|
|
8232
|
+
});
|
|
8233
|
+
});
|
|
8234
|
+
}
|
|
8235
|
+
/**
|
|
8236
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8237
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8238
|
+
*/
|
|
8239
|
+
|
|
8240
|
+
/**
|
|
8241
|
+
* @@@
|
|
8242
|
+
*
|
|
8243
|
+
* @public exported from `@promptbook/node`
|
|
8244
|
+
*/
|
|
8245
|
+
function $provideFilesystemForNode(options) {
|
|
8246
|
+
if (!$isRunningInNode()) {
|
|
8247
|
+
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8248
|
+
}
|
|
8249
|
+
var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
8250
|
+
TODO_USE(isVerbose);
|
|
8251
|
+
return {
|
|
8252
|
+
stat: stat,
|
|
8253
|
+
access: access,
|
|
8254
|
+
constants: constants,
|
|
8255
|
+
readFile: readFile,
|
|
8256
|
+
readdir: readdir,
|
|
8257
|
+
};
|
|
8258
|
+
}
|
|
8259
|
+
/**
|
|
8260
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8261
|
+
*/
|
|
8262
|
+
|
|
8263
|
+
/**
|
|
8264
|
+
* Checks if the file is executable
|
|
8265
|
+
*
|
|
8266
|
+
* @private within the repository
|
|
8267
|
+
*/
|
|
8268
|
+
function isExecutable(path, fs) {
|
|
8269
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8270
|
+
return __generator(this, function (_a) {
|
|
8271
|
+
switch (_a.label) {
|
|
8272
|
+
case 0:
|
|
8273
|
+
_a.trys.push([0, 2, , 3]);
|
|
8274
|
+
return [4 /*yield*/, fs.access(path, fs.constants.X_OK)];
|
|
8275
|
+
case 1:
|
|
8276
|
+
_a.sent();
|
|
8277
|
+
return [2 /*return*/, true];
|
|
8278
|
+
case 2:
|
|
8279
|
+
_a.sent();
|
|
8280
|
+
return [2 /*return*/, false];
|
|
8281
|
+
case 3: return [2 /*return*/];
|
|
8282
|
+
}
|
|
8283
|
+
});
|
|
8284
|
+
});
|
|
8285
|
+
}
|
|
8286
|
+
/**
|
|
8287
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
8288
|
+
* TODO: [🖇] What about symlinks?
|
|
8289
|
+
*/
|
|
8290
|
+
|
|
8291
|
+
// Note: Module `userhome` has no types available, so it is imported using `require`
|
|
8292
|
+
// @see https://stackoverflow.com/questions/37000981/how-to-import-node-module-in-typescript-without-type-definitions
|
|
8293
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8294
|
+
var userhome = require('userhome');
|
|
8295
|
+
// Note: We want to use the `exec` as async function
|
|
8296
|
+
var exec = promisify(exec$2);
|
|
8297
|
+
/**
|
|
8298
|
+
* @@@
|
|
8299
|
+
*
|
|
8300
|
+
* @private within the repository
|
|
8301
|
+
*/
|
|
8302
|
+
function locateAppOnMacOs(_a) {
|
|
8303
|
+
var appName = _a.appName, macOsName = _a.macOsName;
|
|
8304
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8305
|
+
var toExec, regPath, altPath, _b, stderr, stdout;
|
|
8306
|
+
return __generator(this, function (_c) {
|
|
8307
|
+
switch (_c.label) {
|
|
8308
|
+
case 0:
|
|
8309
|
+
toExec = "/Contents/MacOS/".concat(macOsName);
|
|
8310
|
+
regPath = "/Applications/".concat(macOsName, ".app") + toExec;
|
|
8311
|
+
altPath = userhome(regPath.slice(1));
|
|
8312
|
+
return [4 /*yield*/, isExecutable(regPath, $provideFilesystemForNode())];
|
|
8313
|
+
case 1:
|
|
8314
|
+
if (!_c.sent()) return [3 /*break*/, 2];
|
|
8315
|
+
return [2 /*return*/, regPath];
|
|
8316
|
+
case 2: return [4 /*yield*/, isExecutable(altPath, $provideFilesystemForNode())];
|
|
8317
|
+
case 3:
|
|
8318
|
+
if (_c.sent()) {
|
|
8319
|
+
return [2 /*return*/, altPath];
|
|
8320
|
+
}
|
|
8321
|
+
_c.label = 4;
|
|
8322
|
+
case 4: return [4 /*yield*/, exec("mdfind 'kMDItemDisplayName == \"".concat(macOsName, "\" && kMDItemKind == Application'"))];
|
|
8323
|
+
case 5:
|
|
8324
|
+
_b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
|
|
8325
|
+
if (!stderr && stdout) {
|
|
8326
|
+
return [2 /*return*/, stdout.trim() + toExec];
|
|
8327
|
+
}
|
|
8328
|
+
throw new Error("Can not locate app ".concat(appName, " on macOS.\n ").concat(stderr));
|
|
8329
|
+
}
|
|
8330
|
+
});
|
|
8331
|
+
});
|
|
8332
|
+
}
|
|
8333
|
+
/**
|
|
8334
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8335
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8336
|
+
*/
|
|
8337
|
+
|
|
8338
|
+
/**
|
|
8339
|
+
* @@@
|
|
8340
|
+
*
|
|
8341
|
+
* @private within the repository
|
|
8342
|
+
*/
|
|
8343
|
+
function locateAppOnWindows(_a) {
|
|
8344
|
+
var appName = _a.appName, windowsSuffix = _a.windowsSuffix;
|
|
8345
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8346
|
+
var prefixes, prefixes_1, prefixes_1_1, prefix, path, e_1_1;
|
|
8347
|
+
var e_1, _b;
|
|
8348
|
+
return __generator(this, function (_c) {
|
|
8349
|
+
switch (_c.label) {
|
|
8350
|
+
case 0:
|
|
8351
|
+
prefixes = [
|
|
8352
|
+
process.env.LOCALAPPDATA,
|
|
8353
|
+
join(process.env.LOCALAPPDATA || '', 'Programs'),
|
|
8354
|
+
process.env.PROGRAMFILES,
|
|
8355
|
+
process.env['PROGRAMFILES(X86)'],
|
|
8356
|
+
];
|
|
8357
|
+
_c.label = 1;
|
|
8358
|
+
case 1:
|
|
8359
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
8360
|
+
prefixes_1 = __values(prefixes), prefixes_1_1 = prefixes_1.next();
|
|
8361
|
+
_c.label = 2;
|
|
8362
|
+
case 2:
|
|
8363
|
+
if (!!prefixes_1_1.done) return [3 /*break*/, 5];
|
|
8364
|
+
prefix = prefixes_1_1.value;
|
|
8365
|
+
path = prefix + windowsSuffix;
|
|
8366
|
+
return [4 /*yield*/, isExecutable(path, $provideFilesystemForNode())];
|
|
8367
|
+
case 3:
|
|
8368
|
+
if (_c.sent()) {
|
|
8369
|
+
return [2 /*return*/, path];
|
|
8370
|
+
}
|
|
8371
|
+
_c.label = 4;
|
|
8372
|
+
case 4:
|
|
8373
|
+
prefixes_1_1 = prefixes_1.next();
|
|
8374
|
+
return [3 /*break*/, 2];
|
|
8375
|
+
case 5: return [3 /*break*/, 8];
|
|
8376
|
+
case 6:
|
|
8377
|
+
e_1_1 = _c.sent();
|
|
8378
|
+
e_1 = { error: e_1_1 };
|
|
8379
|
+
return [3 /*break*/, 8];
|
|
8380
|
+
case 7:
|
|
8381
|
+
try {
|
|
8382
|
+
if (prefixes_1_1 && !prefixes_1_1.done && (_b = prefixes_1.return)) _b.call(prefixes_1);
|
|
8383
|
+
}
|
|
8384
|
+
finally { if (e_1) throw e_1.error; }
|
|
8385
|
+
return [7 /*endfinally*/];
|
|
8386
|
+
case 8: throw new Error("Can not locate app ".concat(appName, " on Windows."));
|
|
8387
|
+
}
|
|
8388
|
+
});
|
|
8389
|
+
});
|
|
8390
|
+
}
|
|
8391
|
+
/**
|
|
8392
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8393
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8394
|
+
*/
|
|
8395
|
+
|
|
8396
|
+
/**
|
|
8397
|
+
* Locates an application on the system
|
|
8398
|
+
*
|
|
8399
|
+
* @private within the repository
|
|
8400
|
+
*/
|
|
8401
|
+
function locateApp(options) {
|
|
8402
|
+
if (!$isRunningInNode()) {
|
|
8403
|
+
throw new EnvironmentMismatchError('Locating apps works only in Node.js environment');
|
|
8404
|
+
}
|
|
8405
|
+
var appName = options.appName, linuxWhich = options.linuxWhich, windowsSuffix = options.windowsSuffix, macOsName = options.macOsName;
|
|
8406
|
+
if (process.platform === 'win32') {
|
|
8407
|
+
if (windowsSuffix) {
|
|
8408
|
+
return locateAppOnWindows({ appName: appName, windowsSuffix: windowsSuffix });
|
|
8409
|
+
}
|
|
8410
|
+
else {
|
|
8411
|
+
throw new Error("".concat(appName, " is not available on Windows."));
|
|
8412
|
+
}
|
|
8413
|
+
}
|
|
8414
|
+
else if (process.platform === 'darwin') {
|
|
8415
|
+
if (macOsName) {
|
|
8416
|
+
return locateAppOnMacOs({ appName: appName, macOsName: macOsName });
|
|
8417
|
+
}
|
|
8418
|
+
else {
|
|
8419
|
+
throw new Error("".concat(appName, " is not available on macOS."));
|
|
8420
|
+
}
|
|
8421
|
+
}
|
|
8422
|
+
else {
|
|
8423
|
+
if (linuxWhich) {
|
|
8424
|
+
return locateAppOnLinux({ appName: appName, linuxWhich: linuxWhich });
|
|
8425
|
+
}
|
|
8426
|
+
else {
|
|
8427
|
+
throw new Error("".concat(appName, " is not available on Linux."));
|
|
8428
|
+
}
|
|
8429
|
+
}
|
|
8430
|
+
}
|
|
8431
|
+
/**
|
|
8432
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8433
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8434
|
+
*/
|
|
8435
|
+
|
|
8436
|
+
/**
|
|
8437
|
+
* @@@
|
|
8438
|
+
*
|
|
8439
|
+
* @private within the repository
|
|
8440
|
+
*/
|
|
8441
|
+
function locateLibreoffice() {
|
|
8442
|
+
return locateApp({
|
|
8443
|
+
appName: 'Libreoffice',
|
|
8444
|
+
linuxWhich: 'libreoffice',
|
|
8445
|
+
windowsSuffix: '\\LibreOffice\\program\\soffice.exe',
|
|
8446
|
+
macOsName: 'LibreOffice',
|
|
8447
|
+
});
|
|
8448
|
+
}
|
|
8449
|
+
/**
|
|
8450
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
|
|
8451
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8452
|
+
*/
|
|
8453
|
+
|
|
8454
|
+
/**
|
|
8455
|
+
* @@@
|
|
8456
|
+
*
|
|
8457
|
+
* @private within the repository
|
|
8458
|
+
*/
|
|
8459
|
+
function locatePandoc() {
|
|
8460
|
+
return locateApp({
|
|
8461
|
+
appName: 'Pandoc',
|
|
8462
|
+
linuxWhich: 'pandoc',
|
|
8463
|
+
windowsSuffix: '\\Pandoc\\pandoc.exe',
|
|
8464
|
+
macOsName: 'Pandoc',
|
|
8465
|
+
});
|
|
8466
|
+
}
|
|
8467
|
+
/**
|
|
8468
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
|
|
8469
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8470
|
+
*/
|
|
8471
|
+
|
|
8472
|
+
/**
|
|
8473
|
+
* @@@
|
|
8474
|
+
*
|
|
8475
|
+
* @public exported from `@promptbook/node`
|
|
8476
|
+
*/
|
|
8477
|
+
function $provideExecutablesForNode(options) {
|
|
8478
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8479
|
+
var _a, _b, isAutoInstalled, _c, isVerbose;
|
|
8480
|
+
var _d;
|
|
8481
|
+
return __generator(this, function (_e) {
|
|
8482
|
+
switch (_e.label) {
|
|
8483
|
+
case 0:
|
|
8484
|
+
if (!$isRunningInNode()) {
|
|
8485
|
+
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8486
|
+
}
|
|
8487
|
+
_a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? DEFAULT_IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
|
|
8488
|
+
TODO_USE(isAutoInstalled); // <- TODO: [🔱][🧠] Auto-install the executables
|
|
8489
|
+
TODO_USE(isVerbose);
|
|
8490
|
+
_d = {};
|
|
8491
|
+
return [4 /*yield*/, locatePandoc()];
|
|
8492
|
+
case 1:
|
|
8493
|
+
_d.pandocPath = _e.sent();
|
|
8494
|
+
return [4 /*yield*/, locateLibreoffice()];
|
|
8495
|
+
case 2: return [2 /*return*/, (_d.libreOfficePath = _e.sent(),
|
|
8496
|
+
_d)];
|
|
8497
|
+
}
|
|
8498
|
+
});
|
|
8499
|
+
});
|
|
8500
|
+
}
|
|
8501
|
+
/**
|
|
8502
|
+
* TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
|
|
8503
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8504
|
+
*/
|
|
8505
|
+
|
|
8213
8506
|
/**
|
|
8214
8507
|
* @@@
|
|
8215
8508
|
*
|
|
@@ -8440,57 +8733,6 @@ function $provideLlmToolsFromEnv(options) {
|
|
|
8440
8733
|
* TODO: [®] DRY Register logic
|
|
8441
8734
|
*/
|
|
8442
8735
|
|
|
8443
|
-
/**
|
|
8444
|
-
* @@@
|
|
8445
|
-
*
|
|
8446
|
-
* @public exported from `@promptbook/node`
|
|
8447
|
-
*/
|
|
8448
|
-
function $provideExecutablesForNode(options) {
|
|
8449
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
8450
|
-
var _a, _b, isAutoInstalled, _c, isVerbose;
|
|
8451
|
-
return __generator(this, function (_d) {
|
|
8452
|
-
if (!$isRunningInNode()) {
|
|
8453
|
-
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8454
|
-
}
|
|
8455
|
-
_a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? DEFAULT_IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
|
|
8456
|
-
TODO_USE(isAutoInstalled);
|
|
8457
|
-
TODO_USE(isVerbose);
|
|
8458
|
-
return [2 /*return*/, {
|
|
8459
|
-
// TODO: !!!!!! use `locate-app` library here
|
|
8460
|
-
pandocPath: 'C:/Users/me/AppData/Local/Pandoc/pandoc.exe',
|
|
8461
|
-
libreOfficePath: 'C:/Program Files/LibreOffice/program/swriter.exe',
|
|
8462
|
-
}];
|
|
8463
|
-
});
|
|
8464
|
-
});
|
|
8465
|
-
}
|
|
8466
|
-
/**
|
|
8467
|
-
* TODO: [🧠] THis should be maybe in different folder
|
|
8468
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8469
|
-
*/
|
|
8470
|
-
|
|
8471
|
-
/**
|
|
8472
|
-
* @@@
|
|
8473
|
-
*
|
|
8474
|
-
* @public exported from `@promptbook/node`
|
|
8475
|
-
*/
|
|
8476
|
-
function $provideFilesystemForNode(options) {
|
|
8477
|
-
if (!$isRunningInNode()) {
|
|
8478
|
-
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8479
|
-
}
|
|
8480
|
-
var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
8481
|
-
TODO_USE(isVerbose);
|
|
8482
|
-
return {
|
|
8483
|
-
stat: stat,
|
|
8484
|
-
access: access,
|
|
8485
|
-
constants: constants,
|
|
8486
|
-
readFile: readFile,
|
|
8487
|
-
readdir: readdir,
|
|
8488
|
-
};
|
|
8489
|
-
}
|
|
8490
|
-
/**
|
|
8491
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8492
|
-
*/
|
|
8493
|
-
|
|
8494
8736
|
/**
|
|
8495
8737
|
* @@@
|
|
8496
8738
|
*
|