@promptbook/markitdown 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 +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/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-2';
|
|
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
|
|
@@ -3489,7 +3489,36 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3489
3489
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3490
3490
|
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.`);
|
|
3491
3491
|
}
|
|
3492
|
-
|
|
3492
|
+
// Note: Try to cache the downloaded file, but don't fail if the filesystem is read-only
|
|
3493
|
+
try {
|
|
3494
|
+
await tools.fs.writeFile(join(rootDirname, filepath), fileContent);
|
|
3495
|
+
}
|
|
3496
|
+
catch (error) {
|
|
3497
|
+
// Note: If we can't write to cache, we'll process the file directly from memory
|
|
3498
|
+
// This handles read-only filesystems like Vercel
|
|
3499
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
3500
|
+
error.message.includes('read-only') ||
|
|
3501
|
+
error.message.includes('EACCES') ||
|
|
3502
|
+
error.message.includes('EPERM'))) {
|
|
3503
|
+
// Return a handler that works directly with the downloaded content
|
|
3504
|
+
return {
|
|
3505
|
+
source: name,
|
|
3506
|
+
filename: null,
|
|
3507
|
+
url,
|
|
3508
|
+
mimeType,
|
|
3509
|
+
async asJson() {
|
|
3510
|
+
return JSON.parse(fileContent.toString('utf-8'));
|
|
3511
|
+
},
|
|
3512
|
+
async asText() {
|
|
3513
|
+
return fileContent.toString('utf-8');
|
|
3514
|
+
},
|
|
3515
|
+
};
|
|
3516
|
+
}
|
|
3517
|
+
else {
|
|
3518
|
+
// Re-throw other unexpected errors
|
|
3519
|
+
throw error;
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3493
3522
|
// TODO: [๐ต] Check the file security
|
|
3494
3523
|
// TODO: [๐งน][๐ง ] Delete the file after the scraping is done
|
|
3495
3524
|
return makeKnowledgeSourceHandler({ name, knowledgeSourceContent: filepath }, tools, {
|
|
@@ -6275,7 +6304,22 @@ class MarkitdownScraper {
|
|
|
6275
6304
|
// <- TODO: [๐] Make MarkitdownError
|
|
6276
6305
|
}
|
|
6277
6306
|
// console.log('!!', { result, cacheFilehandler });
|
|
6278
|
-
|
|
6307
|
+
// Note: Try to cache the converted content, but don't fail if the filesystem is read-only
|
|
6308
|
+
try {
|
|
6309
|
+
await this.tools.fs.writeFile(cacheFilehandler.filename, result.text_content);
|
|
6310
|
+
}
|
|
6311
|
+
catch (error) {
|
|
6312
|
+
// Note: If we can't write to cache, we'll continue without caching
|
|
6313
|
+
// This handles read-only filesystems like Vercel
|
|
6314
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
6315
|
+
error.message.includes('read-only') ||
|
|
6316
|
+
error.message.includes('EACCES') ||
|
|
6317
|
+
error.message.includes('EPERM'))) ;
|
|
6318
|
+
else {
|
|
6319
|
+
// Re-throw other unexpected errors
|
|
6320
|
+
throw error;
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6279
6323
|
}
|
|
6280
6324
|
return cacheFilehandler;
|
|
6281
6325
|
}
|