@promptbook/legacy-documents 0.100.0-1 โ 0.100.0-2
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 +31 -2
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/config.d.ts +0 -10
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +31 -2
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/remote-server/connection-improvements.test.d.ts +0 -1
- package/esm/typings/src/remote-server/utils/connectionProgress.d.ts +0 -72
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-2';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -3653,7 +3653,36 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3653
3653
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3654
3654
|
throw new LimitReachedError(`File is too large (${Math.round(fileContent.length / 1024 / 1024)}MB). Maximum allowed size is ${Math.round(DEFAULT_MAX_FILE_SIZE / 1024 / 1024)}MB.`);
|
|
3655
3655
|
}
|
|
3656
|
-
|
|
3656
|
+
// Note: Try to cache the downloaded file, but don't fail if the filesystem is read-only
|
|
3657
|
+
try {
|
|
3658
|
+
await tools.fs.writeFile(join(rootDirname, filepath), fileContent);
|
|
3659
|
+
}
|
|
3660
|
+
catch (error) {
|
|
3661
|
+
// Note: If we can't write to cache, we'll process the file directly from memory
|
|
3662
|
+
// This handles read-only filesystems like Vercel
|
|
3663
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
3664
|
+
error.message.includes('read-only') ||
|
|
3665
|
+
error.message.includes('EACCES') ||
|
|
3666
|
+
error.message.includes('EPERM'))) {
|
|
3667
|
+
// Return a handler that works directly with the downloaded content
|
|
3668
|
+
return {
|
|
3669
|
+
source: name,
|
|
3670
|
+
filename: null,
|
|
3671
|
+
url,
|
|
3672
|
+
mimeType,
|
|
3673
|
+
async asJson() {
|
|
3674
|
+
return JSON.parse(fileContent.toString('utf-8'));
|
|
3675
|
+
},
|
|
3676
|
+
async asText() {
|
|
3677
|
+
return fileContent.toString('utf-8');
|
|
3678
|
+
},
|
|
3679
|
+
};
|
|
3680
|
+
}
|
|
3681
|
+
else {
|
|
3682
|
+
// Re-throw other unexpected errors
|
|
3683
|
+
throw error;
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3657
3686
|
// TODO: [๐ต] Check the file security
|
|
3658
3687
|
// TODO: [๐งน][๐ง ] Delete the file after the scraping is done
|
|
3659
3688
|
return makeKnowledgeSourceHandler({ name, knowledgeSourceContent: filepath }, tools, {
|