@promptbook/markitdown 0.100.0-2 → 0.100.0-4

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 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-2';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-4';
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
@@ -834,7 +834,23 @@ async function getScraperIntermediateSource(source, options) {
834
834
  .join('/') +
835
835
  '.' +
836
836
  extension;
837
- await mkdir(dirname(cacheFilename), { recursive: true });
837
+ // Note: Try to create cache directory, but don't fail if filesystem has issues
838
+ try {
839
+ await mkdir(dirname(cacheFilename), { recursive: true });
840
+ }
841
+ catch (error) {
842
+ // Note: If we can't create cache directory, continue without it
843
+ // This handles read-only filesystems, permission issues, and missing parent directories
844
+ if (error instanceof Error && (error.message.includes('EROFS') ||
845
+ error.message.includes('read-only') ||
846
+ error.message.includes('EACCES') ||
847
+ error.message.includes('EPERM') ||
848
+ error.message.includes('ENOENT'))) ;
849
+ else {
850
+ // Re-throw other unexpected errors
851
+ throw error;
852
+ }
853
+ }
838
854
  let isDestroyed = true;
839
855
  const fileHandler = {
840
856
  filename: cacheFilename,
@@ -3484,7 +3500,23 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3484
3500
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
3485
3501
  const rootDirname = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
3486
3502
  const filepath = join(...nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
3487
- await tools.fs.mkdir(dirname(join(rootDirname, filepath)), { recursive: true });
3503
+ // Note: Try to create cache directory, but don't fail if filesystem has issues
3504
+ try {
3505
+ await tools.fs.mkdir(dirname(join(rootDirname, filepath)), { recursive: true });
3506
+ }
3507
+ catch (error) {
3508
+ // Note: If we can't create cache directory, we'll handle it when trying to write the file
3509
+ // This handles read-only filesystems, permission issues, and missing parent directories
3510
+ if (error instanceof Error && (error.message.includes('EROFS') ||
3511
+ error.message.includes('read-only') ||
3512
+ error.message.includes('EACCES') ||
3513
+ error.message.includes('EPERM') ||
3514
+ error.message.includes('ENOENT'))) ;
3515
+ else {
3516
+ // Re-throw other unexpected errors
3517
+ throw error;
3518
+ }
3519
+ }
3488
3520
  const fileContent = Buffer.from(await response.arrayBuffer());
3489
3521
  if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
3490
3522
  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.`);
@@ -3499,7 +3531,8 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3499
3531
  if (error instanceof Error && (error.message.includes('EROFS') ||
3500
3532
  error.message.includes('read-only') ||
3501
3533
  error.message.includes('EACCES') ||
3502
- error.message.includes('EPERM'))) {
3534
+ error.message.includes('EPERM') ||
3535
+ error.message.includes('ENOENT'))) {
3503
3536
  // Return a handler that works directly with the downloaded content
3504
3537
  return {
3505
3538
  source: name,
@@ -6314,7 +6347,8 @@ class MarkitdownScraper {
6314
6347
  if (error instanceof Error && (error.message.includes('EROFS') ||
6315
6348
  error.message.includes('read-only') ||
6316
6349
  error.message.includes('EACCES') ||
6317
- error.message.includes('EPERM'))) ;
6350
+ error.message.includes('EPERM') ||
6351
+ error.message.includes('ENOENT'))) ;
6318
6352
  else {
6319
6353
  // Re-throw other unexpected errors
6320
6354
  throw error;