@promptbook/pdf 0.100.0-1 โ 0.100.0-13
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 +83 -5
- 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 +83 -5
- 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-13';
|
|
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
|
|
@@ -847,7 +847,23 @@ async function getScraperIntermediateSource(source, options) {
|
|
|
847
847
|
.join('/') +
|
|
848
848
|
'.' +
|
|
849
849
|
extension;
|
|
850
|
-
|
|
850
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
851
|
+
try {
|
|
852
|
+
await mkdir(dirname(cacheFilename), { recursive: true });
|
|
853
|
+
}
|
|
854
|
+
catch (error) {
|
|
855
|
+
// Note: If we can't create cache directory, continue without it
|
|
856
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
857
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
858
|
+
error.message.includes('read-only') ||
|
|
859
|
+
error.message.includes('EACCES') ||
|
|
860
|
+
error.message.includes('EPERM') ||
|
|
861
|
+
error.message.includes('ENOENT'))) ;
|
|
862
|
+
else {
|
|
863
|
+
// Re-throw other unexpected errors
|
|
864
|
+
throw error;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
851
867
|
let isDestroyed = true;
|
|
852
868
|
const fileHandler = {
|
|
853
869
|
filename: cacheFilename,
|
|
@@ -3497,12 +3513,58 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3497
3513
|
// <- TODO: [๐ฅฌ] Encapsulate sha256 to some private utility function
|
|
3498
3514
|
const rootDirname = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
3499
3515
|
const filepath = join(...nameToSubfolderPath(hash /* <- TODO: [๐] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
|
|
3500
|
-
|
|
3516
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
3517
|
+
try {
|
|
3518
|
+
await tools.fs.mkdir(dirname(join(rootDirname, filepath)), { recursive: true });
|
|
3519
|
+
}
|
|
3520
|
+
catch (error) {
|
|
3521
|
+
// Note: If we can't create cache directory, we'll handle it when trying to write the file
|
|
3522
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
3523
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
3524
|
+
error.message.includes('read-only') ||
|
|
3525
|
+
error.message.includes('EACCES') ||
|
|
3526
|
+
error.message.includes('EPERM') ||
|
|
3527
|
+
error.message.includes('ENOENT'))) ;
|
|
3528
|
+
else {
|
|
3529
|
+
// Re-throw other unexpected errors
|
|
3530
|
+
throw error;
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3501
3533
|
const fileContent = Buffer.from(await response.arrayBuffer());
|
|
3502
3534
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3503
3535
|
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
3536
|
}
|
|
3505
|
-
|
|
3537
|
+
// Note: Try to cache the downloaded file, but don't fail if the filesystem is read-only
|
|
3538
|
+
try {
|
|
3539
|
+
await tools.fs.writeFile(join(rootDirname, filepath), fileContent);
|
|
3540
|
+
}
|
|
3541
|
+
catch (error) {
|
|
3542
|
+
// Note: If we can't write to cache, we'll process the file directly from memory
|
|
3543
|
+
// This handles read-only filesystems like Vercel
|
|
3544
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
3545
|
+
error.message.includes('read-only') ||
|
|
3546
|
+
error.message.includes('EACCES') ||
|
|
3547
|
+
error.message.includes('EPERM') ||
|
|
3548
|
+
error.message.includes('ENOENT'))) {
|
|
3549
|
+
// Return a handler that works directly with the downloaded content
|
|
3550
|
+
return {
|
|
3551
|
+
source: name,
|
|
3552
|
+
filename: null,
|
|
3553
|
+
url,
|
|
3554
|
+
mimeType,
|
|
3555
|
+
async asJson() {
|
|
3556
|
+
return JSON.parse(fileContent.toString('utf-8'));
|
|
3557
|
+
},
|
|
3558
|
+
async asText() {
|
|
3559
|
+
return fileContent.toString('utf-8');
|
|
3560
|
+
},
|
|
3561
|
+
};
|
|
3562
|
+
}
|
|
3563
|
+
else {
|
|
3564
|
+
// Re-throw other unexpected errors
|
|
3565
|
+
throw error;
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3506
3568
|
// TODO: [๐ต] Check the file security
|
|
3507
3569
|
// TODO: [๐งน][๐ง ] Delete the file after the scraping is done
|
|
3508
3570
|
return makeKnowledgeSourceHandler({ name, knowledgeSourceContent: filepath }, tools, {
|
|
@@ -6288,7 +6350,23 @@ class MarkitdownScraper {
|
|
|
6288
6350
|
// <- TODO: [๐] Make MarkitdownError
|
|
6289
6351
|
}
|
|
6290
6352
|
// console.log('!!', { result, cacheFilehandler });
|
|
6291
|
-
|
|
6353
|
+
// Note: Try to cache the converted content, but don't fail if the filesystem is read-only
|
|
6354
|
+
try {
|
|
6355
|
+
await this.tools.fs.writeFile(cacheFilehandler.filename, result.text_content);
|
|
6356
|
+
}
|
|
6357
|
+
catch (error) {
|
|
6358
|
+
// Note: If we can't write to cache, we'll continue without caching
|
|
6359
|
+
// This handles read-only filesystems like Vercel
|
|
6360
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
6361
|
+
error.message.includes('read-only') ||
|
|
6362
|
+
error.message.includes('EACCES') ||
|
|
6363
|
+
error.message.includes('EPERM') ||
|
|
6364
|
+
error.message.includes('ENOENT'))) ;
|
|
6365
|
+
else {
|
|
6366
|
+
// Re-throw other unexpected errors
|
|
6367
|
+
throw error;
|
|
6368
|
+
}
|
|
6369
|
+
}
|
|
6292
6370
|
}
|
|
6293
6371
|
return cacheFilehandler;
|
|
6294
6372
|
}
|