@promptbook/wizard 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.
@@ -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-1`).
18
+ * It follows semantic versioning (e.g., `0.100.0-3`).
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/wizard",
3
- "version": "0.100.0-2",
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,
@@ -95,7 +95,7 @@
95
95
  "module": "./esm/index.es.js",
96
96
  "typings": "./esm/typings/src/_packages/wizard.index.d.ts",
97
97
  "peerDependencies": {
98
- "@promptbook/core": "0.100.0-2"
98
+ "@promptbook/core": "0.100.0-4"
99
99
  },
100
100
  "dependencies": {
101
101
  "@ai-sdk/deepseek": "0.1.6",
package/umd/index.umd.js CHANGED
@@ -49,7 +49,7 @@
49
49
  * @generated
50
50
  * @see https://github.com/webgptorg/promptbook
51
51
  */
52
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-2';
52
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-4';
53
53
  /**
54
54
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
55
55
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -5974,7 +5974,23 @@
5974
5974
  .join('/') +
5975
5975
  '.' +
5976
5976
  extension;
5977
- await promises.mkdir(path.dirname(cacheFilename), { recursive: true });
5977
+ // Note: Try to create cache directory, but don't fail if filesystem has issues
5978
+ try {
5979
+ await promises.mkdir(path.dirname(cacheFilename), { recursive: true });
5980
+ }
5981
+ catch (error) {
5982
+ // Note: If we can't create cache directory, continue without it
5983
+ // This handles read-only filesystems, permission issues, and missing parent directories
5984
+ if (error instanceof Error && (error.message.includes('EROFS') ||
5985
+ error.message.includes('read-only') ||
5986
+ error.message.includes('EACCES') ||
5987
+ error.message.includes('EPERM') ||
5988
+ error.message.includes('ENOENT'))) ;
5989
+ else {
5990
+ // Re-throw other unexpected errors
5991
+ throw error;
5992
+ }
5993
+ }
5978
5994
  let isDestroyed = true;
5979
5995
  const fileHandler = {
5980
5996
  filename: cacheFilename,
@@ -7738,7 +7754,23 @@
7738
7754
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
7739
7755
  const rootDirname = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
7740
7756
  const filepath = path.join(...nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
7741
- await tools.fs.mkdir(path.dirname(path.join(rootDirname, filepath)), { recursive: true });
7757
+ // Note: Try to create cache directory, but don't fail if filesystem has issues
7758
+ try {
7759
+ await tools.fs.mkdir(path.dirname(path.join(rootDirname, filepath)), { recursive: true });
7760
+ }
7761
+ catch (error) {
7762
+ // Note: If we can't create cache directory, we'll handle it when trying to write the file
7763
+ // This handles read-only filesystems, permission issues, and missing parent directories
7764
+ if (error instanceof Error && (error.message.includes('EROFS') ||
7765
+ error.message.includes('read-only') ||
7766
+ error.message.includes('EACCES') ||
7767
+ error.message.includes('EPERM') ||
7768
+ error.message.includes('ENOENT'))) ;
7769
+ else {
7770
+ // Re-throw other unexpected errors
7771
+ throw error;
7772
+ }
7773
+ }
7742
7774
  const fileContent = Buffer.from(await response.arrayBuffer());
7743
7775
  if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
7744
7776
  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.`);
@@ -7753,7 +7785,8 @@
7753
7785
  if (error instanceof Error && (error.message.includes('EROFS') ||
7754
7786
  error.message.includes('read-only') ||
7755
7787
  error.message.includes('EACCES') ||
7756
- error.message.includes('EPERM'))) {
7788
+ error.message.includes('EPERM') ||
7789
+ error.message.includes('ENOENT'))) {
7757
7790
  // Return a handler that works directly with the downloaded content
7758
7791
  return {
7759
7792
  source: name,
@@ -10860,7 +10893,8 @@
10860
10893
  if (error instanceof Error && (error.message.includes('EROFS') ||
10861
10894
  error.message.includes('read-only') ||
10862
10895
  error.message.includes('EACCES') ||
10863
- error.message.includes('EPERM'))) ;
10896
+ error.message.includes('EPERM') ||
10897
+ error.message.includes('ENOENT'))) ;
10864
10898
  else {
10865
10899
  // Re-throw other unexpected errors
10866
10900
  throw error;
@@ -11163,7 +11197,8 @@
11163
11197
  if (error instanceof Error && (error.message.includes('EROFS') ||
11164
11198
  error.message.includes('read-only') ||
11165
11199
  error.message.includes('EACCES') ||
11166
- error.message.includes('EPERM'))) ;
11200
+ error.message.includes('EPERM') ||
11201
+ error.message.includes('ENOENT'))) ;
11167
11202
  else {
11168
11203
  // Re-throw other unexpected errors
11169
11204
  throw error;
@@ -11909,8 +11944,27 @@
11909
11944
  throw new UnexpectedError(`The "${key}" you want to store in JSON file is not serializable as JSON`);
11910
11945
  }
11911
11946
  const fileContent = stringifyPipelineJson(value);
11912
- await promises.mkdir(path.dirname(filename), { recursive: true }); // <- [0]
11913
- await promises.writeFile(filename, fileContent, 'utf-8');
11947
+ // Note: Try to create cache directory and write file, but don't fail if filesystem is read-only or has permission issues
11948
+ try {
11949
+ await promises.mkdir(path.dirname(filename), { recursive: true }); // <- [0]
11950
+ await promises.writeFile(filename, fileContent, 'utf-8');
11951
+ }
11952
+ catch (error) {
11953
+ // Note: If we can't write to cache, silently ignore the error
11954
+ // This handles read-only filesystems, permission issues, and missing parent directories
11955
+ if (error instanceof Error && (error.message.includes('EROFS') ||
11956
+ error.message.includes('read-only') ||
11957
+ error.message.includes('EACCES') ||
11958
+ error.message.includes('EPERM') ||
11959
+ error.message.includes('ENOENT'))) {
11960
+ // Silently ignore filesystem errors - caching is optional
11961
+ return;
11962
+ }
11963
+ else {
11964
+ // Re-throw other unexpected errors
11965
+ throw error;
11966
+ }
11967
+ }
11914
11968
  }
11915
11969
  /**
11916
11970
  * Removes the key/value pair with the given key from the storage, if a key/value pair with the given key exists.
@@ -16790,7 +16844,8 @@
16790
16844
  if (error instanceof Error && (error.message.includes('EROFS') ||
16791
16845
  error.message.includes('read-only') ||
16792
16846
  error.message.includes('EACCES') ||
16793
- error.message.includes('EPERM'))) ;
16847
+ error.message.includes('EPERM') ||
16848
+ error.message.includes('ENOENT'))) ;
16794
16849
  else {
16795
16850
  // Re-throw other unexpected errors
16796
16851
  throw error;
@@ -16917,14 +16972,14 @@
16917
16972
  *
16918
16973
  * Note: This works similar to the `ptbk run` command
16919
16974
  */
16920
- async execute(book, inputParameters) {
16975
+ async execute(book, inputParameters, options = {}) {
16921
16976
  if (!$isRunningInNode()) {
16922
16977
  throw new EnvironmentMismatchError('Wizard works only in Node.js environment');
16923
16978
  }
16924
16979
  // ▶ Get the tools
16925
- const tools = await this.getExecutionTools();
16980
+ const tools = await this.getExecutionTools(options);
16926
16981
  // ▶ Get the Pipeline
16927
- const pipeline = await this.getCompiledBook(book);
16982
+ const pipeline = await this.getCompiledBook(book, options);
16928
16983
  // ▶ Create executor - the function that will execute the Pipeline
16929
16984
  const pipelineExecutor = createPipelineExecutor({ pipeline, tools });
16930
16985
  // 🚀▶ Execute the Pipeline
@@ -16947,15 +17002,16 @@
16947
17002
  /**
16948
17003
  * Provides the tools automatically for the Node.js environment
16949
17004
  *
16950
- * @param pipelineSource
17005
+ * @param options
16951
17006
  */
16952
- async getExecutionTools() {
17007
+ async getExecutionTools(options = {}) {
17008
+ var _a;
16953
17009
  if (this.executionTools !== null) {
16954
17010
  return this.executionTools;
16955
17011
  }
16956
17012
  // TODO: DRY [◽]
16957
17013
  const prepareAndScrapeOptions = {
16958
- isVerbose: false,
17014
+ isVerbose: (_a = options.isVerbose) !== null && _a !== void 0 ? _a : false,
16959
17015
  isCacheReloaded: false, // <- TODO: Allow to pass
16960
17016
  }; /* <- TODO: ` satisfies PrepareAndScrapeOptions` */
16961
17017
  const fs = $provideFilesystemForNode();
@@ -16985,9 +17041,10 @@
16985
17041
  * 3) As a string
16986
17042
  *
16987
17043
  * @param pipelineSource
17044
+ * @param options
16988
17045
  */
16989
- async getCompiledBook(pipelineSource) {
16990
- const tools = await this.getExecutionTools();
17046
+ async getCompiledBook(pipelineSource, options = {}) {
17047
+ const tools = await this.getExecutionTools(options);
16991
17048
  return /* not await */ $getCompiledBook(tools, pipelineSource);
16992
17049
  }
16993
17050
  }