@promptbook/node 0.82.0 → 0.83.0

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 (44) hide show
  1. package/esm/index.es.js +47 -44
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/editable.index.d.ts +74 -0
  4. package/esm/typings/src/_packages/types.index.d.ts +26 -0
  5. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
  6. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +1 -1
  7. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +1 -1
  8. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -1
  9. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
  10. package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +1 -1
  11. package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +1 -1
  12. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
  13. package/esm/typings/src/commands/JOKER/JokerCommand.d.ts +1 -1
  14. package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +1 -1
  15. package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -2
  16. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +1 -1
  17. package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.d.ts → knowledgeSourceContentToName.d.ts} +2 -2
  18. package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -1
  19. package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -1
  20. package/esm/typings/src/commands/PARAMETER/ParameterCommand.d.ts +1 -1
  21. package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +1 -1
  22. package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +1 -1
  23. package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +1 -1
  24. package/esm/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +1 -1
  25. package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +1 -1
  26. package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
  27. package/esm/typings/src/commands/SECTION/sectionCommandParser.d.ts +1 -1
  28. package/esm/typings/src/commands/URL/UrlCommand.d.ts +1 -1
  29. package/esm/typings/src/commands/URL/urlCommandParser.d.ts +1 -1
  30. package/esm/typings/src/commands/X_ACTION/ActionCommand.d.ts +1 -1
  31. package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +1 -1
  32. package/esm/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +1 -1
  33. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +1 -1
  34. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
  35. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  36. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -0
  37. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +8 -0
  38. package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +2 -0
  39. package/esm/typings/src/commands/index.d.ts +1 -1
  40. package/esm/typings/src/pipeline/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  41. package/package.json +2 -2
  42. package/umd/index.umd.js +47 -44
  43. package/umd/index.umd.js.map +1 -1
  44. /package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.test.d.ts → knowledgeSourceContentToName.test.d.ts} +0 -0
package/umd/index.umd.js CHANGED
@@ -45,7 +45,7 @@
45
45
  * @generated
46
46
  * @see https://github.com/webgptorg/promptbook
47
47
  */
48
- var PROMPTBOOK_ENGINE_VERSION = '0.82.0-3';
48
+ var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
49
49
  /**
50
50
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
51
51
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -5307,15 +5307,15 @@
5307
5307
  /**
5308
5308
  * Creates unique name for the source
5309
5309
  *
5310
- * @private within the repository
5310
+ * @public exported from `@promptbook/editable`
5311
5311
  */
5312
- function sourceContentToName(sourceContent) {
5313
- var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(sourceContent)))
5312
+ function knowledgeSourceContentToName(knowledgeSourceContent) {
5313
+ var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(knowledgeSourceContent)))
5314
5314
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
5315
5315
  .toString( /* hex */)
5316
5316
  .substring(0, 20);
5317
5317
  // <- TODO: [🥬] Make some system for hashes and ids of promptbook
5318
- var semanticName = normalizeToKebabCase(sourceContent.substring(0, 20));
5318
+ var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
5319
5319
  var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
5320
5320
  var name = pieces.join('-').split('--').join('-');
5321
5321
  // <- TODO: Use MAX_FILENAME_LENGTH
@@ -5464,19 +5464,19 @@
5464
5464
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5465
5465
  var _a;
5466
5466
  return __awaiter(this, void 0, void 0, function () {
5467
- var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
5467
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
5468
5468
  return __generator(this, function (_f) {
5469
5469
  switch (_f.label) {
5470
5470
  case 0:
5471
5471
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
5472
- sourceContent = knowledgeSource.sourceContent;
5472
+ knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
5473
5473
  name = knowledgeSource.name;
5474
5474
  _c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
5475
5475
  if (!name) {
5476
- name = sourceContentToName(sourceContent);
5476
+ name = knowledgeSourceContentToName(knowledgeSourceContent);
5477
5477
  }
5478
- if (!isValidUrl(sourceContent)) return [3 /*break*/, 2];
5479
- url = sourceContent;
5478
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
5479
+ url = knowledgeSourceContent;
5480
5480
  return [4 /*yield*/, fetch(url)];
5481
5481
  case 1:
5482
5482
  response_1 = _f.sent();
@@ -5522,7 +5522,7 @@
5522
5522
  },
5523
5523
  }];
5524
5524
  case 2:
5525
- if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
5525
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
5526
5526
  if (tools.fs === undefined) {
5527
5527
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
5528
5528
  // <- TODO: [🧠] What is the best error type here`
@@ -5531,13 +5531,13 @@
5531
5531
  throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
5532
5532
  // <- TODO: [🧠] What is the best error type here`
5533
5533
  }
5534
- filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
5534
+ filename_1 = path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
5535
5535
  fileExtension = getFileExtension(filename_1);
5536
5536
  mimeType = extensionToMimeType(fileExtension || '');
5537
5537
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
5538
5538
  case 3:
5539
5539
  if (!(_f.sent())) {
5540
- 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(sourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
5540
+ 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(knowledgeSourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
5541
5541
  }
5542
5542
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
5543
5543
  return [2 /*return*/, {
@@ -5588,7 +5588,7 @@
5588
5588
  url: null,
5589
5589
  mimeType: 'text/markdown',
5590
5590
  asText: function () {
5591
- return knowledgeSource.sourceContent;
5591
+ return knowledgeSource.knowledgeSourceContent;
5592
5592
  },
5593
5593
  asJson: function () {
5594
5594
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
@@ -5650,7 +5650,7 @@
5650
5650
  partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
5651
5651
  return [2 /*return*/, "break"];
5652
5652
  }
5653
- console.warn(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n\n The source:\n ").concat(block(knowledgeSource.sourceContent
5653
+ console.warn(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n\n The source:\n ").concat(block(knowledgeSource.knowledgeSourceContent
5654
5654
  .split('\n')
5655
5655
  .map(function (line) { return "> ".concat(line); })
5656
5656
  .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -5688,7 +5688,7 @@
5688
5688
  return [7 /*endfinally*/];
5689
5689
  case 9:
5690
5690
  if (partialPieces === null) {
5691
- throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.sourceContent
5691
+ throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
5692
5692
  .split('\n')
5693
5693
  .map(function (line) { return "> ".concat(line); })
5694
5694
  .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -5959,7 +5959,7 @@
5959
5959
  * Parses the knowledge command
5960
5960
  *
5961
5961
  * @see `documentationUrl` for more details
5962
- * @private within the commands folder
5962
+ * @public exported from `@promptbook/editable`
5963
5963
  */
5964
5964
  var knowledgeCommandParser = {
5965
5965
  /**
@@ -5995,23 +5995,25 @@
5995
5995
  */
5996
5996
  parse: function (input) {
5997
5997
  var args = input.args;
5998
- var sourceContent = spaceTrim__default["default"](args[0] || '');
5999
- if (sourceContent === '') {
5998
+ var knowledgeSourceContent = spaceTrim__default["default"](args[0] || '');
5999
+ if (knowledgeSourceContent === '') {
6000
6000
  throw new ParseError("Source is not defined");
6001
6001
  }
6002
6002
  // TODO: [main] !!4 Following checks should be applied every link in the `sourceContent`
6003
- if (sourceContent.startsWith('http://')) {
6003
+ if (knowledgeSourceContent.startsWith('http://')) {
6004
6004
  throw new ParseError("Source is not secure");
6005
6005
  }
6006
- if (!(isValidFilePath(sourceContent) || isValidUrl(sourceContent))) {
6006
+ if (!(isValidFilePath(knowledgeSourceContent) || isValidUrl(knowledgeSourceContent))) {
6007
6007
  throw new ParseError("Source not valid");
6008
6008
  }
6009
- if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
6009
+ if (knowledgeSourceContent.startsWith('../') ||
6010
+ knowledgeSourceContent.startsWith('/') ||
6011
+ /^[A-Z]:[\\/]+/i.test(knowledgeSourceContent)) {
6010
6012
  throw new ParseError("Source cannot be outside of the .book.md folder");
6011
6013
  }
6012
6014
  return {
6013
6015
  type: 'KNOWLEDGE',
6014
- sourceContent: sourceContent,
6016
+ knowledgeSourceContent: knowledgeSourceContent,
6015
6017
  };
6016
6018
  },
6017
6019
  /**
@@ -6020,10 +6022,10 @@
6020
6022
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6021
6023
  */
6022
6024
  $applyToPipelineJson: function (command, $pipelineJson) {
6023
- var sourceContent = command.sourceContent;
6025
+ var knowledgeSourceContent = command.knowledgeSourceContent;
6024
6026
  $pipelineJson.knowledgeSources.push({
6025
- name: sourceContentToName(sourceContent),
6026
- sourceContent: sourceContent,
6027
+ name: knowledgeSourceContentToName(knowledgeSourceContent),
6028
+ knowledgeSourceContent: knowledgeSourceContent,
6027
6029
  });
6028
6030
  },
6029
6031
  /**
@@ -6051,7 +6053,7 @@
6051
6053
  * Parses the section command
6052
6054
  *
6053
6055
  * @see `documentationUrl` for more details
6054
- * @private within the commands folder
6056
+ * @public exported from `@promptbook/editable`
6055
6057
  */
6056
6058
  var sectionCommandParser = {
6057
6059
  /**
@@ -6182,7 +6184,7 @@
6182
6184
  if (command.taskType === 'KNOWLEDGE') {
6183
6185
  knowledgeCommandParser.$applyToPipelineJson({
6184
6186
  type: 'KNOWLEDGE',
6185
- sourceContent: $taskJson.content, // <- TODO: [🐝][main] !!3 Work with KNOWLEDGE which not referring to the source file or website, but its content itself
6187
+ knowledgeSourceContent: $taskJson.content, // <- TODO: [🐝][main] !!3 Work with KNOWLEDGE which not referring to the source file or website, but its content itself
6186
6188
  }, $pipelineJson);
6187
6189
  $taskJson.isTask = false;
6188
6190
  return;
@@ -6327,7 +6329,7 @@
6327
6329
  * Parses the BOOK_VERSION command
6328
6330
  *
6329
6331
  * @see `documentationUrl` for more details
6330
- * @private within the commands folder
6332
+ * @public exported from `@promptbook/editable`
6331
6333
  */
6332
6334
  var bookVersionCommandParser = {
6333
6335
  /**
@@ -6482,7 +6484,7 @@
6482
6484
  * Parses the expect command
6483
6485
  *
6484
6486
  * @see `documentationUrl` for more details
6485
- * @private within the commands folder
6487
+ * @public exported from `@promptbook/editable`
6486
6488
  */
6487
6489
  var expectCommandParser = {
6488
6490
  /**
@@ -6814,7 +6816,7 @@
6814
6816
  * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
6815
6817
  *
6816
6818
  * @see `documentationUrl` for more details
6817
- * @private within the commands folder
6819
+ * @public exported from `@promptbook/editable`
6818
6820
  */
6819
6821
  var foreachCommandParser = {
6820
6822
  /**
@@ -6968,7 +6970,7 @@
6968
6970
  * Parses the format command
6969
6971
  *
6970
6972
  * @see `documentationUrl` for more details
6971
- * @private within the commands folder
6973
+ * @public exported from `@promptbook/editable`
6972
6974
  */
6973
6975
  var formatCommandParser = {
6974
6976
  /**
@@ -7265,7 +7267,7 @@
7265
7267
  * Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
7266
7268
  *
7267
7269
  * @see `documentationUrl` for more details
7268
- * @private within the commands folder
7270
+ * @public exported from `@promptbook/editable`
7269
7271
  */
7270
7272
  var formfactorCommandParser = {
7271
7273
  /**
@@ -7354,7 +7356,7 @@
7354
7356
  * Parses the joker command
7355
7357
  *
7356
7358
  * @see `documentationUrl` for more details
7357
- * @private within the commands folder
7359
+ * @public exported from `@promptbook/editable`
7358
7360
  */
7359
7361
  var jokerCommandParser = {
7360
7362
  /**
@@ -7431,7 +7433,8 @@
7431
7433
  * Parses the model command
7432
7434
  *
7433
7435
  * @see `documentationUrl` for more details
7434
- * @private within the commands folder
7436
+ * @deprecated Option to manually set the model requirements is not recommended to use, use `PERSONA` instead
7437
+ * @public exported from `@promptbook/editable`
7435
7438
  */
7436
7439
  var modelCommandParser = {
7437
7440
  /**
@@ -7575,7 +7578,7 @@
7575
7578
  * Parses the parameter command
7576
7579
  *
7577
7580
  * @see `documentationUrl` for more details
7578
- * @private within the commands folder
7581
+ * @public exported from `@promptbook/editable`
7579
7582
  */
7580
7583
  var parameterCommandParser = {
7581
7584
  /**
@@ -7680,7 +7683,7 @@
7680
7683
  * Parses the persona command
7681
7684
  *
7682
7685
  * @see `documentationUrl` for more details
7683
- * @private within the commands folder
7686
+ * @public exported from `@promptbook/editable`
7684
7687
  */
7685
7688
  var personaCommandParser = {
7686
7689
  /**
@@ -7815,7 +7818,7 @@
7815
7818
  * Parses the postprocess command
7816
7819
  *
7817
7820
  * @see `documentationUrl` for more details
7818
- * @private within the commands folder
7821
+ * @public exported from `@promptbook/editable`
7819
7822
  */
7820
7823
  var postprocessCommandParser = {
7821
7824
  /**
@@ -7893,7 +7896,7 @@
7893
7896
  * Parses the url command
7894
7897
  *
7895
7898
  * @see `documentationUrl` for more details
7896
- * @private within the commands folder
7899
+ * @public exported from `@promptbook/editable`
7897
7900
  */
7898
7901
  var urlCommandParser = {
7899
7902
  /**
@@ -7994,7 +7997,7 @@
7994
7997
  * Parses the action command
7995
7998
  *
7996
7999
  * @see `documentationUrl` for more details
7997
- * @private within the commands folder
8000
+ * @public exported from `@promptbook/editable`
7998
8001
  */
7999
8002
  var actionCommandParser = {
8000
8003
  /**
@@ -8060,7 +8063,7 @@
8060
8063
  * Parses the instrument command
8061
8064
  *
8062
8065
  * @see `documentationUrl` for more details
8063
- * @private within the commands folder
8066
+ * @public exported from `@promptbook/editable`
8064
8067
  */
8065
8068
  var instrumentCommandParser = {
8066
8069
  /**
@@ -8125,7 +8128,7 @@
8125
8128
  /**
8126
8129
  * All available command parsers
8127
8130
  *
8128
- * @private internal index of `parseCommand`
8131
+ * @public exported from `@promptbook/editable`
8129
8132
  */
8130
8133
  var COMMANDS = [
8131
8134
  sectionCommandParser,
@@ -8156,7 +8159,7 @@
8156
8159
  * @returns the parser for the command
8157
8160
  * @throws {UnexpectedError} if the parser is not found
8158
8161
  *
8159
- * @private within the compilePipeline
8162
+ * @public exported from `@promptbook/editable`
8160
8163
  */
8161
8164
  function getParserForCommand(command) {
8162
8165
  var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
@@ -8192,7 +8195,7 @@
8192
8195
  * @returns parsed command object
8193
8196
  * @throws {ParseError} if the command is invalid
8194
8197
  *
8195
- * @private within the compilePipeline
8198
+ * @public exported from `@promptbook/editable`
8196
8199
  */
8197
8200
  function parseCommand(raw, usagePlace) {
8198
8201
  if (raw.includes('\n') || raw.includes('\r')) {