@promptbook/node 0.100.0-1 โ 0.100.0-10
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 +70 -5
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/config.d.ts +0 -10
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/wizard.d.ts +14 -4
- package/package.json +2 -2
- package/umd/index.umd.js +70 -5
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/remote-server/connection-improvements.test.d.ts +0 -1
- package/esm/typings/src/remote-server/utils/connectionProgress.d.ts +0 -72
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-10';
|
|
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,12 +5610,58 @@ 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.`);
|
|
5617
5633
|
}
|
|
5618
|
-
|
|
5634
|
+
// Note: Try to cache the downloaded file, but don't fail if the filesystem is read-only
|
|
5635
|
+
try {
|
|
5636
|
+
await tools.fs.writeFile(join(rootDirname, filepath), fileContent);
|
|
5637
|
+
}
|
|
5638
|
+
catch (error) {
|
|
5639
|
+
// Note: If we can't write to cache, we'll process the file directly from memory
|
|
5640
|
+
// This handles read-only filesystems like Vercel
|
|
5641
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
5642
|
+
error.message.includes('read-only') ||
|
|
5643
|
+
error.message.includes('EACCES') ||
|
|
5644
|
+
error.message.includes('EPERM') ||
|
|
5645
|
+
error.message.includes('ENOENT'))) {
|
|
5646
|
+
// Return a handler that works directly with the downloaded content
|
|
5647
|
+
return {
|
|
5648
|
+
source: name,
|
|
5649
|
+
filename: null,
|
|
5650
|
+
url,
|
|
5651
|
+
mimeType,
|
|
5652
|
+
async asJson() {
|
|
5653
|
+
return JSON.parse(fileContent.toString('utf-8'));
|
|
5654
|
+
},
|
|
5655
|
+
async asText() {
|
|
5656
|
+
return fileContent.toString('utf-8');
|
|
5657
|
+
},
|
|
5658
|
+
};
|
|
5659
|
+
}
|
|
5660
|
+
else {
|
|
5661
|
+
// Re-throw other unexpected errors
|
|
5662
|
+
throw error;
|
|
5663
|
+
}
|
|
5664
|
+
}
|
|
5619
5665
|
// TODO: [๐ต] Check the file security
|
|
5620
5666
|
// TODO: [๐งน][๐ง ] Delete the file after the scraping is done
|
|
5621
5667
|
return makeKnowledgeSourceHandler({ name, knowledgeSourceContent: filepath }, tools, {
|
|
@@ -11292,8 +11338,27 @@ class FileCacheStorage {
|
|
|
11292
11338
|
throw new UnexpectedError(`The "${key}" you want to store in JSON file is not serializable as JSON`);
|
|
11293
11339
|
}
|
|
11294
11340
|
const fileContent = stringifyPipelineJson(value);
|
|
11295
|
-
|
|
11296
|
-
|
|
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
|
+
}
|
|
11297
11362
|
}
|
|
11298
11363
|
/**
|
|
11299
11364
|
* Removes the key/value pair with the given key from the storage, if a key/value pair with the given key exists.
|