@promptbook/cli 0.84.0-10 โ†’ 0.84.0-12

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
@@ -38,7 +38,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
38
38
  * @generated
39
39
  * @see https://github.com/webgptorg/promptbook
40
40
  */
41
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-9';
41
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-11';
42
42
  /**
43
43
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
44
44
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -314,6 +314,14 @@ var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
314
314
  */
315
315
  var DEFAULT_BOOKS_DIRNAME = './books';
316
316
  // <- TODO: [๐Ÿ•] Make also `BOOKS_DIRNAME_ALTERNATIVES`
317
+ /**
318
+ * Where to store the temporary downloads
319
+ *
320
+ * Note: When the folder does not exist, it is created recursively
321
+ *
322
+ * @public exported from `@promptbook/core`
323
+ */
324
+ var DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
317
325
  /**
318
326
  * Where to store the cache of executions for promptbook CLI
319
327
  *
@@ -321,7 +329,7 @@ var DEFAULT_BOOKS_DIRNAME = './books';
321
329
  *
322
330
  * @public exported from `@promptbook/core`
323
331
  */
324
- var DEFAULT_EXECUTIONS_CACHE_DIRNAME = './.promptbook/executions-cache';
332
+ var DEFAULT_EXECUTION_CACHE_DIRNAME = './.promptbook/execution-cache';
325
333
  /**
326
334
  * Where to store the scrape cache
327
335
  *
@@ -516,6 +524,7 @@ function $provideFilesystemForNode(options) {
516
524
  readFile: readFile,
517
525
  writeFile: writeFile,
518
526
  readdir: readdir,
527
+ mkdir: mkdir,
519
528
  };
520
529
  }
521
530
  /**
@@ -2717,7 +2726,7 @@ function $provideLlmToolsForWizzardOrCli(options) {
2717
2726
  _c.sent()]),
2718
2727
  {
2719
2728
  storage: new FileCacheStorage({ fs: $provideFilesystemForNode() }, {
2720
- rootFolderPath: join(process.cwd(), DEFAULT_EXECUTIONS_CACHE_DIRNAME),
2729
+ rootFolderPath: join(process.cwd(), DEFAULT_EXECUTION_CACHE_DIRNAME),
2721
2730
  }),
2722
2731
  isCacheReloaded: isCacheReloaded,
2723
2732
  }])];
@@ -2790,24 +2799,18 @@ function collectionToJson(collection) {
2790
2799
  var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [๐Ÿ†] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [๐Ÿ†] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book.md`\n- INPUT PARAMETER `{availableModelNames}` List of available model names separated by comma (,)\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n\\`\\`\\`json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelRequirements}`\n"}],sourceFile:"./books/prepare-persona.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book.md",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"โœ Convert Knowledge-piece to title\" but \"โœ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book.md`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"โœ Convert Knowledge-piece to title\" but \"โœ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book.md"}];
2791
2800
 
2792
2801
  /**
2793
- * Function isValidJsonString will tell you if the string is valid JSON or not
2802
+ * Checks if value is valid email
2794
2803
  *
2795
2804
  * @public exported from `@promptbook/utils`
2796
2805
  */
2797
- function isValidJsonString(value /* <- [๐Ÿ‘จโ€โš–๏ธ] */) {
2798
- try {
2799
- JSON.parse(value);
2800
- return true;
2806
+ function isValidEmail(email) {
2807
+ if (typeof email !== 'string') {
2808
+ return false;
2801
2809
  }
2802
- catch (error) {
2803
- if (!(error instanceof Error)) {
2804
- throw error;
2805
- }
2806
- if (error.message.includes('Unexpected token')) {
2807
- return false;
2808
- }
2810
+ if (email.split('\n').length > 1) {
2809
2811
  return false;
2810
2812
  }
2813
+ return /^.+@.+\..+$/.test(email);
2811
2814
  }
2812
2815
 
2813
2816
  /**
@@ -2829,6 +2832,27 @@ var ParseError = /** @class */ (function (_super) {
2829
2832
  * TODO: Maybe split `ParseError` and `ApplyError`
2830
2833
  */
2831
2834
 
2835
+ /**
2836
+ * Function isValidJsonString will tell you if the string is valid JSON or not
2837
+ *
2838
+ * @public exported from `@promptbook/utils`
2839
+ */
2840
+ function isValidJsonString(value /* <- [๐Ÿ‘จโ€โš–๏ธ] */) {
2841
+ try {
2842
+ JSON.parse(value);
2843
+ return true;
2844
+ }
2845
+ catch (error) {
2846
+ if (!(error instanceof Error)) {
2847
+ throw error;
2848
+ }
2849
+ if (error.message.includes('Unexpected token')) {
2850
+ return false;
2851
+ }
2852
+ return false;
2853
+ }
2854
+ }
2855
+
2832
2856
  /**
2833
2857
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
2834
2858
  * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
@@ -2842,6 +2866,15 @@ function validatePipelineString(pipelineString) {
2842
2866
  if (isValidJsonString(pipelineString)) {
2843
2867
  throw new ParseError('Expected a book, but got a JSON string');
2844
2868
  }
2869
+ else if (isValidUrl(pipelineString)) {
2870
+ throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
2871
+ }
2872
+ else if (isValidFilePath(pipelineString)) {
2873
+ throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
2874
+ }
2875
+ else if (isValidEmail(pipelineString)) {
2876
+ throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
2877
+ }
2845
2878
  // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
2846
2879
  return pipelineString;
2847
2880
  }
@@ -3914,12 +3947,28 @@ function deserializeError(error) {
3914
3947
  /**
3915
3948
  * Asserts that the execution of a Promptbook is successful
3916
3949
  *
3950
+ * Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
3951
+ *
3917
3952
  * @param executionResult - The partial result of the Promptbook execution
3918
3953
  * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
3919
3954
  * @public exported from `@promptbook/core`
3920
3955
  */
3921
3956
  function assertsExecutionSuccessful(executionResult) {
3922
- var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
3957
+ var e_1, _a;
3958
+ var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
3959
+ try {
3960
+ for (var warnings_1 = __values(warnings), warnings_1_1 = warnings_1.next(); !warnings_1_1.done; warnings_1_1 = warnings_1.next()) {
3961
+ var warning = warnings_1_1.value;
3962
+ console.warn(warning.message);
3963
+ }
3964
+ }
3965
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3966
+ finally {
3967
+ try {
3968
+ if (warnings_1_1 && !warnings_1_1.done && (_a = warnings_1.return)) _a.call(warnings_1);
3969
+ }
3970
+ finally { if (e_1) throw e_1.error; }
3971
+ }
3923
3972
  if (isSuccessful === true) {
3924
3973
  return;
3925
3974
  }
@@ -6461,10 +6510,11 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
6461
6510
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6462
6511
  var _a;
6463
6512
  return __awaiter(this, void 0, void 0, function () {
6464
- var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
6465
- return __generator(this, function (_f) {
6466
- switch (_f.label) {
6513
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response, mimeType, filename, hash, rootDirname_1, filepath, _f, _g, _h, _j, _k, filename_1, fileExtension, mimeType;
6514
+ return __generator(this, function (_l) {
6515
+ switch (_l.label) {
6467
6516
  case 0:
6517
+ console.log('!!! makeKnowledgeSourceHandler', knowledgeSource);
6468
6518
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
6469
6519
  knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
6470
6520
  name = knowledgeSource.name;
@@ -6472,54 +6522,32 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6472
6522
  if (!name) {
6473
6523
  name = knowledgeSourceContentToName(knowledgeSourceContent);
6474
6524
  }
6475
- if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
6525
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 5];
6476
6526
  url = knowledgeSourceContent;
6477
6527
  return [4 /*yield*/, fetch(url)];
6478
6528
  case 1:
6479
- response_1 = _f.sent();
6480
- mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
6481
- return [2 /*return*/, {
6482
- source: name,
6483
- filename: null,
6484
- url: url,
6485
- mimeType: mimeType,
6486
- /*
6487
- TODO: [๐Ÿฅฝ]
6488
- > async asBlob() {
6489
- > // TODO: [๐Ÿ‘จ๐Ÿปโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿป] This can be called multiple times BUT when called second time, response in already consumed
6490
- > const content = await response.blob();
6491
- > return content;
6492
- > },
6493
- */
6494
- asJson: function () {
6495
- return __awaiter(this, void 0, void 0, function () {
6496
- var content;
6497
- return __generator(this, function (_a) {
6498
- switch (_a.label) {
6499
- case 0: return [4 /*yield*/, response_1.json()];
6500
- case 1:
6501
- content = _a.sent();
6502
- return [2 /*return*/, content];
6503
- }
6504
- });
6505
- });
6506
- },
6507
- asText: function () {
6508
- return __awaiter(this, void 0, void 0, function () {
6509
- var content;
6510
- return __generator(this, function (_a) {
6511
- switch (_a.label) {
6512
- case 0: return [4 /*yield*/, response_1.text()];
6513
- case 1:
6514
- content = _a.sent();
6515
- return [2 /*return*/, content];
6516
- }
6517
- });
6518
- });
6519
- },
6520
- }];
6529
+ response = _l.sent();
6530
+ mimeType = ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
6531
+ filename = url.split('/').pop() || titleToName(url);
6532
+ hash = sha256(hexEncoder.parse(url)).toString( /* hex */);
6533
+ rootDirname_1 = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
6534
+ filepath = join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [๐ŸŽŽ] Maybe add some SHA256 prefix */)), false), ["".concat(filename.substring(0, MAX_FILENAME_LENGTH), ".pdf")], false));
6535
+ return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
6521
6536
  case 2:
6522
- if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
6537
+ _l.sent();
6538
+ _g = (_f = tools.fs).writeFile;
6539
+ _h = [join(rootDirname_1, filepath)];
6540
+ _k = (_j = Buffer).from;
6541
+ return [4 /*yield*/, response.arrayBuffer()];
6542
+ case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
6543
+ case 4:
6544
+ _l.sent();
6545
+ // TODO: !!!!!!!! Check the file security
6546
+ // TODO: !!!!!!!! Check the file size (if it is not too big)
6547
+ // TODO: !!!!!!!! Delete the file
6548
+ return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
6549
+ case 5:
6550
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
6523
6551
  if (tools.fs === undefined) {
6524
6552
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
6525
6553
  // <- TODO: [๐Ÿง ] What is the best error type here`
@@ -6532,8 +6560,8 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6532
6560
  fileExtension = getFileExtension(filename_1);
6533
6561
  mimeType = extensionToMimeType(fileExtension || '');
6534
6562
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
6535
- case 3:
6536
- if (!(_f.sent())) {
6563
+ case 6:
6564
+ if (!(_l.sent())) {
6537
6565
  throw new NotFoundError(spaceTrim(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 "); }));
6538
6566
  }
6539
6567
  // TODO: [๐Ÿง ][๐Ÿ˜ฟ] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
@@ -6579,7 +6607,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6579
6607
  });
6580
6608
  },
6581
6609
  }];
6582
- case 4: return [2 /*return*/, {
6610
+ case 7: return [2 /*return*/, {
6583
6611
  source: name,
6584
6612
  filename: null,
6585
6613
  url: null,