@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.
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.100.0-2`).
18
+ * It follows semantic versioning (e.g., `0.100.0-3`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.100.0-3",
3
+ "version": "0.100.0-4",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -93,7 +93,7 @@
93
93
  "module": "./esm/index.es.js",
94
94
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
95
95
  "peerDependencies": {
96
- "@promptbook/core": "0.100.0-3"
96
+ "@promptbook/core": "0.100.0-4"
97
97
  },
98
98
  "dependencies": {
99
99
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -46,7 +46,7 @@
46
46
  * @generated
47
47
  * @see https://github.com/webgptorg/promptbook
48
48
  */
49
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-3';
49
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-4';
50
50
  /**
51
51
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
52
52
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -5626,7 +5626,23 @@
5626
5626
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
5627
5627
  const rootDirname = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
5628
5628
  const filepath = path.join(...nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
5629
- await tools.fs.mkdir(path.dirname(path.join(rootDirname, filepath)), { recursive: true });
5629
+ // Note: Try to create cache directory, but don't fail if filesystem has issues
5630
+ try {
5631
+ await tools.fs.mkdir(path.dirname(path.join(rootDirname, filepath)), { recursive: true });
5632
+ }
5633
+ catch (error) {
5634
+ // Note: If we can't create cache directory, we'll handle it when trying to write the file
5635
+ // This handles read-only filesystems, permission issues, and missing parent directories
5636
+ if (error instanceof Error && (error.message.includes('EROFS') ||
5637
+ error.message.includes('read-only') ||
5638
+ error.message.includes('EACCES') ||
5639
+ error.message.includes('EPERM') ||
5640
+ error.message.includes('ENOENT'))) ;
5641
+ else {
5642
+ // Re-throw other unexpected errors
5643
+ throw error;
5644
+ }
5645
+ }
5630
5646
  const fileContent = Buffer.from(await response.arrayBuffer());
5631
5647
  if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
5632
5648
  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.`);
@@ -5641,7 +5657,8 @@
5641
5657
  if (error instanceof Error && (error.message.includes('EROFS') ||
5642
5658
  error.message.includes('read-only') ||
5643
5659
  error.message.includes('EACCES') ||
5644
- error.message.includes('EPERM'))) {
5660
+ error.message.includes('EPERM') ||
5661
+ error.message.includes('ENOENT'))) {
5645
5662
  // Return a handler that works directly with the downloaded content
5646
5663
  return {
5647
5664
  source: name,
@@ -11337,8 +11354,27 @@
11337
11354
  throw new UnexpectedError(`The "${key}" you want to store in JSON file is not serializable as JSON`);
11338
11355
  }
11339
11356
  const fileContent = stringifyPipelineJson(value);
11340
- await promises.mkdir(path.dirname(filename), { recursive: true }); // <- [0]
11341
- await promises.writeFile(filename, fileContent, 'utf-8');
11357
+ // Note: Try to create cache directory and write file, but don't fail if filesystem is read-only or has permission issues
11358
+ try {
11359
+ await promises.mkdir(path.dirname(filename), { recursive: true }); // <- [0]
11360
+ await promises.writeFile(filename, fileContent, 'utf-8');
11361
+ }
11362
+ catch (error) {
11363
+ // Note: If we can't write to cache, silently ignore the error
11364
+ // This handles read-only filesystems, permission issues, and missing parent directories
11365
+ if (error instanceof Error && (error.message.includes('EROFS') ||
11366
+ error.message.includes('read-only') ||
11367
+ error.message.includes('EACCES') ||
11368
+ error.message.includes('EPERM') ||
11369
+ error.message.includes('ENOENT'))) {
11370
+ // Silently ignore filesystem errors - caching is optional
11371
+ return;
11372
+ }
11373
+ else {
11374
+ // Re-throw other unexpected errors
11375
+ throw error;
11376
+ }
11377
+ }
11342
11378
  }
11343
11379
  /**
11344
11380
  * Removes the key/value pair with the given key from the storage, if a key/value pair with the given key exists.