@promptbook/remote-server 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 +20 -3
- 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 +20 -3
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
33
33
|
* @generated
|
|
34
34
|
* @see https://github.com/webgptorg/promptbook
|
|
35
35
|
*/
|
|
36
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
36
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-4';
|
|
37
37
|
/**
|
|
38
38
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
39
39
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3822,7 +3822,23 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3822
3822
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
3823
3823
|
const rootDirname = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
3824
3824
|
const filepath = join(...nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
|
|
3825
|
-
|
|
3825
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
3826
|
+
try {
|
|
3827
|
+
await tools.fs.mkdir(dirname(join(rootDirname, filepath)), { recursive: true });
|
|
3828
|
+
}
|
|
3829
|
+
catch (error) {
|
|
3830
|
+
// Note: If we can't create cache directory, we'll handle it when trying to write the file
|
|
3831
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
3832
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
3833
|
+
error.message.includes('read-only') ||
|
|
3834
|
+
error.message.includes('EACCES') ||
|
|
3835
|
+
error.message.includes('EPERM') ||
|
|
3836
|
+
error.message.includes('ENOENT'))) ;
|
|
3837
|
+
else {
|
|
3838
|
+
// Re-throw other unexpected errors
|
|
3839
|
+
throw error;
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3826
3842
|
const fileContent = Buffer.from(await response.arrayBuffer());
|
|
3827
3843
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3828
3844
|
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.`);
|
|
@@ -3837,7 +3853,8 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3837
3853
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
3838
3854
|
error.message.includes('read-only') ||
|
|
3839
3855
|
error.message.includes('EACCES') ||
|
|
3840
|
-
error.message.includes('EPERM')
|
|
3856
|
+
error.message.includes('EPERM') ||
|
|
3857
|
+
error.message.includes('ENOENT'))) {
|
|
3841
3858
|
// Return a handler that works directly with the downloaded content
|
|
3842
3859
|
return {
|
|
3843
3860
|
source: name,
|