@promptbook/core 0.100.0-0 โ†’ 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 CHANGED
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-0';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-2';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -5925,7 +5925,36 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5925
5925
  if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
5926
5926
  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.`);
5927
5927
  }
5928
- await tools.fs.writeFile(join(rootDirname, filepath), fileContent);
5928
+ // Note: Try to cache the downloaded file, but don't fail if the filesystem is read-only
5929
+ try {
5930
+ await tools.fs.writeFile(join(rootDirname, filepath), fileContent);
5931
+ }
5932
+ catch (error) {
5933
+ // Note: If we can't write to cache, we'll process the file directly from memory
5934
+ // This handles read-only filesystems like Vercel
5935
+ if (error instanceof Error && (error.message.includes('EROFS') ||
5936
+ error.message.includes('read-only') ||
5937
+ error.message.includes('EACCES') ||
5938
+ error.message.includes('EPERM'))) {
5939
+ // Return a handler that works directly with the downloaded content
5940
+ return {
5941
+ source: name,
5942
+ filename: null,
5943
+ url,
5944
+ mimeType,
5945
+ async asJson() {
5946
+ return JSON.parse(fileContent.toString('utf-8'));
5947
+ },
5948
+ async asText() {
5949
+ return fileContent.toString('utf-8');
5950
+ },
5951
+ };
5952
+ }
5953
+ else {
5954
+ // Re-throw other unexpected errors
5955
+ throw error;
5956
+ }
5957
+ }
5929
5958
  // TODO: [๐Ÿ’ต] Check the file security
5930
5959
  // TODO: [๐Ÿงน][๐Ÿง ] Delete the file after the scraping is done
5931
5960
  return makeKnowledgeSourceHandler({ name, knowledgeSourceContent: filepath }, tools, {