@promptbook/pdf 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
@@ -847,7 +847,23 @@ async function getScraperIntermediateSource(source, options) {
847
847
  .join('/') +
848
848
  '.' +
849
849
  extension;
850
- await mkdir(dirname(cacheFilename), { recursive: true });
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,7 +3513,23 @@ 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
- await tools.fs.mkdir(dirname(join(rootDirname, filepath)), { recursive: true });
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.`);
@@ -3512,7 +3544,8 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3512
3544
  if (error instanceof Error && (error.message.includes('EROFS') ||
3513
3545
  error.message.includes('read-only') ||
3514
3546
  error.message.includes('EACCES') ||
3515
- error.message.includes('EPERM'))) {
3547
+ error.message.includes('EPERM') ||
3548
+ error.message.includes('ENOENT'))) {
3516
3549
  // Return a handler that works directly with the downloaded content
3517
3550
  return {
3518
3551
  source: name,
@@ -6327,7 +6360,8 @@ class MarkitdownScraper {
6327
6360
  if (error instanceof Error && (error.message.includes('EROFS') ||
6328
6361
  error.message.includes('read-only') ||
6329
6362
  error.message.includes('EACCES') ||
6330
- error.message.includes('EPERM'))) ;
6363
+ error.message.includes('EPERM') ||
6364
+ error.message.includes('ENOENT'))) ;
6331
6365
  else {
6332
6366
  // Re-throw other unexpected errors
6333
6367
  throw error;