@promptbook/cli 0.100.0-2 → 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 +64 -9
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/wizard.d.ts +14 -4
- package/package.json +1 -1
- package/umd/index.umd.js +64 -9
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
47
47
|
* @generated
|
|
48
48
|
* @see https://github.com/webgptorg/promptbook
|
|
49
49
|
*/
|
|
50
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
50
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-4';
|
|
51
51
|
/**
|
|
52
52
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
53
53
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2198,8 +2198,27 @@ class FileCacheStorage {
|
|
|
2198
2198
|
throw new UnexpectedError(`The "${key}" you want to store in JSON file is not serializable as JSON`);
|
|
2199
2199
|
}
|
|
2200
2200
|
const fileContent = stringifyPipelineJson(value);
|
|
2201
|
-
|
|
2202
|
-
|
|
2201
|
+
// Note: Try to create cache directory and write file, but don't fail if filesystem is read-only or has permission issues
|
|
2202
|
+
try {
|
|
2203
|
+
await mkdir(dirname(filename), { recursive: true }); // <- [0]
|
|
2204
|
+
await writeFile(filename, fileContent, 'utf-8');
|
|
2205
|
+
}
|
|
2206
|
+
catch (error) {
|
|
2207
|
+
// Note: If we can't write to cache, silently ignore the error
|
|
2208
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
2209
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
2210
|
+
error.message.includes('read-only') ||
|
|
2211
|
+
error.message.includes('EACCES') ||
|
|
2212
|
+
error.message.includes('EPERM') ||
|
|
2213
|
+
error.message.includes('ENOENT'))) {
|
|
2214
|
+
// Silently ignore filesystem errors - caching is optional
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
else {
|
|
2218
|
+
// Re-throw other unexpected errors
|
|
2219
|
+
throw error;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2203
2222
|
}
|
|
2204
2223
|
/**
|
|
2205
2224
|
* Removes the key/value pair with the given key from the storage, if a key/value pair with the given key exists.
|
|
@@ -7706,7 +7725,23 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
7706
7725
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
7707
7726
|
const rootDirname = join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
7708
7727
|
const filepath = join(...nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
|
|
7709
|
-
|
|
7728
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
7729
|
+
try {
|
|
7730
|
+
await tools.fs.mkdir(dirname(join(rootDirname, filepath)), { recursive: true });
|
|
7731
|
+
}
|
|
7732
|
+
catch (error) {
|
|
7733
|
+
// Note: If we can't create cache directory, we'll handle it when trying to write the file
|
|
7734
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
7735
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
7736
|
+
error.message.includes('read-only') ||
|
|
7737
|
+
error.message.includes('EACCES') ||
|
|
7738
|
+
error.message.includes('EPERM') ||
|
|
7739
|
+
error.message.includes('ENOENT'))) ;
|
|
7740
|
+
else {
|
|
7741
|
+
// Re-throw other unexpected errors
|
|
7742
|
+
throw error;
|
|
7743
|
+
}
|
|
7744
|
+
}
|
|
7710
7745
|
const fileContent = Buffer.from(await response.arrayBuffer());
|
|
7711
7746
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
7712
7747
|
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.`);
|
|
@@ -7721,7 +7756,8 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
7721
7756
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
7722
7757
|
error.message.includes('read-only') ||
|
|
7723
7758
|
error.message.includes('EACCES') ||
|
|
7724
|
-
error.message.includes('EPERM')
|
|
7759
|
+
error.message.includes('EPERM') ||
|
|
7760
|
+
error.message.includes('ENOENT'))) {
|
|
7725
7761
|
// Return a handler that works directly with the downloaded content
|
|
7726
7762
|
return {
|
|
7727
7763
|
source: name,
|
|
@@ -13367,7 +13403,8 @@ async function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
13367
13403
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
13368
13404
|
error.message.includes('read-only') ||
|
|
13369
13405
|
error.message.includes('EACCES') ||
|
|
13370
|
-
error.message.includes('EPERM')
|
|
13406
|
+
error.message.includes('EPERM') ||
|
|
13407
|
+
error.message.includes('ENOENT'))) ;
|
|
13371
13408
|
else {
|
|
13372
13409
|
// Re-throw other unexpected errors
|
|
13373
13410
|
throw error;
|
|
@@ -18667,7 +18704,23 @@ async function getScraperIntermediateSource(source, options) {
|
|
|
18667
18704
|
.join('/') +
|
|
18668
18705
|
'.' +
|
|
18669
18706
|
extension;
|
|
18670
|
-
|
|
18707
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
18708
|
+
try {
|
|
18709
|
+
await mkdir(dirname(cacheFilename), { recursive: true });
|
|
18710
|
+
}
|
|
18711
|
+
catch (error) {
|
|
18712
|
+
// Note: If we can't create cache directory, continue without it
|
|
18713
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
18714
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
18715
|
+
error.message.includes('read-only') ||
|
|
18716
|
+
error.message.includes('EACCES') ||
|
|
18717
|
+
error.message.includes('EPERM') ||
|
|
18718
|
+
error.message.includes('ENOENT'))) ;
|
|
18719
|
+
else {
|
|
18720
|
+
// Re-throw other unexpected errors
|
|
18721
|
+
throw error;
|
|
18722
|
+
}
|
|
18723
|
+
}
|
|
18671
18724
|
let isDestroyed = true;
|
|
18672
18725
|
const fileHandler = {
|
|
18673
18726
|
filename: cacheFilename,
|
|
@@ -19527,7 +19580,8 @@ class MarkitdownScraper {
|
|
|
19527
19580
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
19528
19581
|
error.message.includes('read-only') ||
|
|
19529
19582
|
error.message.includes('EACCES') ||
|
|
19530
|
-
error.message.includes('EPERM')
|
|
19583
|
+
error.message.includes('EPERM') ||
|
|
19584
|
+
error.message.includes('ENOENT'))) ;
|
|
19531
19585
|
else {
|
|
19532
19586
|
// Re-throw other unexpected errors
|
|
19533
19587
|
throw error;
|
|
@@ -19830,7 +19884,8 @@ class WebsiteScraper {
|
|
|
19830
19884
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
19831
19885
|
error.message.includes('read-only') ||
|
|
19832
19886
|
error.message.includes('EACCES') ||
|
|
19833
|
-
error.message.includes('EPERM')
|
|
19887
|
+
error.message.includes('EPERM') ||
|
|
19888
|
+
error.message.includes('ENOENT'))) ;
|
|
19834
19889
|
else {
|
|
19835
19890
|
// Re-throw other unexpected errors
|
|
19836
19891
|
throw error;
|