@promptbook/node 0.100.0-0 โ†’ 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.
@@ -138,9 +138,6 @@ export declare const SMALL_NUMBER = 0.001;
138
138
  /**
139
139
  * Timeout for the connections in milliseconds
140
140
  *
141
- * Note: Increased from 7 seconds to 30 seconds to accommodate OAuth flows
142
- * like Facebook login which may require user interaction and redirects
143
- *
144
141
  * @private within the repository - too low-level in comparison with other `MAX_...`
145
142
  */
146
143
  export declare const CONNECTION_TIMEOUT_MS: number;
@@ -150,13 +147,6 @@ export declare const CONNECTION_TIMEOUT_MS: number;
150
147
  * @private within the repository - too low-level in comparison with other `MAX_...`
151
148
  */
152
149
  export declare const CONNECTION_RETRIES_LIMIT = 5;
153
- /**
154
- * Timeout specifically for OAuth authentication flows in milliseconds
155
- * OAuth flows typically require more time due to user interaction and redirects
156
- *
157
- * @private within the repository - too low-level in comparison with other `MAX_...`
158
- */
159
- export declare const OAUTH_TIMEOUT_MS: number;
160
150
  /**
161
151
  * Short time interval to prevent race conditions in milliseconds
162
152
  *
@@ -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.99.0-0`).
18
+ * It follows semantic versioning (e.g., `0.100.0-9`).
19
19
  *
20
20
  * @generated
21
21
  */
@@ -6,6 +6,15 @@ import type { InputParameters } from '../types/typeAliases';
6
6
  import type { string_filename } from '../types/typeAliases';
7
7
  import type { string_parameter_value } from '../types/typeAliases';
8
8
  import type { string_pipeline_url } from '../types/typeAliases';
9
+ /**
10
+ * Options for wizard methods
11
+ */
12
+ interface WizardOptions {
13
+ /**
14
+ * Whether to enable verbose logging
15
+ */
16
+ isVerbose?: boolean;
17
+ }
9
18
  /**
10
19
  * Wizard for simple usage of the Promptbook
11
20
  * Look at `wizard` for more details
@@ -26,7 +35,7 @@ declare class Wizard {
26
35
  *
27
36
  * Note: This works similar to the `ptbk run` command
28
37
  */
29
- execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters): Promise<{
38
+ execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters, options?: WizardOptions): Promise<{
30
39
  /**
31
40
  * Simple result of the execution
32
41
  */
@@ -36,9 +45,9 @@ declare class Wizard {
36
45
  /**
37
46
  * Provides the tools automatically for the Node.js environment
38
47
  *
39
- * @param pipelineSource
48
+ * @param options
40
49
  */
41
- getExecutionTools(): Promise<Required<Pick<ExecutionTools, 'fs' | 'fetch'>>>;
50
+ getExecutionTools(options?: WizardOptions): Promise<Required<Pick<ExecutionTools, 'fs' | 'fetch'>>>;
42
51
  /**
43
52
  * Load book from the source
44
53
  *
@@ -49,8 +58,9 @@ declare class Wizard {
49
58
  * 3) As a string
50
59
  *
51
60
  * @param pipelineSource
61
+ * @param options
52
62
  */
53
- getCompiledBook(pipelineSource: string_filename | string_pipeline_url | PipelineString): Promise<PipelineJson>;
63
+ getCompiledBook(pipelineSource: string_filename | string_pipeline_url | PipelineString, options?: WizardOptions): Promise<PipelineJson>;
54
64
  }
55
65
  /**
56
66
  * Wizard for simple usage of the Promptbook
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.100.0-0",
3
+ "version": "0.100.0-10",
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-0"
96
+ "@promptbook/core": "0.100.0-10"
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-0';
49
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-10';
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,12 +5626,58 @@
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.`);
5633
5649
  }
5634
- await tools.fs.writeFile(path.join(rootDirname, filepath), fileContent);
5650
+ // Note: Try to cache the downloaded file, but don't fail if the filesystem is read-only
5651
+ try {
5652
+ await tools.fs.writeFile(path.join(rootDirname, filepath), fileContent);
5653
+ }
5654
+ catch (error) {
5655
+ // Note: If we can't write to cache, we'll process the file directly from memory
5656
+ // This handles read-only filesystems like Vercel
5657
+ if (error instanceof Error && (error.message.includes('EROFS') ||
5658
+ error.message.includes('read-only') ||
5659
+ error.message.includes('EACCES') ||
5660
+ error.message.includes('EPERM') ||
5661
+ error.message.includes('ENOENT'))) {
5662
+ // Return a handler that works directly with the downloaded content
5663
+ return {
5664
+ source: name,
5665
+ filename: null,
5666
+ url,
5667
+ mimeType,
5668
+ async asJson() {
5669
+ return JSON.parse(fileContent.toString('utf-8'));
5670
+ },
5671
+ async asText() {
5672
+ return fileContent.toString('utf-8');
5673
+ },
5674
+ };
5675
+ }
5676
+ else {
5677
+ // Re-throw other unexpected errors
5678
+ throw error;
5679
+ }
5680
+ }
5635
5681
  // TODO: [๐Ÿ’ต] Check the file security
5636
5682
  // TODO: [๐Ÿงน][๐Ÿง ] Delete the file after the scraping is done
5637
5683
  return makeKnowledgeSourceHandler({ name, knowledgeSourceContent: filepath }, tools, {
@@ -11308,8 +11354,27 @@
11308
11354
  throw new UnexpectedError(`The "${key}" you want to store in JSON file is not serializable as JSON`);
11309
11355
  }
11310
11356
  const fileContent = stringifyPipelineJson(value);
11311
- await promises.mkdir(path.dirname(filename), { recursive: true }); // <- [0]
11312
- 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
+ }
11313
11378
  }
11314
11379
  /**
11315
11380
  * Removes the key/value pair with the given key from the storage, if a key/value pair with the given key exists.