@promptbook/remote-server 0.84.0-9 → 0.84.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.
- package/README.md +21 -9
- package/esm/index.es.js +283 -127
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +12 -2
- package/esm/typings/src/_packages/deepseek.index.d.ts +8 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/_packages/wizzard.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/about.d.ts +4 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +13 -0
- package/esm/typings/src/cli/cli-commands/make.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +3 -1
- package/esm/typings/src/config.d.ts +27 -1
- package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +3 -1
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +9 -0
- package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +9 -0
- package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +14 -0
- package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +14 -0
- package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +15 -0
- package/esm/typings/src/pipeline/book-notation.d.ts +3 -2
- package/esm/typings/src/pipeline/prompt-notation.d.ts +18 -5
- package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +5 -2
- package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +1 -0
- package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +1 -0
- package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +3 -0
- package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +3 -0
- package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +3 -0
- package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +3 -0
- package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +10 -0
- package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +1 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +7 -1
- package/package.json +9 -16
- package/umd/index.umd.js +283 -127
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -4,14 +4,15 @@ import { Server } from 'socket.io';
|
|
|
4
4
|
import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
5
5
|
import { spawn } from 'child_process';
|
|
6
6
|
import { forTime } from 'waitasecond';
|
|
7
|
-
import { stat, access, constants, readFile, writeFile, readdir } from 'fs/promises';
|
|
8
|
-
import { join } from 'path';
|
|
7
|
+
import { stat, access, constants, readFile, writeFile, readdir, mkdir } from 'fs/promises';
|
|
8
|
+
import { join, basename, dirname } from 'path';
|
|
9
9
|
import { format } from 'prettier';
|
|
10
10
|
import parserHtml from 'prettier/parser-html';
|
|
11
11
|
import { unparse, parse } from 'papaparse';
|
|
12
|
-
import { SHA256 } from 'crypto-js';
|
|
13
12
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
14
|
-
import
|
|
13
|
+
import sha256 from 'crypto-js/sha256';
|
|
14
|
+
import { SHA256 } from 'crypto-js';
|
|
15
|
+
import { lookup, extension } from 'mime-types';
|
|
15
16
|
|
|
16
17
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
17
18
|
/**
|
|
@@ -27,7 +28,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
27
28
|
* @generated
|
|
28
29
|
* @see https://github.com/webgptorg/promptbook
|
|
29
30
|
*/
|
|
30
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-
|
|
31
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.84.0-21';
|
|
31
32
|
/**
|
|
32
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -198,6 +199,12 @@ var ADMIN_GITHUB_NAME = 'hejny';
|
|
|
198
199
|
* @public exported from `@promptbook/core`
|
|
199
200
|
*/
|
|
200
201
|
var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
|
|
202
|
+
/**
|
|
203
|
+
* Maximum file size limit
|
|
204
|
+
*
|
|
205
|
+
* @public exported from `@promptbook/core`
|
|
206
|
+
*/
|
|
207
|
+
var DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
|
201
208
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
202
209
|
/**
|
|
203
210
|
* The maximum number of iterations for a loops
|
|
@@ -231,6 +238,12 @@ var SMALL_NUMBER = 0.001;
|
|
|
231
238
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
232
239
|
*/
|
|
233
240
|
var IMMEDIATE_TIME = 10;
|
|
241
|
+
/**
|
|
242
|
+
* The maximum length of the (generated) filename
|
|
243
|
+
*
|
|
244
|
+
* @public exported from `@promptbook/core`
|
|
245
|
+
*/
|
|
246
|
+
var MAX_FILENAME_LENGTH = 30;
|
|
234
247
|
/**
|
|
235
248
|
* Strategy for caching the intermediate results for knowledge sources
|
|
236
249
|
*
|
|
@@ -250,6 +263,15 @@ var DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
|
250
263
|
* @public exported from `@promptbook/core`
|
|
251
264
|
*/
|
|
252
265
|
var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹♂️]
|
|
266
|
+
// <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
267
|
+
/**
|
|
268
|
+
* Where to store the temporary downloads
|
|
269
|
+
*
|
|
270
|
+
* Note: When the folder does not exist, it is created recursively
|
|
271
|
+
*
|
|
272
|
+
* @public exported from `@promptbook/core`
|
|
273
|
+
*/
|
|
274
|
+
var DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
|
|
253
275
|
/**
|
|
254
276
|
* Where to store the scrape cache
|
|
255
277
|
*
|
|
@@ -645,6 +667,9 @@ function serializeError(error) {
|
|
|
645
667
|
* @public exported from `@promptbook/utils`
|
|
646
668
|
*/
|
|
647
669
|
var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
|
|
670
|
+
/**
|
|
671
|
+
* TODO: [☑]
|
|
672
|
+
*/
|
|
648
673
|
|
|
649
674
|
/**
|
|
650
675
|
* Normalize options for `execCommand` and `execCommands`
|
|
@@ -858,6 +883,7 @@ function $provideFilesystemForNode(options) {
|
|
|
858
883
|
readFile: readFile,
|
|
859
884
|
writeFile: writeFile,
|
|
860
885
|
readdir: readdir,
|
|
886
|
+
mkdir: mkdir,
|
|
861
887
|
};
|
|
862
888
|
}
|
|
863
889
|
/**
|
|
@@ -1312,7 +1338,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
1312
1338
|
if (!(error_1 instanceof Error) || error_1 instanceof UnexpectedError) {
|
|
1313
1339
|
throw error_1;
|
|
1314
1340
|
}
|
|
1315
|
-
errors.push(error_1);
|
|
1341
|
+
errors.push({ llmExecutionTools: llmExecutionTools, error: error_1 });
|
|
1316
1342
|
return [3 /*break*/, 13];
|
|
1317
1343
|
case 13:
|
|
1318
1344
|
_b = _a.next();
|
|
@@ -1339,7 +1365,10 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
1339
1365
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
1340
1366
|
// 3) ...
|
|
1341
1367
|
spaceTrim$1(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
1342
|
-
.map(function (
|
|
1368
|
+
.map(function (_a, i) {
|
|
1369
|
+
var error = _a.error, llmExecutionTools = _a.llmExecutionTools;
|
|
1370
|
+
return "".concat(i + 1, ") **").concat(llmExecutionTools.title, "** thrown **").concat(error.name || 'Error', ":** ").concat(error.message);
|
|
1371
|
+
})
|
|
1343
1372
|
.join('\n')), "\n\n "); }));
|
|
1344
1373
|
}
|
|
1345
1374
|
else if (this.llmExecutionTools.length === 0) {
|
|
@@ -1652,10 +1681,11 @@ function $registeredLlmToolsMessage() {
|
|
|
1652
1681
|
// <- Note: [🗨]
|
|
1653
1682
|
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isFullyConfigured: isFullyConfigured, isPartiallyConfigured: isPartiallyConfigured });
|
|
1654
1683
|
});
|
|
1684
|
+
var usedEnvMessage = "Unknown `.env` file" ;
|
|
1655
1685
|
if (metadata.length === 0) {
|
|
1656
|
-
return "No LLM providers are available.";
|
|
1686
|
+
return spaceTrim$1(function (block) { return "\n No LLM providers are available.\n\n ".concat(block(usedEnvMessage), "\n "); });
|
|
1657
1687
|
}
|
|
1658
|
-
return spaceTrim$1(function (block) { return "\n Relevant environment variables:\n ".concat(block(Object.keys(env)
|
|
1688
|
+
return spaceTrim$1(function (block) { return "\n\n ".concat(block(usedEnvMessage), "\n\n Relevant environment variables:\n ").concat(block(Object.keys(env)
|
|
1659
1689
|
.filter(function (envVariableName) {
|
|
1660
1690
|
return metadata.some(function (_a) {
|
|
1661
1691
|
var envVariables = _a.envVariables;
|
|
@@ -1757,6 +1787,99 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
1757
1787
|
|
|
1758
1788
|
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"}];
|
|
1759
1789
|
|
|
1790
|
+
/**
|
|
1791
|
+
* Checks if value is valid email
|
|
1792
|
+
*
|
|
1793
|
+
* @public exported from `@promptbook/utils`
|
|
1794
|
+
*/
|
|
1795
|
+
function isValidEmail(email) {
|
|
1796
|
+
if (typeof email !== 'string') {
|
|
1797
|
+
return false;
|
|
1798
|
+
}
|
|
1799
|
+
if (email.split('\n').length > 1) {
|
|
1800
|
+
return false;
|
|
1801
|
+
}
|
|
1802
|
+
return /^.+@.+\..+$/.test(email);
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
/**
|
|
1806
|
+
* Tests if given string is valid URL.
|
|
1807
|
+
*
|
|
1808
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
1809
|
+
* @public exported from `@promptbook/utils`
|
|
1810
|
+
*/
|
|
1811
|
+
function isValidFilePath(filename) {
|
|
1812
|
+
if (typeof filename !== 'string') {
|
|
1813
|
+
return false;
|
|
1814
|
+
}
|
|
1815
|
+
if (filename.split('\n').length > 1) {
|
|
1816
|
+
return false;
|
|
1817
|
+
}
|
|
1818
|
+
if (filename.split(' ').length >
|
|
1819
|
+
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
1820
|
+
return false;
|
|
1821
|
+
}
|
|
1822
|
+
var filenameSlashes = filename.split('\\').join('/');
|
|
1823
|
+
// Absolute Unix path: /hello.txt
|
|
1824
|
+
if (/^(\/)/i.test(filenameSlashes)) {
|
|
1825
|
+
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
1826
|
+
return true;
|
|
1827
|
+
}
|
|
1828
|
+
// Absolute Windows path: /hello.txt
|
|
1829
|
+
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
1830
|
+
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
1831
|
+
return true;
|
|
1832
|
+
}
|
|
1833
|
+
// Relative path: ./hello.txt
|
|
1834
|
+
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
1835
|
+
// console.log(filename, 'Relative path: ./hello.txt');
|
|
1836
|
+
return true;
|
|
1837
|
+
}
|
|
1838
|
+
// Allow paths like foo/hello
|
|
1839
|
+
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
1840
|
+
// console.log(filename, 'Allow paths like foo/hello');
|
|
1841
|
+
return true;
|
|
1842
|
+
}
|
|
1843
|
+
// Allow paths like hello.book
|
|
1844
|
+
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
1845
|
+
// console.log(filename, 'Allow paths like hello.book');
|
|
1846
|
+
return true;
|
|
1847
|
+
}
|
|
1848
|
+
return false;
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* TODO: [🍏] Implement for MacOs
|
|
1852
|
+
*/
|
|
1853
|
+
|
|
1854
|
+
/**
|
|
1855
|
+
* Tests if given string is valid URL.
|
|
1856
|
+
*
|
|
1857
|
+
* Note: Dataurl are considered perfectly valid.
|
|
1858
|
+
* Note: There are two simmilar functions:
|
|
1859
|
+
* - `isValidUrl` which tests any URL
|
|
1860
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
1861
|
+
*
|
|
1862
|
+
* @public exported from `@promptbook/utils`
|
|
1863
|
+
*/
|
|
1864
|
+
function isValidUrl(url) {
|
|
1865
|
+
if (typeof url !== 'string') {
|
|
1866
|
+
return false;
|
|
1867
|
+
}
|
|
1868
|
+
try {
|
|
1869
|
+
if (url.startsWith('blob:')) {
|
|
1870
|
+
url = url.replace(/^blob:/, '');
|
|
1871
|
+
}
|
|
1872
|
+
var urlObject = new URL(url /* because fail is handled */);
|
|
1873
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1876
|
+
return true;
|
|
1877
|
+
}
|
|
1878
|
+
catch (error) {
|
|
1879
|
+
return false;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1760
1883
|
/**
|
|
1761
1884
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1762
1885
|
*
|
|
@@ -1791,6 +1914,15 @@ function validatePipelineString(pipelineString) {
|
|
|
1791
1914
|
if (isValidJsonString(pipelineString)) {
|
|
1792
1915
|
throw new ParseError('Expected a book, but got a JSON string');
|
|
1793
1916
|
}
|
|
1917
|
+
else if (isValidUrl(pipelineString)) {
|
|
1918
|
+
throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
|
|
1919
|
+
}
|
|
1920
|
+
else if (isValidFilePath(pipelineString)) {
|
|
1921
|
+
throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
|
|
1922
|
+
}
|
|
1923
|
+
else if (isValidEmail(pipelineString)) {
|
|
1924
|
+
throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
|
|
1925
|
+
}
|
|
1794
1926
|
// <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
|
|
1795
1927
|
return pipelineString;
|
|
1796
1928
|
}
|
|
@@ -2434,35 +2566,6 @@ function isUrlOnPrivateNetwork(url) {
|
|
|
2434
2566
|
return isHostnameOnPrivateNetwork(url.hostname);
|
|
2435
2567
|
}
|
|
2436
2568
|
|
|
2437
|
-
/**
|
|
2438
|
-
* Tests if given string is valid URL.
|
|
2439
|
-
*
|
|
2440
|
-
* Note: Dataurl are considered perfectly valid.
|
|
2441
|
-
* Note: There are two simmilar functions:
|
|
2442
|
-
* - `isValidUrl` which tests any URL
|
|
2443
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
2444
|
-
*
|
|
2445
|
-
* @public exported from `@promptbook/utils`
|
|
2446
|
-
*/
|
|
2447
|
-
function isValidUrl(url) {
|
|
2448
|
-
if (typeof url !== 'string') {
|
|
2449
|
-
return false;
|
|
2450
|
-
}
|
|
2451
|
-
try {
|
|
2452
|
-
if (url.startsWith('blob:')) {
|
|
2453
|
-
url = url.replace(/^blob:/, '');
|
|
2454
|
-
}
|
|
2455
|
-
var urlObject = new URL(url /* because fail is handled */);
|
|
2456
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
2457
|
-
return false;
|
|
2458
|
-
}
|
|
2459
|
-
return true;
|
|
2460
|
-
}
|
|
2461
|
-
catch (error) {
|
|
2462
|
-
return false;
|
|
2463
|
-
}
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
2569
|
/**
|
|
2467
2570
|
* Tests if given string is valid pipeline URL URL.
|
|
2468
2571
|
*
|
|
@@ -2962,12 +3065,28 @@ function deserializeError(error) {
|
|
|
2962
3065
|
/**
|
|
2963
3066
|
* Asserts that the execution of a Promptbook is successful
|
|
2964
3067
|
*
|
|
3068
|
+
* Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
|
|
3069
|
+
*
|
|
2965
3070
|
* @param executionResult - The partial result of the Promptbook execution
|
|
2966
3071
|
* @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
|
|
2967
3072
|
* @public exported from `@promptbook/core`
|
|
2968
3073
|
*/
|
|
2969
3074
|
function assertsExecutionSuccessful(executionResult) {
|
|
2970
|
-
var
|
|
3075
|
+
var e_1, _a;
|
|
3076
|
+
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
|
|
3077
|
+
try {
|
|
3078
|
+
for (var warnings_1 = __values(warnings), warnings_1_1 = warnings_1.next(); !warnings_1_1.done; warnings_1_1 = warnings_1.next()) {
|
|
3079
|
+
var warning = warnings_1_1.value;
|
|
3080
|
+
console.warn(warning.message);
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3084
|
+
finally {
|
|
3085
|
+
try {
|
|
3086
|
+
if (warnings_1_1 && !warnings_1_1.done && (_a = warnings_1.return)) _a.call(warnings_1);
|
|
3087
|
+
}
|
|
3088
|
+
finally { if (e_1) throw e_1.error; }
|
|
3089
|
+
}
|
|
2971
3090
|
if (isSuccessful === true) {
|
|
2972
3091
|
return;
|
|
2973
3092
|
}
|
|
@@ -5976,6 +6095,15 @@ function knowledgeSourceContentToName(knowledgeSourceContent) {
|
|
|
5976
6095
|
* TODO: [🐱🐉][🧠] Make some smart crop NOT source-i-m-pavol-a-develop-... BUT source-i-m-pavol-a-developer-...
|
|
5977
6096
|
*/
|
|
5978
6097
|
|
|
6098
|
+
/**
|
|
6099
|
+
* @@@
|
|
6100
|
+
*
|
|
6101
|
+
* @private for `FileCacheStorage`
|
|
6102
|
+
*/
|
|
6103
|
+
function nameToSubfolderPath(name) {
|
|
6104
|
+
return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
|
|
6105
|
+
}
|
|
6106
|
+
|
|
5979
6107
|
/**
|
|
5980
6108
|
* Convert file extension to mime type
|
|
5981
6109
|
*
|
|
@@ -6032,53 +6160,55 @@ function isFileExisting(filename, fs) {
|
|
|
6032
6160
|
*/
|
|
6033
6161
|
|
|
6034
6162
|
/**
|
|
6035
|
-
*
|
|
6163
|
+
* Convert mime type to file extension
|
|
6036
6164
|
*
|
|
6037
|
-
* Note:
|
|
6165
|
+
* Note: If the mime type is invalid, `null` is returned
|
|
6166
|
+
*
|
|
6167
|
+
* @private within the repository
|
|
6168
|
+
*/
|
|
6169
|
+
function mimeTypeToExtension(value) {
|
|
6170
|
+
return extension(value) || null;
|
|
6171
|
+
}
|
|
6172
|
+
|
|
6173
|
+
/**
|
|
6174
|
+
* Removes emojis from a string and fix whitespaces
|
|
6175
|
+
*
|
|
6176
|
+
* @param text with emojis
|
|
6177
|
+
* @returns text without emojis
|
|
6038
6178
|
* @public exported from `@promptbook/utils`
|
|
6039
6179
|
*/
|
|
6040
|
-
function
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
}
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
if (filename.split(' ').length >
|
|
6048
|
-
5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
|
|
6049
|
-
return false;
|
|
6050
|
-
}
|
|
6051
|
-
var filenameSlashes = filename.split('\\').join('/');
|
|
6052
|
-
// Absolute Unix path: /hello.txt
|
|
6053
|
-
if (/^(\/)/i.test(filenameSlashes)) {
|
|
6054
|
-
// console.log(filename, 'Absolute Unix path: /hello.txt');
|
|
6055
|
-
return true;
|
|
6056
|
-
}
|
|
6057
|
-
// Absolute Windows path: /hello.txt
|
|
6058
|
-
if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
|
|
6059
|
-
// console.log(filename, 'Absolute Windows path: /hello.txt');
|
|
6060
|
-
return true;
|
|
6061
|
-
}
|
|
6062
|
-
// Relative path: ./hello.txt
|
|
6063
|
-
if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
|
|
6064
|
-
// console.log(filename, 'Relative path: ./hello.txt');
|
|
6065
|
-
return true;
|
|
6066
|
-
}
|
|
6067
|
-
// Allow paths like foo/hello
|
|
6068
|
-
if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
|
|
6069
|
-
// console.log(filename, 'Allow paths like foo/hello');
|
|
6070
|
-
return true;
|
|
6071
|
-
}
|
|
6072
|
-
// Allow paths like hello.book
|
|
6073
|
-
if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
|
|
6074
|
-
// console.log(filename, 'Allow paths like hello.book');
|
|
6075
|
-
return true;
|
|
6076
|
-
}
|
|
6077
|
-
return false;
|
|
6180
|
+
function removeEmojis(text) {
|
|
6181
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
6182
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
6183
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
6184
|
+
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
6185
|
+
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
6186
|
+
return text;
|
|
6078
6187
|
}
|
|
6188
|
+
|
|
6079
6189
|
/**
|
|
6080
|
-
*
|
|
6190
|
+
* @@@
|
|
6191
|
+
*
|
|
6192
|
+
* @param value @@@
|
|
6193
|
+
* @returns @@@
|
|
6194
|
+
* @example @@@
|
|
6195
|
+
* @public exported from `@promptbook/utils`
|
|
6081
6196
|
*/
|
|
6197
|
+
function titleToName(value) {
|
|
6198
|
+
if (isValidUrl(value)) {
|
|
6199
|
+
value = value.replace(/^https?:\/\//, '');
|
|
6200
|
+
value = value.replace(/\.html$/, '');
|
|
6201
|
+
}
|
|
6202
|
+
else if (isValidFilePath(value)) {
|
|
6203
|
+
value = basename(value);
|
|
6204
|
+
// Note: Keeping extension in the name
|
|
6205
|
+
}
|
|
6206
|
+
value = value.split('/').join('-');
|
|
6207
|
+
value = removeEmojis(value);
|
|
6208
|
+
value = normalizeToKebabCase(value);
|
|
6209
|
+
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
6210
|
+
return value;
|
|
6211
|
+
}
|
|
6082
6212
|
|
|
6083
6213
|
/**
|
|
6084
6214
|
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
@@ -6115,9 +6245,9 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
|
|
|
6115
6245
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
6116
6246
|
var _a;
|
|
6117
6247
|
return __awaiter(this, void 0, void 0, function () {
|
|
6118
|
-
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
6119
|
-
return __generator(this, function (
|
|
6120
|
-
switch (
|
|
6248
|
+
var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, fileContent, _f, _g, filename_1, fileExtension, mimeType;
|
|
6249
|
+
return __generator(this, function (_h) {
|
|
6250
|
+
switch (_h.label) {
|
|
6121
6251
|
case 0:
|
|
6122
6252
|
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
6123
6253
|
knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
|
|
@@ -6126,54 +6256,76 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
6126
6256
|
if (!name) {
|
|
6127
6257
|
name = knowledgeSourceContentToName(knowledgeSourceContent);
|
|
6128
6258
|
}
|
|
6129
|
-
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/,
|
|
6259
|
+
if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 5];
|
|
6130
6260
|
url = knowledgeSourceContent;
|
|
6131
6261
|
return [4 /*yield*/, fetch(url)];
|
|
6132
6262
|
case 1:
|
|
6133
|
-
response_1 =
|
|
6263
|
+
response_1 = _h.sent();
|
|
6134
6264
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6265
|
+
if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [💵] */)) {
|
|
6266
|
+
return [2 /*return*/, {
|
|
6267
|
+
source: name,
|
|
6268
|
+
filename: null,
|
|
6269
|
+
url: url,
|
|
6270
|
+
mimeType: mimeType,
|
|
6271
|
+
/*
|
|
6272
|
+
TODO: [🥽]
|
|
6273
|
+
> async asBlob() {
|
|
6274
|
+
> // TODO: [👨🏻🤝👨🏻] This can be called multiple times BUT when called second time, response in already consumed
|
|
6275
|
+
> const content = await response.blob();
|
|
6276
|
+
> return content;
|
|
6277
|
+
> },
|
|
6278
|
+
*/
|
|
6279
|
+
asJson: function () {
|
|
6280
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6281
|
+
var content;
|
|
6282
|
+
return __generator(this, function (_a) {
|
|
6283
|
+
switch (_a.label) {
|
|
6284
|
+
case 0: return [4 /*yield*/, response_1.json()];
|
|
6285
|
+
case 1:
|
|
6286
|
+
content = _a.sent();
|
|
6287
|
+
return [2 /*return*/, content];
|
|
6288
|
+
}
|
|
6289
|
+
});
|
|
6158
6290
|
});
|
|
6159
|
-
}
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
}
|
|
6291
|
+
},
|
|
6292
|
+
asText: function () {
|
|
6293
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6294
|
+
var content;
|
|
6295
|
+
return __generator(this, function (_a) {
|
|
6296
|
+
switch (_a.label) {
|
|
6297
|
+
case 0: return [4 /*yield*/, response_1.text()];
|
|
6298
|
+
case 1:
|
|
6299
|
+
content = _a.sent();
|
|
6300
|
+
return [2 /*return*/, content];
|
|
6301
|
+
}
|
|
6302
|
+
});
|
|
6171
6303
|
});
|
|
6172
|
-
}
|
|
6173
|
-
}
|
|
6174
|
-
|
|
6304
|
+
},
|
|
6305
|
+
}];
|
|
6306
|
+
}
|
|
6307
|
+
basename = url.split('/').pop() || titleToName(url);
|
|
6308
|
+
hash = sha256(hexEncoder.parse(url)).toString( /* hex */);
|
|
6309
|
+
rootDirname_1 = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
6310
|
+
filepath = 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));
|
|
6311
|
+
return [4 /*yield*/, tools.fs.mkdir(dirname(join(rootDirname_1, filepath)), { recursive: true })];
|
|
6175
6312
|
case 2:
|
|
6176
|
-
|
|
6313
|
+
_h.sent();
|
|
6314
|
+
_g = (_f = Buffer).from;
|
|
6315
|
+
return [4 /*yield*/, response_1.arrayBuffer()];
|
|
6316
|
+
case 3:
|
|
6317
|
+
fileContent = _g.apply(_f, [_h.sent()]);
|
|
6318
|
+
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
6319
|
+
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."));
|
|
6320
|
+
}
|
|
6321
|
+
return [4 /*yield*/, tools.fs.writeFile(join(rootDirname_1, filepath), fileContent)];
|
|
6322
|
+
case 4:
|
|
6323
|
+
_h.sent();
|
|
6324
|
+
// TODO: [💵] Check the file security
|
|
6325
|
+
// TODO: [🧹][🧠] Delete the file after the scraping is done
|
|
6326
|
+
return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
|
|
6327
|
+
case 5:
|
|
6328
|
+
if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
|
|
6177
6329
|
if (tools.fs === undefined) {
|
|
6178
6330
|
throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
|
|
6179
6331
|
// <- TODO: [🧠] What is the best error type here`
|
|
@@ -6186,8 +6338,8 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
6186
6338
|
fileExtension = getFileExtension(filename_1);
|
|
6187
6339
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
6188
6340
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
6189
|
-
case
|
|
6190
|
-
if (!(
|
|
6341
|
+
case 6:
|
|
6342
|
+
if (!(_h.sent())) {
|
|
6191
6343
|
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(knowledgeSourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
|
|
6192
6344
|
}
|
|
6193
6345
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
@@ -6233,7 +6385,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
6233
6385
|
});
|
|
6234
6386
|
},
|
|
6235
6387
|
}];
|
|
6236
|
-
case
|
|
6388
|
+
case 7: return [2 /*return*/, {
|
|
6237
6389
|
source: name,
|
|
6238
6390
|
filename: null,
|
|
6239
6391
|
url: null,
|
|
@@ -6603,6 +6755,10 @@ function $provideScrapersForNode(tools, options) {
|
|
|
6603
6755
|
return [4 /*yield*/, scraperFactory(tools, options || {})];
|
|
6604
6756
|
case 3:
|
|
6605
6757
|
scraper = _g.sent();
|
|
6758
|
+
if (scraper.metadata.packageName === '@promptbook/boilerplate' ||
|
|
6759
|
+
scraper.metadata.mimeTypes.some(function (mimeType) { return mimeType.includes('DISABLED'); })) {
|
|
6760
|
+
return [3 /*break*/, 4];
|
|
6761
|
+
}
|
|
6606
6762
|
scrapers.push(scraper);
|
|
6607
6763
|
_g.label = 4;
|
|
6608
6764
|
case 4:
|