@promptbook/remote-client 0.84.0-10 → 0.84.0-12

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.
@@ -19,7 +19,8 @@ import { DEFAULT_MAX_EXECUTION_ATTEMPTS } from '../config';
19
19
  import { DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH } from '../config';
20
20
  import { DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL } from '../config';
21
21
  import { DEFAULT_BOOKS_DIRNAME } from '../config';
22
- import { DEFAULT_EXECUTIONS_CACHE_DIRNAME } from '../config';
22
+ import { DEFAULT_DOWNLOAD_CACHE_DIRNAME } from '../config';
23
+ import { DEFAULT_EXECUTION_CACHE_DIRNAME } from '../config';
23
24
  import { DEFAULT_SCRAPE_CACHE_DIRNAME } from '../config';
24
25
  import { DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME } from '../config';
25
26
  import { DEFAULT_REMOTE_URL } from '../config';
@@ -145,7 +146,8 @@ export { DEFAULT_MAX_EXECUTION_ATTEMPTS };
145
146
  export { DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH };
146
147
  export { DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL };
147
148
  export { DEFAULT_BOOKS_DIRNAME };
148
- export { DEFAULT_EXECUTIONS_CACHE_DIRNAME };
149
+ export { DEFAULT_DOWNLOAD_CACHE_DIRNAME };
150
+ export { DEFAULT_EXECUTION_CACHE_DIRNAME };
149
151
  export { DEFAULT_SCRAPE_CACHE_DIRNAME };
150
152
  export { DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME };
151
153
  export { DEFAULT_REMOTE_URL };
@@ -8,6 +8,7 @@ import { serializeError } from '../errors/utils/serializeError';
8
8
  import { forEachAsync } from '../execution/utils/forEachAsync';
9
9
  import { isValidJsonString } from '../formats/json/utils/isValidJsonString';
10
10
  import { prompt } from '../pipeline/prompt-notation';
11
+ import { promptTemplate } from '../pipeline/prompt-notation';
11
12
  import { $getCurrentDate } from '../utils/$getCurrentDate';
12
13
  import { $isRunningInBrowser } from '../utils/environment/$isRunningInBrowser';
13
14
  import { $isRunningInJest } from '../utils/environment/$isRunningInJest';
@@ -89,6 +90,7 @@ export { serializeError };
89
90
  export { forEachAsync };
90
91
  export { isValidJsonString };
91
92
  export { prompt };
93
+ export { promptTemplate };
92
94
  export { $getCurrentDate };
93
95
  export { $isRunningInBrowser };
94
96
  export { $isRunningInJest };
@@ -166,6 +166,14 @@ export declare const DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
166
166
  * @public exported from `@promptbook/core`
167
167
  */
168
168
  export declare const DEFAULT_BOOKS_DIRNAME = "./books";
169
+ /**
170
+ * Where to store the temporary downloads
171
+ *
172
+ * Note: When the folder does not exist, it is created recursively
173
+ *
174
+ * @public exported from `@promptbook/core`
175
+ */
176
+ export declare const DEFAULT_DOWNLOAD_CACHE_DIRNAME = "./.promptbook/download-cache";
169
177
  /**
170
178
  * Where to store the cache of executions for promptbook CLI
171
179
  *
@@ -173,7 +181,7 @@ export declare const DEFAULT_BOOKS_DIRNAME = "./books";
173
181
  *
174
182
  * @public exported from `@promptbook/core`
175
183
  */
176
- export declare const DEFAULT_EXECUTIONS_CACHE_DIRNAME = "./.promptbook/executions-cache";
184
+ export declare const DEFAULT_EXECUTION_CACHE_DIRNAME = "./.promptbook/execution-cache";
177
185
  /**
178
186
  * Where to store the scrape cache
179
187
  *
@@ -3,7 +3,7 @@ import type fs from 'fs/promises';
3
3
  /**
4
4
  * Container for all the tools needed to manipulate with filesystem
5
5
  */
6
- export type FilesystemTools = Pick<typeof fs, 'access' | 'constants' | 'readFile' | 'writeFile' | 'stat' | 'readdir'>;
6
+ export type FilesystemTools = Pick<typeof fs, 'access' | 'constants' | 'readFile' | 'writeFile' | 'stat' | 'readdir' | 'mkdir'>;
7
7
  /**
8
8
  * TODO: Implement destroyable pattern to free resources
9
9
  */
@@ -2,11 +2,13 @@ import type { PipelineExecutorResult } from './PipelineExecutorResult';
2
2
  /**
3
3
  * Asserts that the execution of a Promptbook is successful
4
4
  *
5
+ * Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
6
+ *
5
7
  * @param executionResult - The partial result of the Promptbook execution
6
8
  * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
7
9
  * @public exported from `@promptbook/core`
8
10
  */
9
- export declare function assertsExecutionSuccessful(executionResult: Pick<PipelineExecutorResult, 'isSuccessful' | 'errors'>): void;
11
+ export declare function assertsExecutionSuccessful(executionResult: Pick<PipelineExecutorResult, 'isSuccessful' | 'errors' | 'warnings'>): void;
10
12
  /**
11
13
  * TODO: [🐚] This function should be removed OR changed OR be completely rewritten
12
14
  * TODO: [🧠] Can this return type be better typed than void
@@ -2,9 +2,10 @@ import type { PipelineString } from './PipelineString';
2
2
  /**
3
3
  * Tag function for notating a pipeline with a book\`...\ notation as template literal
4
4
  *
5
- * Note: There are 2 similar functions:
5
+ * Note: There are 3 similar functions:
6
6
  * 1) `prompt` for notating single prompt exported from `@promptbook/utils`
7
- * 1) `book` for notating and validating entire books exported from `@promptbook/utils`
7
+ * 2) `promptTemplate` alias for `prompt`
8
+ * 3) `book` for notating and validating entire books exported from `@promptbook/utils`
8
9
  *
9
10
  * @param strings @@@
10
11
  * @param values @@@
@@ -2,16 +2,29 @@ import type { string_prompt } from '../types/typeAliases';
2
2
  /**
3
3
  * Tag function for notating a prompt as template literal
4
4
  *
5
- * Note: There are 2 similar functions:
5
+ * Note: There are 3 similar functions:
6
6
  * 1) `prompt` for notating single prompt exported from `@promptbook/utils`
7
- * 1) `book` for notating and validating entire books exported from `@promptbook/utils`
7
+ * 2) `promptTemplate` alias for `prompt`
8
+ * 3) `book` for notating and validating entire books exported from `@promptbook/utils`
8
9
  *
9
- * @param strings @@@
10
- * @param values @@@
11
- * @returns the pipeline string
10
+ * @param strings
11
+ * @param values
12
+ * @returns the prompt string
12
13
  * @public exported from `@promptbook/utils`
13
14
  */
14
15
  export declare function prompt(strings: TemplateStringsArray, ...values: Array<string>): string_prompt;
16
+ /**
17
+ * Tag function for notating a prompt as template literal
18
+ *
19
+ * Note: There are 3 similar functions:
20
+ * 1) `prompt` for notating single prompt exported from `@promptbook/utils`
21
+ * 2) `promptTemplate` alias for `prompt`
22
+ * 3) `book` for notating and validating entire books exported from `@promptbook/utils`
23
+ *
24
+ * @alias prompt
25
+ * @public exported from `@promptbook/utils`
26
+ */
27
+ export declare const promptTemplate: typeof prompt;
15
28
  /**
16
29
  * TODO: [🧠][🈴] Where is the best location for this file
17
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6,6 +6,7 @@ import type { PipelineString } from '../pipeline/PipelineString';
6
6
  import type { TaskProgress } from '../types/TaskProgress';
7
7
  import type { InputParameters } from '../types/typeAliases';
8
8
  import type { string_filename } from '../types/typeAliases';
9
+ import type { string_parameter_value } from '../types/typeAliases';
9
10
  import type { string_pipeline_url } from '../types/typeAliases';
10
11
  /**
11
12
  * Wizzard for simple usage of the Promptbook
@@ -27,7 +28,12 @@ declare class Wizzard {
27
28
  *
28
29
  * Note: This works simmilar to the `ptbk run` command
29
30
  */
30
- execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
31
+ execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
32
+ /**
33
+ * Simple result of the execution
34
+ */
35
+ result: string_parameter_value;
36
+ } & PipelineExecutorResult>;
31
37
  private executionTools;
32
38
  /**
33
39
  * Provides the tools automatically for the Node.js environment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-client",
3
- "version": "0.84.0-10",
3
+ "version": "0.84.0-12",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
@@ -54,7 +54,7 @@
54
54
  "module": "./esm/index.es.js",
55
55
  "typings": "./esm/typings/src/_packages/remote-client.index.d.ts",
56
56
  "peerDependencies": {
57
- "@promptbook/core": "0.84.0-10"
57
+ "@promptbook/core": "0.84.0-12"
58
58
  },
59
59
  "dependencies": {
60
60
  "crypto-js": "4.2.0",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-9';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-11';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4512,6 +4512,21 @@
4512
4512
  * Note: [💞] Ignore a discrepancy between file name and entity name
4513
4513
  */
4514
4514
 
4515
+ /**
4516
+ * Checks if value is valid email
4517
+ *
4518
+ * @public exported from `@promptbook/utils`
4519
+ */
4520
+ function isValidEmail(email) {
4521
+ if (typeof email !== 'string') {
4522
+ return false;
4523
+ }
4524
+ if (email.split('\n').length > 1) {
4525
+ return false;
4526
+ }
4527
+ return /^.+@.+\..+$/.test(email);
4528
+ }
4529
+
4515
4530
  /**
4516
4531
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
4517
4532
  * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
@@ -4525,6 +4540,15 @@
4525
4540
  if (isValidJsonString(pipelineString)) {
4526
4541
  throw new ParseError('Expected a book, but got a JSON string');
4527
4542
  }
4543
+ else if (isValidUrl(pipelineString)) {
4544
+ throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
4545
+ }
4546
+ else if (isValidFilePath(pipelineString)) {
4547
+ throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
4548
+ }
4549
+ else if (isValidEmail(pipelineString)) {
4550
+ throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
4551
+ }
4528
4552
  // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
4529
4553
  return pipelineString;
4530
4554
  }