@promptbook/remote-server 0.84.0-21 → 0.84.0-9

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 (38) hide show
  1. package/README.md +5 -21
  2. package/esm/index.es.js +125 -277
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/cli.index.d.ts +0 -4
  5. package/esm/typings/src/_packages/core.index.d.ts +2 -12
  6. package/esm/typings/src/_packages/types.index.d.ts +0 -2
  7. package/esm/typings/src/_packages/utils.index.d.ts +0 -2
  8. package/esm/typings/src/_packages/wizzard.index.d.ts +0 -4
  9. package/esm/typings/src/cli/cli-commands/about.d.ts +1 -3
  10. package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -3
  11. package/esm/typings/src/cli/cli-commands/list-models.d.ts +1 -3
  12. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -3
  13. package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -3
  14. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -3
  15. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
  16. package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -3
  17. package/esm/typings/src/config.d.ts +1 -27
  18. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
  19. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  20. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -3
  21. package/esm/typings/src/pipeline/book-notation.d.ts +2 -3
  22. package/esm/typings/src/pipeline/prompt-notation.d.ts +5 -18
  23. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
  24. package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +2 -5
  25. package/esm/typings/src/wizzard/wizzard.d.ts +1 -7
  26. package/package.json +16 -9
  27. package/umd/index.umd.js +125 -277
  28. package/umd/index.umd.js.map +1 -1
  29. package/esm/typings/src/_packages/deepseek.index.d.ts +0 -8
  30. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +0 -13
  31. package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +0 -9
  32. package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +0 -14
  33. package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +0 -14
  34. package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +0 -15
  35. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +0 -1
  36. package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +0 -1
  37. package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +0 -10
  38. package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +0 -1
package/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('http'), require('socket.io'), require('spacetrim'), require('child_process'), require('waitasecond'), require('fs/promises'), require('path'), require('prettier'), require('prettier/parser-html'), require('papaparse'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'colors', 'http', 'socket.io', 'spacetrim', 'child_process', 'waitasecond', 'fs/promises', 'path', 'prettier', 'prettier/parser-html', 'papaparse', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.http, global.socket_io, global.spaceTrim, global.child_process, global.waitasecond, global.promises, global.path, global.prettier, global.parserHtml, global.papaparse, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes));
5
- })(this, (function (exports, colors, http, socket_io, spaceTrim, child_process, waitasecond, promises, path, prettier, parserHtml, papaparse, hexEncoder, sha256, cryptoJs, mimeTypes) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('http'), require('socket.io'), require('spacetrim'), require('child_process'), require('waitasecond'), require('fs/promises'), require('path'), require('prettier'), require('prettier/parser-html'), require('papaparse'), require('crypto-js'), require('crypto-js/enc-hex'), require('mime-types')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'colors', 'http', 'socket.io', 'spacetrim', 'child_process', 'waitasecond', 'fs/promises', 'path', 'prettier', 'prettier/parser-html', 'papaparse', 'crypto-js', 'crypto-js/enc-hex', 'mime-types'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.http, global.socket_io, global.spaceTrim, global.child_process, global.waitasecond, global.promises, global.path, global.prettier, global.parserHtml, global.papaparse, global.cryptoJs, global.hexEncoder, global.mimeTypes));
5
+ })(this, (function (exports, colors, http, socket_io, spaceTrim, child_process, waitasecond, promises, path, prettier, parserHtml, papaparse, cryptoJs, hexEncoder, mimeTypes) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -11,7 +11,6 @@
11
11
  var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
12
12
  var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
13
13
  var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
14
- var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
15
14
 
16
15
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
17
16
  /**
@@ -27,7 +26,7 @@
27
26
  * @generated
28
27
  * @see https://github.com/webgptorg/promptbook
29
28
  */
30
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-20';
29
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-8';
31
30
  /**
32
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -198,12 +197,6 @@
198
197
  * @public exported from `@promptbook/core`
199
198
  */
200
199
  var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
201
- /**
202
- * Maximum file size limit
203
- *
204
- * @public exported from `@promptbook/core`
205
- */
206
- var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
207
200
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
208
201
  /**
209
202
  * The maximum number of iterations for a loops
@@ -237,12 +230,6 @@
237
230
  * @private within the repository - too low-level in comparison with other `MAX_...`
238
231
  */
239
232
  var IMMEDIATE_TIME = 10;
240
- /**
241
- * The maximum length of the (generated) filename
242
- *
243
- * @public exported from `@promptbook/core`
244
- */
245
- var MAX_FILENAME_LENGTH = 30;
246
233
  /**
247
234
  * Strategy for caching the intermediate results for knowledge sources
248
235
  *
@@ -262,15 +249,6 @@
262
249
  * @public exported from `@promptbook/core`
263
250
  */
264
251
  var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
265
- // <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
266
- /**
267
- * Where to store the temporary downloads
268
- *
269
- * Note: When the folder does not exist, it is created recursively
270
- *
271
- * @public exported from `@promptbook/core`
272
- */
273
- var DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
274
252
  /**
275
253
  * Where to store the scrape cache
276
254
  *
@@ -879,7 +857,6 @@
879
857
  readFile: promises.readFile,
880
858
  writeFile: promises.writeFile,
881
859
  readdir: promises.readdir,
882
- mkdir: promises.mkdir,
883
860
  };
884
861
  }
885
862
  /**
@@ -1334,7 +1311,7 @@
1334
1311
  if (!(error_1 instanceof Error) || error_1 instanceof UnexpectedError) {
1335
1312
  throw error_1;
1336
1313
  }
1337
- errors.push({ llmExecutionTools: llmExecutionTools, error: error_1 });
1314
+ errors.push(error_1);
1338
1315
  return [3 /*break*/, 13];
1339
1316
  case 13:
1340
1317
  _b = _a.next();
@@ -1361,10 +1338,7 @@
1361
1338
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
1362
1339
  // 3) ...
1363
1340
  spaceTrim__default["default"](function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
1364
- .map(function (_a, i) {
1365
- var error = _a.error, llmExecutionTools = _a.llmExecutionTools;
1366
- return "".concat(i + 1, ") **").concat(llmExecutionTools.title, "** thrown **").concat(error.name || 'Error', ":** ").concat(error.message);
1367
- })
1341
+ .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
1368
1342
  .join('\n')), "\n\n "); }));
1369
1343
  }
1370
1344
  else if (this.llmExecutionTools.length === 0) {
@@ -1782,99 +1756,6 @@
1782
1756
 
1783
1757
  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"}];
1784
1758
 
1785
- /**
1786
- * Checks if value is valid email
1787
- *
1788
- * @public exported from `@promptbook/utils`
1789
- */
1790
- function isValidEmail(email) {
1791
- if (typeof email !== 'string') {
1792
- return false;
1793
- }
1794
- if (email.split('\n').length > 1) {
1795
- return false;
1796
- }
1797
- return /^.+@.+\..+$/.test(email);
1798
- }
1799
-
1800
- /**
1801
- * Tests if given string is valid URL.
1802
- *
1803
- * Note: This does not check if the file exists only if the path is valid
1804
- * @public exported from `@promptbook/utils`
1805
- */
1806
- function isValidFilePath(filename) {
1807
- if (typeof filename !== 'string') {
1808
- return false;
1809
- }
1810
- if (filename.split('\n').length > 1) {
1811
- return false;
1812
- }
1813
- if (filename.split(' ').length >
1814
- 5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
1815
- return false;
1816
- }
1817
- var filenameSlashes = filename.split('\\').join('/');
1818
- // Absolute Unix path: /hello.txt
1819
- if (/^(\/)/i.test(filenameSlashes)) {
1820
- // console.log(filename, 'Absolute Unix path: /hello.txt');
1821
- return true;
1822
- }
1823
- // Absolute Windows path: /hello.txt
1824
- if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
1825
- // console.log(filename, 'Absolute Windows path: /hello.txt');
1826
- return true;
1827
- }
1828
- // Relative path: ./hello.txt
1829
- if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
1830
- // console.log(filename, 'Relative path: ./hello.txt');
1831
- return true;
1832
- }
1833
- // Allow paths like foo/hello
1834
- if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
1835
- // console.log(filename, 'Allow paths like foo/hello');
1836
- return true;
1837
- }
1838
- // Allow paths like hello.book
1839
- if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
1840
- // console.log(filename, 'Allow paths like hello.book');
1841
- return true;
1842
- }
1843
- return false;
1844
- }
1845
- /**
1846
- * TODO: [🍏] Implement for MacOs
1847
- */
1848
-
1849
- /**
1850
- * Tests if given string is valid URL.
1851
- *
1852
- * Note: Dataurl are considered perfectly valid.
1853
- * Note: There are two simmilar functions:
1854
- * - `isValidUrl` which tests any URL
1855
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
1856
- *
1857
- * @public exported from `@promptbook/utils`
1858
- */
1859
- function isValidUrl(url) {
1860
- if (typeof url !== 'string') {
1861
- return false;
1862
- }
1863
- try {
1864
- if (url.startsWith('blob:')) {
1865
- url = url.replace(/^blob:/, '');
1866
- }
1867
- var urlObject = new URL(url /* because fail is handled */);
1868
- if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
1869
- return false;
1870
- }
1871
- return true;
1872
- }
1873
- catch (error) {
1874
- return false;
1875
- }
1876
- }
1877
-
1878
1759
  /**
1879
1760
  * Function isValidJsonString will tell you if the string is valid JSON or not
1880
1761
  *
@@ -1909,15 +1790,6 @@
1909
1790
  if (isValidJsonString(pipelineString)) {
1910
1791
  throw new ParseError('Expected a book, but got a JSON string');
1911
1792
  }
1912
- else if (isValidUrl(pipelineString)) {
1913
- throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
1914
- }
1915
- else if (isValidFilePath(pipelineString)) {
1916
- throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
1917
- }
1918
- else if (isValidEmail(pipelineString)) {
1919
- throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
1920
- }
1921
1793
  // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
1922
1794
  return pipelineString;
1923
1795
  }
@@ -2561,6 +2433,35 @@
2561
2433
  return isHostnameOnPrivateNetwork(url.hostname);
2562
2434
  }
2563
2435
 
2436
+ /**
2437
+ * Tests if given string is valid URL.
2438
+ *
2439
+ * Note: Dataurl are considered perfectly valid.
2440
+ * Note: There are two simmilar functions:
2441
+ * - `isValidUrl` which tests any URL
2442
+ * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
2443
+ *
2444
+ * @public exported from `@promptbook/utils`
2445
+ */
2446
+ function isValidUrl(url) {
2447
+ if (typeof url !== 'string') {
2448
+ return false;
2449
+ }
2450
+ try {
2451
+ if (url.startsWith('blob:')) {
2452
+ url = url.replace(/^blob:/, '');
2453
+ }
2454
+ var urlObject = new URL(url /* because fail is handled */);
2455
+ if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
2456
+ return false;
2457
+ }
2458
+ return true;
2459
+ }
2460
+ catch (error) {
2461
+ return false;
2462
+ }
2463
+ }
2464
+
2564
2465
  /**
2565
2466
  * Tests if given string is valid pipeline URL URL.
2566
2467
  *
@@ -3060,28 +2961,12 @@
3060
2961
  /**
3061
2962
  * Asserts that the execution of a Promptbook is successful
3062
2963
  *
3063
- * Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
3064
- *
3065
2964
  * @param executionResult - The partial result of the Promptbook execution
3066
2965
  * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
3067
2966
  * @public exported from `@promptbook/core`
3068
2967
  */
3069
2968
  function assertsExecutionSuccessful(executionResult) {
3070
- var e_1, _a;
3071
- var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
3072
- try {
3073
- for (var warnings_1 = __values(warnings), warnings_1_1 = warnings_1.next(); !warnings_1_1.done; warnings_1_1 = warnings_1.next()) {
3074
- var warning = warnings_1_1.value;
3075
- console.warn(warning.message);
3076
- }
3077
- }
3078
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3079
- finally {
3080
- try {
3081
- if (warnings_1_1 && !warnings_1_1.done && (_a = warnings_1.return)) _a.call(warnings_1);
3082
- }
3083
- finally { if (e_1) throw e_1.error; }
3084
- }
2969
+ var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
3085
2970
  if (isSuccessful === true) {
3086
2971
  return;
3087
2972
  }
@@ -6090,15 +5975,6 @@
6090
5975
  * TODO: [🐱‍🐉][🧠] Make some smart crop NOT source-i-m-pavol-a-develop-... BUT source-i-m-pavol-a-developer-...
6091
5976
  */
6092
5977
 
6093
- /**
6094
- * @@@
6095
- *
6096
- * @private for `FileCacheStorage`
6097
- */
6098
- function nameToSubfolderPath(name) {
6099
- return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
6100
- }
6101
-
6102
5978
  /**
6103
5979
  * Convert file extension to mime type
6104
5980
  *
@@ -6155,55 +6031,53 @@
6155
6031
  */
6156
6032
 
6157
6033
  /**
6158
- * Convert mime type to file extension
6159
- *
6160
- * Note: If the mime type is invalid, `null` is returned
6161
- *
6162
- * @private within the repository
6163
- */
6164
- function mimeTypeToExtension(value) {
6165
- return mimeTypes.extension(value) || null;
6166
- }
6167
-
6168
- /**
6169
- * Removes emojis from a string and fix whitespaces
6170
- *
6171
- * @param text with emojis
6172
- * @returns text without emojis
6173
- * @public exported from `@promptbook/utils`
6174
- */
6175
- function removeEmojis(text) {
6176
- // Replace emojis (and also ZWJ sequence) with hyphens
6177
- text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
6178
- text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
6179
- text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
6180
- text = text.replace(/\p{Extended_Pictographic}/gu, '');
6181
- return text;
6182
- }
6183
-
6184
- /**
6185
- * @@@
6034
+ * Tests if given string is valid URL.
6186
6035
  *
6187
- * @param value @@@
6188
- * @returns @@@
6189
- * @example @@@
6036
+ * Note: This does not check if the file exists only if the path is valid
6190
6037
  * @public exported from `@promptbook/utils`
6191
6038
  */
6192
- function titleToName(value) {
6193
- if (isValidUrl(value)) {
6194
- value = value.replace(/^https?:\/\//, '');
6195
- value = value.replace(/\.html$/, '');
6039
+ function isValidFilePath(filename) {
6040
+ if (typeof filename !== 'string') {
6041
+ return false;
6196
6042
  }
6197
- else if (isValidFilePath(value)) {
6198
- value = path.basename(value);
6199
- // Note: Keeping extension in the name
6043
+ if (filename.split('\n').length > 1) {
6044
+ return false;
6200
6045
  }
6201
- value = value.split('/').join('-');
6202
- value = removeEmojis(value);
6203
- value = normalizeToKebabCase(value);
6204
- // TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
6205
- return value;
6046
+ if (filename.split(' ').length >
6047
+ 5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
6048
+ return false;
6049
+ }
6050
+ var filenameSlashes = filename.split('\\').join('/');
6051
+ // Absolute Unix path: /hello.txt
6052
+ if (/^(\/)/i.test(filenameSlashes)) {
6053
+ // console.log(filename, 'Absolute Unix path: /hello.txt');
6054
+ return true;
6055
+ }
6056
+ // Absolute Windows path: /hello.txt
6057
+ if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
6058
+ // console.log(filename, 'Absolute Windows path: /hello.txt');
6059
+ return true;
6060
+ }
6061
+ // Relative path: ./hello.txt
6062
+ if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
6063
+ // console.log(filename, 'Relative path: ./hello.txt');
6064
+ return true;
6065
+ }
6066
+ // Allow paths like foo/hello
6067
+ if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
6068
+ // console.log(filename, 'Allow paths like foo/hello');
6069
+ return true;
6070
+ }
6071
+ // Allow paths like hello.book
6072
+ if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
6073
+ // console.log(filename, 'Allow paths like hello.book');
6074
+ return true;
6075
+ }
6076
+ return false;
6206
6077
  }
6078
+ /**
6079
+ * TODO: [🍏] Implement for MacOs
6080
+ */
6207
6081
 
6208
6082
  /**
6209
6083
  * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
@@ -6240,9 +6114,9 @@
6240
6114
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6241
6115
  var _a;
6242
6116
  return __awaiter(this, void 0, void 0, function () {
6243
- var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
6244
- return __generator(this, function (_h) {
6245
- switch (_h.label) {
6117
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
6118
+ return __generator(this, function (_f) {
6119
+ switch (_f.label) {
6246
6120
  case 0:
6247
6121
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
6248
6122
  knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
@@ -6251,76 +6125,54 @@
6251
6125
  if (!name) {
6252
6126
  name = knowledgeSourceContentToName(knowledgeSourceContent);
6253
6127
  }
6254
- if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 5];
6128
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
6255
6129
  url = knowledgeSourceContent;
6256
6130
  return [4 /*yield*/, fetch(url)];
6257
6131
  case 1:
6258
- response_1 = _h.sent();
6132
+ response_1 = _f.sent();
6259
6133
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
6260
- if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [💵] */)) {
6261
- return [2 /*return*/, {
6262
- source: name,
6263
- filename: null,
6264
- url: url,
6265
- mimeType: mimeType,
6266
- /*
6267
- TODO: [🥽]
6268
- > async asBlob() {
6269
- > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
6270
- > const content = await response.blob();
6271
- > return content;
6272
- > },
6273
- */
6274
- asJson: function () {
6275
- return __awaiter(this, void 0, void 0, function () {
6276
- var content;
6277
- return __generator(this, function (_a) {
6278
- switch (_a.label) {
6279
- case 0: return [4 /*yield*/, response_1.json()];
6280
- case 1:
6281
- content = _a.sent();
6282
- return [2 /*return*/, content];
6283
- }
6284
- });
6134
+ return [2 /*return*/, {
6135
+ source: name,
6136
+ filename: null,
6137
+ url: url,
6138
+ mimeType: mimeType,
6139
+ /*
6140
+ TODO: [🥽]
6141
+ > async asBlob() {
6142
+ > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
6143
+ > const content = await response.blob();
6144
+ > return content;
6145
+ > },
6146
+ */
6147
+ asJson: function () {
6148
+ return __awaiter(this, void 0, void 0, function () {
6149
+ var content;
6150
+ return __generator(this, function (_a) {
6151
+ switch (_a.label) {
6152
+ case 0: return [4 /*yield*/, response_1.json()];
6153
+ case 1:
6154
+ content = _a.sent();
6155
+ return [2 /*return*/, content];
6156
+ }
6285
6157
  });
6286
- },
6287
- asText: function () {
6288
- return __awaiter(this, void 0, void 0, function () {
6289
- var content;
6290
- return __generator(this, function (_a) {
6291
- switch (_a.label) {
6292
- case 0: return [4 /*yield*/, response_1.text()];
6293
- case 1:
6294
- content = _a.sent();
6295
- return [2 /*return*/, content];
6296
- }
6297
- });
6158
+ });
6159
+ },
6160
+ asText: function () {
6161
+ return __awaiter(this, void 0, void 0, function () {
6162
+ var content;
6163
+ return __generator(this, function (_a) {
6164
+ switch (_a.label) {
6165
+ case 0: return [4 /*yield*/, response_1.text()];
6166
+ case 1:
6167
+ content = _a.sent();
6168
+ return [2 /*return*/, content];
6169
+ }
6298
6170
  });
6299
- },
6300
- }];
6301
- }
6302
- basename = url.split('/').pop() || titleToName(url);
6303
- hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
6304
- rootDirname_1 = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
6305
- filepath = path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".").concat(mimeTypeToExtension(mimeType))], false));
6306
- return [4 /*yield*/, tools.fs.mkdir(path.dirname(path.join(rootDirname_1, filepath)), { recursive: true })];
6171
+ });
6172
+ },
6173
+ }];
6307
6174
  case 2:
6308
- _h.sent();
6309
- _g = (_f = Buffer).from;
6310
- return [4 /*yield*/, response_1.arrayBuffer()];
6311
- case 3:
6312
- fileContent = _g.apply(_f, [_h.sent()]);
6313
- if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
6314
- throw new LimitReachedError("File is too large (".concat(Math.round(fileContent.length / 1024 / 1024), "MB). Maximum allowed size is ").concat(Math.round(DEFAULT_MAX_FILE_SIZE / 1024 / 1024), "MB."));
6315
- }
6316
- return [4 /*yield*/, tools.fs.writeFile(path.join(rootDirname_1, filepath), fileContent)];
6317
- case 4:
6318
- _h.sent();
6319
- // TODO: [💵] Check the file security
6320
- // TODO: [🧹][🧠] Delete the file after the scraping is done
6321
- return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
6322
- case 5:
6323
- if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
6175
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
6324
6176
  if (tools.fs === undefined) {
6325
6177
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
6326
6178
  // <- TODO: [🧠] What is the best error type here`
@@ -6333,8 +6185,8 @@
6333
6185
  fileExtension = getFileExtension(filename_1);
6334
6186
  mimeType = extensionToMimeType(fileExtension || '');
6335
6187
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
6336
- case 6:
6337
- if (!(_h.sent())) {
6188
+ case 3:
6189
+ if (!(_f.sent())) {
6338
6190
  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 "); }));
6339
6191
  }
6340
6192
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
@@ -6380,7 +6232,7 @@
6380
6232
  });
6381
6233
  },
6382
6234
  }];
6383
- case 7: return [2 /*return*/, {
6235
+ case 4: return [2 /*return*/, {
6384
6236
  source: name,
6385
6237
  filename: null,
6386
6238
  url: null,
@@ -6750,10 +6602,6 @@
6750
6602
  return [4 /*yield*/, scraperFactory(tools, options || {})];
6751
6603
  case 3:
6752
6604
  scraper = _g.sent();
6753
- if (scraper.metadata.packageName === '@promptbook/boilerplate' ||
6754
- scraper.metadata.mimeTypes.some(function (mimeType) { return mimeType.includes('DISABLED'); })) {
6755
- return [3 /*break*/, 4];
6756
- }
6757
6605
  scrapers.push(scraper);
6758
6606
  _g.label = 4;
6759
6607
  case 4: