@promptbook/cli 0.71.0-21 → 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 CHANGED
@@ -27,7 +27,7 @@ import { Converter } from 'showdown';
27
27
  /**
28
28
  * The version of the Promptbook library
29
29
  */
30
- var PROMPTBOOK_VERSION = '0.71.0-20';
30
+ var PROMPTBOOK_VERSION = '0.71.0-22';
31
31
  // TODO: [main] !!!! List here all the versions and annotate + put into script
32
32
 
33
33
  /*! *****************************************************************************
@@ -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, mimeType_1;
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
- asBlob: function () {
5199
- return __awaiter(this, void 0, void 0, function () {
5200
- var content;
5201
- return __generator(this, function (_a) {
5202
- switch (_a.label) {
5203
- case 0: return [4 /*yield*/, response_1.blob()];
5204
- case 1:
5205
- content = _a.sent();
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
- mimeType_1 = extensionToMimeType(fileExtension || '');
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: !!!!!! Test security file - file is scoped to the project (maybe do this in `filesystemTools`)
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: mimeType_1,
5262
- asBlob: function () {
5263
- return __awaiter(this, void 0, void 0, function () {
5264
- var content;
5265
- return __generator(this, function (_a) {
5266
- switch (_a.label) {
5267
- case 0: return [4 /*yield*/, tools.fs.readFile(filename_1)];
5268
- case 1:
5269
- content = _a.sent();
5270
- return [2 /*return*/, new Blob([
5271
- content,
5272
- // <- TODO: !!!!!! Test that this is working
5273
- ], { type: mimeType_1 })];
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
- asBlob: function () {
5314
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
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
@@ -13389,9 +13387,14 @@ var DocumentScraper = /** @class */ (function () {
13389
13387
  asJson: function () {
13390
13388
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
13391
13389
  },
13392
- asBlob: function () {
13393
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
13394
- },
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
+ */
13395
13398
  };
13396
13399
  knowledge = this.markdownScraper.scrape(markdownSource);
13397
13400
  return [4 /*yield*/, cacheFilehandler.destroy()];
@@ -13557,9 +13560,14 @@ var LegacyDocumentScraper = /** @class */ (function () {
13557
13560
  asJson: function () {
13558
13561
  throw new UnexpectedError('Did not expect that `documentScraper` would need to get the content `asJson`');
13559
13562
  },
13560
- asBlob: function () {
13561
- throw new UnexpectedError('Did not expect that `documentScraper` would need to get the content `asBlob`');
13562
- },
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
+ */
13563
13571
  };
13564
13572
  knowledge = this.documentScraper.scrape(markdownSource);
13565
13573
  return [4 /*yield*/, cacheFilehandler.destroy()];
@@ -13847,7 +13855,6 @@ var WebsiteScraper = /** @class */ (function () {
13847
13855
  switch (_g.label) {
13848
13856
  case 0:
13849
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;
13850
- // TODO: !!!!!! Does this work in browser? Make it work.
13851
13858
  if (source.url === null) {
13852
13859
  throw new KnowledgeScrapeError('Website scraper requires URL');
13853
13860
  }
@@ -13907,9 +13914,14 @@ var WebsiteScraper = /** @class */ (function () {
13907
13914
  asJson: function () {
13908
13915
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
13909
13916
  },
13910
- asBlob: function () {
13911
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
13912
- },
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
+ */
13913
13925
  };
13914
13926
  knowledge = this.markdownScraper.scrape(markdownSource);
13915
13927
  return [4 /*yield*/, cacheFilehandler.destroy()];