@promptbook/node 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 +41 -5
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +41 -5
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -30,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
30
30
|
* @generated
|
|
31
31
|
* @see https://github.com/webgptorg/promptbook
|
|
32
32
|
*/
|
|
33
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-4';
|
|
34
34
|
/**
|
|
35
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
36
36
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -5610,7 +5610,23 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5610
5610
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
5611
5611
|
const rootDirname = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
5612
5612
|
const filepath = join(...nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
|
|
5613
|
-
|
|
5613
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
5614
|
+
try {
|
|
5615
|
+
await tools.fs.mkdir(dirname(join(rootDirname, filepath)), { recursive: true });
|
|
5616
|
+
}
|
|
5617
|
+
catch (error) {
|
|
5618
|
+
// Note: If we can't create cache directory, we'll handle it when trying to write the file
|
|
5619
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
5620
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
5621
|
+
error.message.includes('read-only') ||
|
|
5622
|
+
error.message.includes('EACCES') ||
|
|
5623
|
+
error.message.includes('EPERM') ||
|
|
5624
|
+
error.message.includes('ENOENT'))) ;
|
|
5625
|
+
else {
|
|
5626
|
+
// Re-throw other unexpected errors
|
|
5627
|
+
throw error;
|
|
5628
|
+
}
|
|
5629
|
+
}
|
|
5614
5630
|
const fileContent = Buffer.from(await response.arrayBuffer());
|
|
5615
5631
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
5616
5632
|
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.`);
|
|
@@ -5625,7 +5641,8 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
5625
5641
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
5626
5642
|
error.message.includes('read-only') ||
|
|
5627
5643
|
error.message.includes('EACCES') ||
|
|
5628
|
-
error.message.includes('EPERM')
|
|
5644
|
+
error.message.includes('EPERM') ||
|
|
5645
|
+
error.message.includes('ENOENT'))) {
|
|
5629
5646
|
// Return a handler that works directly with the downloaded content
|
|
5630
5647
|
return {
|
|
5631
5648
|
source: name,
|
|
@@ -11321,8 +11338,27 @@ class FileCacheStorage {
|
|
|
11321
11338
|
throw new UnexpectedError(`The "${key}" you want to store in JSON file is not serializable as JSON`);
|
|
11322
11339
|
}
|
|
11323
11340
|
const fileContent = stringifyPipelineJson(value);
|
|
11324
|
-
|
|
11325
|
-
|
|
11341
|
+
// Note: Try to create cache directory and write file, but don't fail if filesystem is read-only or has permission issues
|
|
11342
|
+
try {
|
|
11343
|
+
await mkdir(dirname(filename), { recursive: true }); // <- [0]
|
|
11344
|
+
await writeFile(filename, fileContent, 'utf-8');
|
|
11345
|
+
}
|
|
11346
|
+
catch (error) {
|
|
11347
|
+
// Note: If we can't write to cache, silently ignore the error
|
|
11348
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
11349
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
11350
|
+
error.message.includes('read-only') ||
|
|
11351
|
+
error.message.includes('EACCES') ||
|
|
11352
|
+
error.message.includes('EPERM') ||
|
|
11353
|
+
error.message.includes('ENOENT'))) {
|
|
11354
|
+
// Silently ignore filesystem errors - caching is optional
|
|
11355
|
+
return;
|
|
11356
|
+
}
|
|
11357
|
+
else {
|
|
11358
|
+
// Re-throw other unexpected errors
|
|
11359
|
+
throw error;
|
|
11360
|
+
}
|
|
11361
|
+
}
|
|
11326
11362
|
}
|
|
11327
11363
|
/**
|
|
11328
11364
|
* Removes the key/value pair with the given key from the storage, if a key/value pair with the given key exists.
|