@promptbook/pdf 0.100.0-1 โ 0.100.0-3
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 +47 -3
- 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/esm/typings/src/wizard/wizard.d.ts +14 -4
- package/package.json +2 -2
- package/umd/index.umd.js +47 -3
- 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
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-3';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -3502,7 +3502,36 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3502
3502
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3503
3503
|
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.`);
|
|
3504
3504
|
}
|
|
3505
|
-
|
|
3505
|
+
// Note: Try to cache the downloaded file, but don't fail if the filesystem is read-only
|
|
3506
|
+
try {
|
|
3507
|
+
await tools.fs.writeFile(join(rootDirname, filepath), fileContent);
|
|
3508
|
+
}
|
|
3509
|
+
catch (error) {
|
|
3510
|
+
// Note: If we can't write to cache, we'll process the file directly from memory
|
|
3511
|
+
// This handles read-only filesystems like Vercel
|
|
3512
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
3513
|
+
error.message.includes('read-only') ||
|
|
3514
|
+
error.message.includes('EACCES') ||
|
|
3515
|
+
error.message.includes('EPERM'))) {
|
|
3516
|
+
// Return a handler that works directly with the downloaded content
|
|
3517
|
+
return {
|
|
3518
|
+
source: name,
|
|
3519
|
+
filename: null,
|
|
3520
|
+
url,
|
|
3521
|
+
mimeType,
|
|
3522
|
+
async asJson() {
|
|
3523
|
+
return JSON.parse(fileContent.toString('utf-8'));
|
|
3524
|
+
},
|
|
3525
|
+
async asText() {
|
|
3526
|
+
return fileContent.toString('utf-8');
|
|
3527
|
+
},
|
|
3528
|
+
};
|
|
3529
|
+
}
|
|
3530
|
+
else {
|
|
3531
|
+
// Re-throw other unexpected errors
|
|
3532
|
+
throw error;
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3506
3535
|
// TODO: [๐ต] Check the file security
|
|
3507
3536
|
// TODO: [๐งน][๐ง ] Delete the file after the scraping is done
|
|
3508
3537
|
return makeKnowledgeSourceHandler({ name, knowledgeSourceContent: filepath }, tools, {
|
|
@@ -6288,7 +6317,22 @@ class MarkitdownScraper {
|
|
|
6288
6317
|
// <- TODO: [๐] Make MarkitdownError
|
|
6289
6318
|
}
|
|
6290
6319
|
// console.log('!!', { result, cacheFilehandler });
|
|
6291
|
-
|
|
6320
|
+
// Note: Try to cache the converted content, but don't fail if the filesystem is read-only
|
|
6321
|
+
try {
|
|
6322
|
+
await this.tools.fs.writeFile(cacheFilehandler.filename, result.text_content);
|
|
6323
|
+
}
|
|
6324
|
+
catch (error) {
|
|
6325
|
+
// Note: If we can't write to cache, we'll continue without caching
|
|
6326
|
+
// This handles read-only filesystems like Vercel
|
|
6327
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
6328
|
+
error.message.includes('read-only') ||
|
|
6329
|
+
error.message.includes('EACCES') ||
|
|
6330
|
+
error.message.includes('EPERM'))) ;
|
|
6331
|
+
else {
|
|
6332
|
+
// Re-throw other unexpected errors
|
|
6333
|
+
throw error;
|
|
6334
|
+
}
|
|
6335
|
+
}
|
|
6292
6336
|
}
|
|
6293
6337
|
return cacheFilehandler;
|
|
6294
6338
|
}
|