@promptbook/wizard 0.100.0-3 → 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
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
38
38
  * @generated
39
39
  * @see https://github.com/webgptorg/promptbook
40
40
  */
41
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-3';
41
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-4';
42
42
  /**
43
43
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
44
44
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -5963,7 +5963,23 @@ async function getScraperIntermediateSource(source, options) {
5963
5963
  .join('/') +
5964
5964
  '.' +
5965
5965
  extension;
5966
- await mkdir(dirname(cacheFilename), { recursive: true });
5966
+ // Note: Try to create cache directory, but don't fail if filesystem has issues
5967
+ try {
5968
+ await mkdir(dirname(cacheFilename), { recursive: true });
5969
+ }
5970
+ catch (error) {
5971
+ // Note: If we can't create cache directory, continue without it
5972
+ // This handles read-only filesystems, permission issues, and missing parent directories
5973
+ if (error instanceof Error && (error.message.includes('EROFS') ||
5974
+ error.message.includes('read-only') ||
5975
+ error.message.includes('EACCES') ||
5976
+ error.message.includes('EPERM') ||
5977
+ error.message.includes('ENOENT'))) ;
5978
+ else {
5979
+ // Re-throw other unexpected errors
5980
+ throw error;
5981
+ }
5982
+ }
5967
5983
  let isDestroyed = true;
5968
5984
  const fileHandler = {
5969
5985
  filename: cacheFilename,
@@ -7727,7 +7743,23 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
7727
7743
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
7728
7744
  const rootDirname = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
7729
7745
  const filepath = join(...nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
7730
- await tools.fs.mkdir(dirname(join(rootDirname, filepath)), { recursive: true });
7746
+ // Note: Try to create cache directory, but don't fail if filesystem has issues
7747
+ try {
7748
+ await tools.fs.mkdir(dirname(join(rootDirname, filepath)), { recursive: true });
7749
+ }
7750
+ catch (error) {
7751
+ // Note: If we can't create cache directory, we'll handle it when trying to write the file
7752
+ // This handles read-only filesystems, permission issues, and missing parent directories
7753
+ if (error instanceof Error && (error.message.includes('EROFS') ||
7754
+ error.message.includes('read-only') ||
7755
+ error.message.includes('EACCES') ||
7756
+ error.message.includes('EPERM') ||
7757
+ error.message.includes('ENOENT'))) ;
7758
+ else {
7759
+ // Re-throw other unexpected errors
7760
+ throw error;
7761
+ }
7762
+ }
7731
7763
  const fileContent = Buffer.from(await response.arrayBuffer());
7732
7764
  if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
7733
7765
  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.`);
@@ -7742,7 +7774,8 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
7742
7774
  if (error instanceof Error && (error.message.includes('EROFS') ||
7743
7775
  error.message.includes('read-only') ||
7744
7776
  error.message.includes('EACCES') ||
7745
- error.message.includes('EPERM'))) {
7777
+ error.message.includes('EPERM') ||
7778
+ error.message.includes('ENOENT'))) {
7746
7779
  // Return a handler that works directly with the downloaded content
7747
7780
  return {
7748
7781
  source: name,
@@ -10849,7 +10882,8 @@ class MarkitdownScraper {
10849
10882
  if (error instanceof Error && (error.message.includes('EROFS') ||
10850
10883
  error.message.includes('read-only') ||
10851
10884
  error.message.includes('EACCES') ||
10852
- error.message.includes('EPERM'))) ;
10885
+ error.message.includes('EPERM') ||
10886
+ error.message.includes('ENOENT'))) ;
10853
10887
  else {
10854
10888
  // Re-throw other unexpected errors
10855
10889
  throw error;
@@ -11152,7 +11186,8 @@ class WebsiteScraper {
11152
11186
  if (error instanceof Error && (error.message.includes('EROFS') ||
11153
11187
  error.message.includes('read-only') ||
11154
11188
  error.message.includes('EACCES') ||
11155
- error.message.includes('EPERM'))) ;
11189
+ error.message.includes('EPERM') ||
11190
+ error.message.includes('ENOENT'))) ;
11156
11191
  else {
11157
11192
  // Re-throw other unexpected errors
11158
11193
  throw error;
@@ -11898,8 +11933,27 @@ class FileCacheStorage {
11898
11933
  throw new UnexpectedError(`The "${key}" you want to store in JSON file is not serializable as JSON`);
11899
11934
  }
11900
11935
  const fileContent = stringifyPipelineJson(value);
11901
- await mkdir(dirname(filename), { recursive: true }); // <- [0]
11902
- await writeFile(filename, fileContent, 'utf-8');
11936
+ // Note: Try to create cache directory and write file, but don't fail if filesystem is read-only or has permission issues
11937
+ try {
11938
+ await mkdir(dirname(filename), { recursive: true }); // <- [0]
11939
+ await writeFile(filename, fileContent, 'utf-8');
11940
+ }
11941
+ catch (error) {
11942
+ // Note: If we can't write to cache, silently ignore the error
11943
+ // This handles read-only filesystems, permission issues, and missing parent directories
11944
+ if (error instanceof Error && (error.message.includes('EROFS') ||
11945
+ error.message.includes('read-only') ||
11946
+ error.message.includes('EACCES') ||
11947
+ error.message.includes('EPERM') ||
11948
+ error.message.includes('ENOENT'))) {
11949
+ // Silently ignore filesystem errors - caching is optional
11950
+ return;
11951
+ }
11952
+ else {
11953
+ // Re-throw other unexpected errors
11954
+ throw error;
11955
+ }
11956
+ }
11903
11957
  }
11904
11958
  /**
11905
11959
  * Removes the key/value pair with the given key from the storage, if a key/value pair with the given key exists.
@@ -16779,7 +16833,8 @@ async function $getCompiledBook(tools, pipelineSource, options) {
16779
16833
  if (error instanceof Error && (error.message.includes('EROFS') ||
16780
16834
  error.message.includes('read-only') ||
16781
16835
  error.message.includes('EACCES') ||
16782
- error.message.includes('EPERM'))) ;
16836
+ error.message.includes('EPERM') ||
16837
+ error.message.includes('ENOENT'))) ;
16783
16838
  else {
16784
16839
  // Re-throw other unexpected errors
16785
16840
  throw error;