@promptbook/cli 0.71.0-20 → 0.71.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 +356 -100
- package/esm/index.es.js.map +1 -1
- 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/locateLibreoffice.test.d.ts +1 -0
- package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
- package/esm/typings/src/executables/apps/locatePandoc.test.d.ts +1 -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/scrapers/_common/Scraper.d.ts +1 -4
- package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
- package/package.json +1 -1
- package/umd/index.umd.js +358 -103
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -10,6 +10,8 @@ import { unparse, parse } from 'papaparse';
|
|
|
10
10
|
import { SHA256 } from 'crypto-js';
|
|
11
11
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
12
12
|
import { lookup } from 'mime-types';
|
|
13
|
+
import { exec as exec$2, spawn } from 'child_process';
|
|
14
|
+
import { promisify } from 'util';
|
|
13
15
|
import * as dotenv from 'dotenv';
|
|
14
16
|
import sha256 from 'crypto-js/sha256';
|
|
15
17
|
import glob from 'glob-promise';
|
|
@@ -17,7 +19,6 @@ import { io } from 'socket.io-client';
|
|
|
17
19
|
import Anthropic from '@anthropic-ai/sdk';
|
|
18
20
|
import { OpenAIClient, AzureKeyCredential } from '@azure/openai';
|
|
19
21
|
import OpenAI from 'openai';
|
|
20
|
-
import { spawn } from 'child_process';
|
|
21
22
|
import { Readability } from '@mozilla/readability';
|
|
22
23
|
import { JSDOM } from 'jsdom';
|
|
23
24
|
import { Converter } from 'showdown';
|
|
@@ -26,7 +27,7 @@ import { Converter } from 'showdown';
|
|
|
26
27
|
/**
|
|
27
28
|
* The version of the Promptbook library
|
|
28
29
|
*/
|
|
29
|
-
var PROMPTBOOK_VERSION = '0.71.0-
|
|
30
|
+
var PROMPTBOOK_VERSION = '0.71.0-22';
|
|
30
31
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
31
32
|
|
|
32
33
|
/*! *****************************************************************************
|
|
@@ -4900,7 +4901,6 @@ var $scrapersRegister = new $Register('scraper_constructors');
|
|
|
4900
4901
|
* TODO: [®] DRY Register logic
|
|
4901
4902
|
*/
|
|
4902
4903
|
|
|
4903
|
-
// TODO: !!!!!!last - Maybe delete this function
|
|
4904
4904
|
/**
|
|
4905
4905
|
* Creates a message with all registered scrapers
|
|
4906
4906
|
*
|
|
@@ -5173,7 +5173,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5173
5173
|
return __awaiter(this, void 0, void 0, function () {
|
|
5174
5174
|
var sourceContent, name, _b, _c, rootDirname, _d,
|
|
5175
5175
|
// <- TODO: process.cwd() if running in Node.js
|
|
5176
|
-
isVerbose, url, response_1, mimeType, filename_1, fileExtension,
|
|
5176
|
+
isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
5177
5177
|
return __generator(this, function (_e) {
|
|
5178
5178
|
switch (_e.label) {
|
|
5179
5179
|
case 0:
|
|
@@ -5195,19 +5195,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5195
5195
|
filename: null,
|
|
5196
5196
|
url: url,
|
|
5197
5197
|
mimeType: mimeType,
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
return [2 /*return*/, content];
|
|
5207
|
-
}
|
|
5208
|
-
});
|
|
5209
|
-
});
|
|
5210
|
-
},
|
|
5198
|
+
/*
|
|
5199
|
+
TODO: [🥽]
|
|
5200
|
+
> async asBlob() {
|
|
5201
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
5202
|
+
> const content = await response.blob();
|
|
5203
|
+
> return content;
|
|
5204
|
+
> },
|
|
5205
|
+
*/
|
|
5211
5206
|
asJson: function () {
|
|
5212
5207
|
return __awaiter(this, void 0, void 0, function () {
|
|
5213
5208
|
var content;
|
|
@@ -5247,34 +5242,31 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5247
5242
|
}
|
|
5248
5243
|
filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
|
|
5249
5244
|
fileExtension = getFileExtension(filename_1);
|
|
5250
|
-
|
|
5245
|
+
mimeType = extensionToMimeType(fileExtension || '');
|
|
5251
5246
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
5252
5247
|
case 3:
|
|
5253
5248
|
if (!(_e.sent())) {
|
|
5254
5249
|
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 "); }));
|
|
5255
5250
|
}
|
|
5256
|
-
// TODO:
|
|
5251
|
+
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
5257
5252
|
return [2 /*return*/, {
|
|
5258
5253
|
source: name,
|
|
5259
5254
|
filename: filename_1,
|
|
5260
5255
|
url: null,
|
|
5261
|
-
mimeType:
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
});
|
|
5276
|
-
});
|
|
5277
|
-
},
|
|
5256
|
+
mimeType: mimeType,
|
|
5257
|
+
/*
|
|
5258
|
+
TODO: [🥽]
|
|
5259
|
+
> async asBlob() {
|
|
5260
|
+
> const content = await tools.fs!.readFile(filename);
|
|
5261
|
+
> return new Blob(
|
|
5262
|
+
> [
|
|
5263
|
+
> content,
|
|
5264
|
+
> // <- TODO: [🥽] This is NOT tested, test it
|
|
5265
|
+
> ],
|
|
5266
|
+
> { type: mimeType },
|
|
5267
|
+
> );
|
|
5268
|
+
> },
|
|
5269
|
+
*/
|
|
5278
5270
|
asJson: function () {
|
|
5279
5271
|
return __awaiter(this, void 0, void 0, function () {
|
|
5280
5272
|
var _a, _b;
|
|
@@ -5310,9 +5302,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5310
5302
|
asJson: function () {
|
|
5311
5303
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
5312
5304
|
},
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5305
|
+
/*
|
|
5306
|
+
TODO: [🥽]
|
|
5307
|
+
> asBlob() {
|
|
5308
|
+
> throw new UnexpectedError(
|
|
5309
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
5310
|
+
> );
|
|
5311
|
+
> },
|
|
5312
|
+
*/
|
|
5316
5313
|
}];
|
|
5317
5314
|
}
|
|
5318
5315
|
});
|
|
@@ -5637,6 +5634,7 @@ var knowledgeCommandParser = {
|
|
|
5637
5634
|
'KNOWLEDGE ./hejny-cv.md',
|
|
5638
5635
|
'KNOWLEDGE ./hejny-cv.pdf',
|
|
5639
5636
|
'KNOWLEDGE ./hejny-cv.docx',
|
|
5637
|
+
// <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
|
|
5640
5638
|
],
|
|
5641
5639
|
/**
|
|
5642
5640
|
* Parses the KNOWLEDGE command
|
|
@@ -8345,6 +8343,301 @@ function pipelineStringToJson(pipelineString, tools, options) {
|
|
|
8345
8343
|
* TODO: [🧠] Should be in generated JSON file GENERATOR_WARNING
|
|
8346
8344
|
*/
|
|
8347
8345
|
|
|
8346
|
+
// Note: We want to use the `exec` as async function
|
|
8347
|
+
var exec$1 = promisify(exec$2);
|
|
8348
|
+
/**
|
|
8349
|
+
* @@@
|
|
8350
|
+
*
|
|
8351
|
+
* @private within the repository
|
|
8352
|
+
*/
|
|
8353
|
+
function locateAppOnLinux(_a) {
|
|
8354
|
+
var appName = _a.appName, linuxWhich = _a.linuxWhich;
|
|
8355
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8356
|
+
var _b, stderr, stdout;
|
|
8357
|
+
return __generator(this, function (_c) {
|
|
8358
|
+
switch (_c.label) {
|
|
8359
|
+
case 0: return [4 /*yield*/, exec$1("which ".concat(linuxWhich))];
|
|
8360
|
+
case 1:
|
|
8361
|
+
_b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
|
|
8362
|
+
if (!stderr && stdout) {
|
|
8363
|
+
return [2 /*return*/, stdout.trim()];
|
|
8364
|
+
}
|
|
8365
|
+
throw new Error("Can not locate app ".concat(appName, " on Linux.\n ").concat(stderr));
|
|
8366
|
+
}
|
|
8367
|
+
});
|
|
8368
|
+
});
|
|
8369
|
+
}
|
|
8370
|
+
/**
|
|
8371
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8372
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8373
|
+
*/
|
|
8374
|
+
|
|
8375
|
+
/**
|
|
8376
|
+
* @@@
|
|
8377
|
+
*
|
|
8378
|
+
* @public exported from `@promptbook/node`
|
|
8379
|
+
*/
|
|
8380
|
+
function $provideFilesystemForNode(options) {
|
|
8381
|
+
if (!$isRunningInNode()) {
|
|
8382
|
+
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8383
|
+
}
|
|
8384
|
+
var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
8385
|
+
TODO_USE(isVerbose);
|
|
8386
|
+
return {
|
|
8387
|
+
stat: stat,
|
|
8388
|
+
access: access,
|
|
8389
|
+
constants: constants,
|
|
8390
|
+
readFile: readFile,
|
|
8391
|
+
readdir: readdir,
|
|
8392
|
+
};
|
|
8393
|
+
}
|
|
8394
|
+
/**
|
|
8395
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8396
|
+
*/
|
|
8397
|
+
|
|
8398
|
+
/**
|
|
8399
|
+
* Checks if the file is executable
|
|
8400
|
+
*
|
|
8401
|
+
* @private within the repository
|
|
8402
|
+
*/
|
|
8403
|
+
function isExecutable(path, fs) {
|
|
8404
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8405
|
+
return __generator(this, function (_a) {
|
|
8406
|
+
switch (_a.label) {
|
|
8407
|
+
case 0:
|
|
8408
|
+
_a.trys.push([0, 2, , 3]);
|
|
8409
|
+
return [4 /*yield*/, fs.access(path, fs.constants.X_OK)];
|
|
8410
|
+
case 1:
|
|
8411
|
+
_a.sent();
|
|
8412
|
+
return [2 /*return*/, true];
|
|
8413
|
+
case 2:
|
|
8414
|
+
_a.sent();
|
|
8415
|
+
return [2 /*return*/, false];
|
|
8416
|
+
case 3: return [2 /*return*/];
|
|
8417
|
+
}
|
|
8418
|
+
});
|
|
8419
|
+
});
|
|
8420
|
+
}
|
|
8421
|
+
/**
|
|
8422
|
+
* Note: Not [~🟢~] because it is not directly dependent on `fs
|
|
8423
|
+
* TODO: [🖇] What about symlinks?
|
|
8424
|
+
*/
|
|
8425
|
+
|
|
8426
|
+
// Note: Module `userhome` has no types available, so it is imported using `require`
|
|
8427
|
+
// @see https://stackoverflow.com/questions/37000981/how-to-import-node-module-in-typescript-without-type-definitions
|
|
8428
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8429
|
+
var userhome = require('userhome');
|
|
8430
|
+
// Note: We want to use the `exec` as async function
|
|
8431
|
+
var exec = promisify(exec$2);
|
|
8432
|
+
/**
|
|
8433
|
+
* @@@
|
|
8434
|
+
*
|
|
8435
|
+
* @private within the repository
|
|
8436
|
+
*/
|
|
8437
|
+
function locateAppOnMacOs(_a) {
|
|
8438
|
+
var appName = _a.appName, macOsName = _a.macOsName;
|
|
8439
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8440
|
+
var toExec, regPath, altPath, _b, stderr, stdout;
|
|
8441
|
+
return __generator(this, function (_c) {
|
|
8442
|
+
switch (_c.label) {
|
|
8443
|
+
case 0:
|
|
8444
|
+
toExec = "/Contents/MacOS/".concat(macOsName);
|
|
8445
|
+
regPath = "/Applications/".concat(macOsName, ".app") + toExec;
|
|
8446
|
+
altPath = userhome(regPath.slice(1));
|
|
8447
|
+
return [4 /*yield*/, isExecutable(regPath, $provideFilesystemForNode())];
|
|
8448
|
+
case 1:
|
|
8449
|
+
if (!_c.sent()) return [3 /*break*/, 2];
|
|
8450
|
+
return [2 /*return*/, regPath];
|
|
8451
|
+
case 2: return [4 /*yield*/, isExecutable(altPath, $provideFilesystemForNode())];
|
|
8452
|
+
case 3:
|
|
8453
|
+
if (_c.sent()) {
|
|
8454
|
+
return [2 /*return*/, altPath];
|
|
8455
|
+
}
|
|
8456
|
+
_c.label = 4;
|
|
8457
|
+
case 4: return [4 /*yield*/, exec("mdfind 'kMDItemDisplayName == \"".concat(macOsName, "\" && kMDItemKind == Application'"))];
|
|
8458
|
+
case 5:
|
|
8459
|
+
_b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
|
|
8460
|
+
if (!stderr && stdout) {
|
|
8461
|
+
return [2 /*return*/, stdout.trim() + toExec];
|
|
8462
|
+
}
|
|
8463
|
+
throw new Error("Can not locate app ".concat(appName, " on macOS.\n ").concat(stderr));
|
|
8464
|
+
}
|
|
8465
|
+
});
|
|
8466
|
+
});
|
|
8467
|
+
}
|
|
8468
|
+
/**
|
|
8469
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8470
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8471
|
+
*/
|
|
8472
|
+
|
|
8473
|
+
/**
|
|
8474
|
+
* @@@
|
|
8475
|
+
*
|
|
8476
|
+
* @private within the repository
|
|
8477
|
+
*/
|
|
8478
|
+
function locateAppOnWindows(_a) {
|
|
8479
|
+
var appName = _a.appName, windowsSuffix = _a.windowsSuffix;
|
|
8480
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8481
|
+
var prefixes, prefixes_1, prefixes_1_1, prefix, path, e_1_1;
|
|
8482
|
+
var e_1, _b;
|
|
8483
|
+
return __generator(this, function (_c) {
|
|
8484
|
+
switch (_c.label) {
|
|
8485
|
+
case 0:
|
|
8486
|
+
prefixes = [
|
|
8487
|
+
process.env.LOCALAPPDATA,
|
|
8488
|
+
join(process.env.LOCALAPPDATA || '', 'Programs'),
|
|
8489
|
+
process.env.PROGRAMFILES,
|
|
8490
|
+
process.env['PROGRAMFILES(X86)'],
|
|
8491
|
+
];
|
|
8492
|
+
_c.label = 1;
|
|
8493
|
+
case 1:
|
|
8494
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
8495
|
+
prefixes_1 = __values(prefixes), prefixes_1_1 = prefixes_1.next();
|
|
8496
|
+
_c.label = 2;
|
|
8497
|
+
case 2:
|
|
8498
|
+
if (!!prefixes_1_1.done) return [3 /*break*/, 5];
|
|
8499
|
+
prefix = prefixes_1_1.value;
|
|
8500
|
+
path = prefix + windowsSuffix;
|
|
8501
|
+
return [4 /*yield*/, isExecutable(path, $provideFilesystemForNode())];
|
|
8502
|
+
case 3:
|
|
8503
|
+
if (_c.sent()) {
|
|
8504
|
+
return [2 /*return*/, path];
|
|
8505
|
+
}
|
|
8506
|
+
_c.label = 4;
|
|
8507
|
+
case 4:
|
|
8508
|
+
prefixes_1_1 = prefixes_1.next();
|
|
8509
|
+
return [3 /*break*/, 2];
|
|
8510
|
+
case 5: return [3 /*break*/, 8];
|
|
8511
|
+
case 6:
|
|
8512
|
+
e_1_1 = _c.sent();
|
|
8513
|
+
e_1 = { error: e_1_1 };
|
|
8514
|
+
return [3 /*break*/, 8];
|
|
8515
|
+
case 7:
|
|
8516
|
+
try {
|
|
8517
|
+
if (prefixes_1_1 && !prefixes_1_1.done && (_b = prefixes_1.return)) _b.call(prefixes_1);
|
|
8518
|
+
}
|
|
8519
|
+
finally { if (e_1) throw e_1.error; }
|
|
8520
|
+
return [7 /*endfinally*/];
|
|
8521
|
+
case 8: throw new Error("Can not locate app ".concat(appName, " on Windows."));
|
|
8522
|
+
}
|
|
8523
|
+
});
|
|
8524
|
+
});
|
|
8525
|
+
}
|
|
8526
|
+
/**
|
|
8527
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8528
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8529
|
+
*/
|
|
8530
|
+
|
|
8531
|
+
/**
|
|
8532
|
+
* Locates an application on the system
|
|
8533
|
+
*
|
|
8534
|
+
* @private within the repository
|
|
8535
|
+
*/
|
|
8536
|
+
function locateApp(options) {
|
|
8537
|
+
if (!$isRunningInNode()) {
|
|
8538
|
+
throw new EnvironmentMismatchError('Locating apps works only in Node.js environment');
|
|
8539
|
+
}
|
|
8540
|
+
var appName = options.appName, linuxWhich = options.linuxWhich, windowsSuffix = options.windowsSuffix, macOsName = options.macOsName;
|
|
8541
|
+
if (process.platform === 'win32') {
|
|
8542
|
+
if (windowsSuffix) {
|
|
8543
|
+
return locateAppOnWindows({ appName: appName, windowsSuffix: windowsSuffix });
|
|
8544
|
+
}
|
|
8545
|
+
else {
|
|
8546
|
+
throw new Error("".concat(appName, " is not available on Windows."));
|
|
8547
|
+
}
|
|
8548
|
+
}
|
|
8549
|
+
else if (process.platform === 'darwin') {
|
|
8550
|
+
if (macOsName) {
|
|
8551
|
+
return locateAppOnMacOs({ appName: appName, macOsName: macOsName });
|
|
8552
|
+
}
|
|
8553
|
+
else {
|
|
8554
|
+
throw new Error("".concat(appName, " is not available on macOS."));
|
|
8555
|
+
}
|
|
8556
|
+
}
|
|
8557
|
+
else {
|
|
8558
|
+
if (linuxWhich) {
|
|
8559
|
+
return locateAppOnLinux({ appName: appName, linuxWhich: linuxWhich });
|
|
8560
|
+
}
|
|
8561
|
+
else {
|
|
8562
|
+
throw new Error("".concat(appName, " is not available on Linux."));
|
|
8563
|
+
}
|
|
8564
|
+
}
|
|
8565
|
+
}
|
|
8566
|
+
/**
|
|
8567
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8568
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8569
|
+
*/
|
|
8570
|
+
|
|
8571
|
+
/**
|
|
8572
|
+
* @@@
|
|
8573
|
+
*
|
|
8574
|
+
* @private within the repository
|
|
8575
|
+
*/
|
|
8576
|
+
function locateLibreoffice() {
|
|
8577
|
+
return locateApp({
|
|
8578
|
+
appName: 'Libreoffice',
|
|
8579
|
+
linuxWhich: 'libreoffice',
|
|
8580
|
+
windowsSuffix: '\\LibreOffice\\program\\soffice.exe',
|
|
8581
|
+
macOsName: 'LibreOffice',
|
|
8582
|
+
});
|
|
8583
|
+
}
|
|
8584
|
+
/**
|
|
8585
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
|
|
8586
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8587
|
+
*/
|
|
8588
|
+
|
|
8589
|
+
/**
|
|
8590
|
+
* @@@
|
|
8591
|
+
*
|
|
8592
|
+
* @private within the repository
|
|
8593
|
+
*/
|
|
8594
|
+
function locatePandoc() {
|
|
8595
|
+
return locateApp({
|
|
8596
|
+
appName: 'Pandoc',
|
|
8597
|
+
linuxWhich: 'pandoc',
|
|
8598
|
+
windowsSuffix: '\\Pandoc\\pandoc.exe',
|
|
8599
|
+
macOsName: 'Pandoc',
|
|
8600
|
+
});
|
|
8601
|
+
}
|
|
8602
|
+
/**
|
|
8603
|
+
* TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
|
|
8604
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8605
|
+
*/
|
|
8606
|
+
|
|
8607
|
+
/**
|
|
8608
|
+
* @@@
|
|
8609
|
+
*
|
|
8610
|
+
* @public exported from `@promptbook/node`
|
|
8611
|
+
*/
|
|
8612
|
+
function $provideExecutablesForNode(options) {
|
|
8613
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8614
|
+
var _a, _b, isAutoInstalled, _c, isVerbose;
|
|
8615
|
+
var _d;
|
|
8616
|
+
return __generator(this, function (_e) {
|
|
8617
|
+
switch (_e.label) {
|
|
8618
|
+
case 0:
|
|
8619
|
+
if (!$isRunningInNode()) {
|
|
8620
|
+
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8621
|
+
}
|
|
8622
|
+
_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;
|
|
8623
|
+
TODO_USE(isAutoInstalled); // <- TODO: [🔱][🧠] Auto-install the executables
|
|
8624
|
+
TODO_USE(isVerbose);
|
|
8625
|
+
_d = {};
|
|
8626
|
+
return [4 /*yield*/, locatePandoc()];
|
|
8627
|
+
case 1:
|
|
8628
|
+
_d.pandocPath = _e.sent();
|
|
8629
|
+
return [4 /*yield*/, locateLibreoffice()];
|
|
8630
|
+
case 2: return [2 /*return*/, (_d.libreOfficePath = _e.sent(),
|
|
8631
|
+
_d)];
|
|
8632
|
+
}
|
|
8633
|
+
});
|
|
8634
|
+
});
|
|
8635
|
+
}
|
|
8636
|
+
/**
|
|
8637
|
+
* TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
|
|
8638
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8639
|
+
*/
|
|
8640
|
+
|
|
8348
8641
|
/**
|
|
8349
8642
|
* @@@
|
|
8350
8643
|
*
|
|
@@ -8575,57 +8868,6 @@ function $provideLlmToolsFromEnv(options) {
|
|
|
8575
8868
|
* TODO: [®] DRY Register logic
|
|
8576
8869
|
*/
|
|
8577
8870
|
|
|
8578
|
-
/**
|
|
8579
|
-
* @@@
|
|
8580
|
-
*
|
|
8581
|
-
* @public exported from `@promptbook/node`
|
|
8582
|
-
*/
|
|
8583
|
-
function $provideExecutablesForNode(options) {
|
|
8584
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
8585
|
-
var _a, _b, isAutoInstalled, _c, isVerbose;
|
|
8586
|
-
return __generator(this, function (_d) {
|
|
8587
|
-
if (!$isRunningInNode()) {
|
|
8588
|
-
throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
|
|
8589
|
-
}
|
|
8590
|
-
_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;
|
|
8591
|
-
TODO_USE(isAutoInstalled);
|
|
8592
|
-
TODO_USE(isVerbose);
|
|
8593
|
-
return [2 /*return*/, {
|
|
8594
|
-
// TODO: !!!!!! use `locate-app` library here
|
|
8595
|
-
pandocPath: 'C:/Users/me/AppData/Local/Pandoc/pandoc.exe',
|
|
8596
|
-
libreOfficePath: 'C:/Program Files/LibreOffice/program/swriter.exe',
|
|
8597
|
-
}];
|
|
8598
|
-
});
|
|
8599
|
-
});
|
|
8600
|
-
}
|
|
8601
|
-
/**
|
|
8602
|
-
* TODO: [🧠] THis should be maybe in different folder
|
|
8603
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8604
|
-
*/
|
|
8605
|
-
|
|
8606
|
-
/**
|
|
8607
|
-
* @@@
|
|
8608
|
-
*
|
|
8609
|
-
* @public exported from `@promptbook/node`
|
|
8610
|
-
*/
|
|
8611
|
-
function $provideFilesystemForNode(options) {
|
|
8612
|
-
if (!$isRunningInNode()) {
|
|
8613
|
-
throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
|
|
8614
|
-
}
|
|
8615
|
-
var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
8616
|
-
TODO_USE(isVerbose);
|
|
8617
|
-
return {
|
|
8618
|
-
stat: stat,
|
|
8619
|
-
access: access,
|
|
8620
|
-
constants: constants,
|
|
8621
|
-
readFile: readFile,
|
|
8622
|
-
readdir: readdir,
|
|
8623
|
-
};
|
|
8624
|
-
}
|
|
8625
|
-
/**
|
|
8626
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8627
|
-
*/
|
|
8628
|
-
|
|
8629
8871
|
/**
|
|
8630
8872
|
* @@@
|
|
8631
8873
|
*
|
|
@@ -13145,9 +13387,14 @@ var DocumentScraper = /** @class */ (function () {
|
|
|
13145
13387
|
asJson: function () {
|
|
13146
13388
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
13147
13389
|
},
|
|
13148
|
-
|
|
13149
|
-
|
|
13150
|
-
|
|
13390
|
+
/*
|
|
13391
|
+
TODO: [🥽]
|
|
13392
|
+
> asBlob() {
|
|
13393
|
+
> throw new UnexpectedError(
|
|
13394
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
13395
|
+
> );
|
|
13396
|
+
> },
|
|
13397
|
+
*/
|
|
13151
13398
|
};
|
|
13152
13399
|
knowledge = this.markdownScraper.scrape(markdownSource);
|
|
13153
13400
|
return [4 /*yield*/, cacheFilehandler.destroy()];
|
|
@@ -13313,9 +13560,14 @@ var LegacyDocumentScraper = /** @class */ (function () {
|
|
|
13313
13560
|
asJson: function () {
|
|
13314
13561
|
throw new UnexpectedError('Did not expect that `documentScraper` would need to get the content `asJson`');
|
|
13315
13562
|
},
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13563
|
+
/*
|
|
13564
|
+
TODO: [🥽]
|
|
13565
|
+
> asBlob() {
|
|
13566
|
+
> throw new UnexpectedError(
|
|
13567
|
+
> 'Did not expect that `documentScraper` would need to get the content `asBlob`',
|
|
13568
|
+
> );
|
|
13569
|
+
> },
|
|
13570
|
+
*/
|
|
13319
13571
|
};
|
|
13320
13572
|
knowledge = this.documentScraper.scrape(markdownSource);
|
|
13321
13573
|
return [4 /*yield*/, cacheFilehandler.destroy()];
|
|
@@ -13603,7 +13855,6 @@ var WebsiteScraper = /** @class */ (function () {
|
|
|
13603
13855
|
switch (_g.label) {
|
|
13604
13856
|
case 0:
|
|
13605
13857
|
_a = this.options, _b = _a.rootDirname, rootDirname = _b === void 0 ? process.cwd() : _b, _c = _a.cacheDirname, cacheDirname = _c === void 0 ? DEFAULT_SCRAPE_CACHE_DIRNAME : _c, _d = _a.intermediateFilesStrategy, intermediateFilesStrategy = _d === void 0 ? DEFAULT_INTERMEDIATE_FILES_STRATEGY : _d, _e = _a.isVerbose, isVerbose = _e === void 0 ? DEFAULT_IS_VERBOSE : _e;
|
|
13606
|
-
// TODO: !!!!!! Does this work in browser? Make it work.
|
|
13607
13858
|
if (source.url === null) {
|
|
13608
13859
|
throw new KnowledgeScrapeError('Website scraper requires URL');
|
|
13609
13860
|
}
|
|
@@ -13663,9 +13914,14 @@ var WebsiteScraper = /** @class */ (function () {
|
|
|
13663
13914
|
asJson: function () {
|
|
13664
13915
|
throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
|
|
13665
13916
|
},
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13917
|
+
/*
|
|
13918
|
+
TODO: [🥽]
|
|
13919
|
+
> asBlob() {
|
|
13920
|
+
> throw new UnexpectedError(
|
|
13921
|
+
> 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
|
|
13922
|
+
> );
|
|
13923
|
+
> },
|
|
13924
|
+
*/
|
|
13669
13925
|
};
|
|
13670
13926
|
knowledge = this.markdownScraper.scrape(markdownSource);
|
|
13671
13927
|
return [4 /*yield*/, cacheFilehandler.destroy()];
|