@promptbook/node 0.71.0-21 → 0.71.0-24

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
@@ -18,7 +18,7 @@ import sha256 from 'crypto-js/sha256';
18
18
  /**
19
19
  * The version of the Promptbook library
20
20
  */
21
- var PROMPTBOOK_VERSION = '0.71.0-20';
21
+ var PROMPTBOOK_VERSION = '0.71.0-23';
22
22
  // TODO: [main] !!!! List here all the versions and annotate + put into script
23
23
 
24
24
  /*! *****************************************************************************
@@ -5002,7 +5002,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5002
5002
  return __awaiter(this, void 0, void 0, function () {
5003
5003
  var sourceContent, name, _b, _c, rootDirname, _d,
5004
5004
  // <- TODO: process.cwd() if running in Node.js
5005
- isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType_1;
5005
+ isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
5006
5006
  return __generator(this, function (_e) {
5007
5007
  switch (_e.label) {
5008
5008
  case 0:
@@ -5024,19 +5024,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5024
5024
  filename: null,
5025
5025
  url: url,
5026
5026
  mimeType: mimeType,
5027
- asBlob: function () {
5028
- return __awaiter(this, void 0, void 0, function () {
5029
- var content;
5030
- return __generator(this, function (_a) {
5031
- switch (_a.label) {
5032
- case 0: return [4 /*yield*/, response_1.blob()];
5033
- case 1:
5034
- content = _a.sent();
5035
- return [2 /*return*/, content];
5036
- }
5037
- });
5038
- });
5039
- },
5027
+ /*
5028
+ TODO: [🥽]
5029
+ > async asBlob() {
5030
+ > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
5031
+ > const content = await response.blob();
5032
+ > return content;
5033
+ > },
5034
+ */
5040
5035
  asJson: function () {
5041
5036
  return __awaiter(this, void 0, void 0, function () {
5042
5037
  var content;
@@ -5076,34 +5071,31 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5076
5071
  }
5077
5072
  filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
5078
5073
  fileExtension = getFileExtension(filename_1);
5079
- mimeType_1 = extensionToMimeType(fileExtension || '');
5074
+ mimeType = extensionToMimeType(fileExtension || '');
5080
5075
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
5081
5076
  case 3:
5082
5077
  if (!(_e.sent())) {
5083
5078
  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 "); }));
5084
5079
  }
5085
- // TODO: !!!!!! Test security file - file is scoped to the project (maybe do this in `filesystemTools`)
5080
+ // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
5086
5081
  return [2 /*return*/, {
5087
5082
  source: name,
5088
5083
  filename: filename_1,
5089
5084
  url: null,
5090
- mimeType: mimeType_1,
5091
- asBlob: function () {
5092
- return __awaiter(this, void 0, void 0, function () {
5093
- var content;
5094
- return __generator(this, function (_a) {
5095
- switch (_a.label) {
5096
- case 0: return [4 /*yield*/, tools.fs.readFile(filename_1)];
5097
- case 1:
5098
- content = _a.sent();
5099
- return [2 /*return*/, new Blob([
5100
- content,
5101
- // <- TODO: !!!!!! Test that this is working
5102
- ], { type: mimeType_1 })];
5103
- }
5104
- });
5105
- });
5106
- },
5085
+ mimeType: mimeType,
5086
+ /*
5087
+ TODO: [🥽]
5088
+ > async asBlob() {
5089
+ > const content = await tools.fs!.readFile(filename);
5090
+ > return new Blob(
5091
+ > [
5092
+ > content,
5093
+ > // <- TODO: [🥽] This is NOT tested, test it
5094
+ > ],
5095
+ > { type: mimeType },
5096
+ > );
5097
+ > },
5098
+ */
5107
5099
  asJson: function () {
5108
5100
  return __awaiter(this, void 0, void 0, function () {
5109
5101
  var _a, _b;
@@ -5139,9 +5131,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5139
5131
  asJson: function () {
5140
5132
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
5141
5133
  },
5142
- asBlob: function () {
5143
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
5144
- },
5134
+ /*
5135
+ TODO: [🥽]
5136
+ > asBlob() {
5137
+ > throw new UnexpectedError(
5138
+ > 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
5139
+ > );
5140
+ > },
5141
+ */
5145
5142
  }];
5146
5143
  }
5147
5144
  });
@@ -5466,6 +5463,7 @@ var knowledgeCommandParser = {
5466
5463
  'KNOWLEDGE ./hejny-cv.md',
5467
5464
  'KNOWLEDGE ./hejny-cv.pdf',
5468
5465
  'KNOWLEDGE ./hejny-cv.docx',
5466
+ // <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
5469
5467
  ],
5470
5468
  /**
5471
5469
  * Parses the KNOWLEDGE command