@promptbook/editable 0.84.0-9 → 0.85.0-0

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.
Files changed (59) hide show
  1. package/README.md +21 -5
  2. package/esm/index.es.js +56 -6
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/cli.index.d.ts +4 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +12 -4
  6. package/esm/typings/src/_packages/deepseek.index.d.ts +8 -0
  7. package/esm/typings/src/_packages/types.index.d.ts +16 -2
  8. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  9. package/esm/typings/src/_packages/wizzard.index.d.ts +4 -0
  10. package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +13 -0
  11. package/esm/typings/src/cli/cli-commands/about.d.ts +4 -1
  12. package/esm/typings/src/cli/cli-commands/hello.d.ts +3 -1
  13. package/esm/typings/src/cli/cli-commands/list-models.d.ts +3 -1
  14. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +13 -0
  15. package/esm/typings/src/cli/cli-commands/make.d.ts +3 -1
  16. package/esm/typings/src/cli/cli-commands/prettify.d.ts +3 -1
  17. package/esm/typings/src/cli/cli-commands/run.d.ts +3 -1
  18. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
  19. package/esm/typings/src/cli/cli-commands/start-server.d.ts +13 -0
  20. package/esm/typings/src/cli/cli-commands/test-command.d.ts +3 -1
  21. package/esm/typings/src/config.d.ts +27 -1
  22. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
  23. package/esm/typings/src/execution/AbstractTaskResult.d.ts +25 -0
  24. package/esm/typings/src/execution/ExecutionTask.d.ts +71 -0
  25. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  26. package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -5
  27. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -15
  28. package/esm/typings/src/execution/PromptbookFetch.d.ts +8 -1
  29. package/esm/typings/src/execution/{assertsExecutionSuccessful.d.ts → assertsTaskSuccessful.d.ts} +4 -3
  30. package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +0 -3
  31. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -6
  32. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +3 -6
  33. package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +9 -0
  34. package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +9 -0
  35. package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +14 -0
  36. package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +14 -0
  37. package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +15 -0
  38. package/esm/typings/src/pipeline/book-notation.d.ts +3 -2
  39. package/esm/typings/src/pipeline/prompt-notation.d.ts +18 -5
  40. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
  41. package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +5 -2
  42. package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -0
  43. package/esm/typings/src/types/typeAliases.d.ts +2 -0
  44. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +1 -0
  45. package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +1 -0
  46. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +3 -0
  47. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +3 -0
  48. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +3 -0
  49. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +3 -0
  50. package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +10 -0
  51. package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +1 -0
  52. package/esm/typings/src/utils/random/$randomSeed.d.ts +2 -1
  53. package/esm/typings/src/utils/random/$randomToken.d.ts +13 -0
  54. package/esm/typings/src/wizzard/wizzard.d.ts +8 -3
  55. package/package.json +9 -16
  56. package/umd/index.umd.js +56 -6
  57. package/umd/index.umd.js.map +1 -1
  58. package/esm/typings/src/remote-server/socket-types/_common/PromptbookServer_Progress.d.ts +0 -10
  59. package/esm/typings/src/types/TaskProgress.d.ts +0 -43
@@ -8,6 +8,3 @@ import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorO
8
8
  * @public exported from `@promptbook/core`
9
9
  */
10
10
  export declare function createPipelineExecutor(options: CreatePipelineExecutorOptions): PipelineExecutor;
11
- /**
12
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
13
- */
@@ -1,6 +1,5 @@
1
- import type { Promisable, ReadonlyDeep } from 'type-fest';
1
+ import type { PartialDeep, Promisable, ReadonlyDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
- import type { TaskProgress } from '../../types/TaskProgress';
4
3
  import type { InputParameters } from '../../types/typeAliases';
5
4
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
6
5
  import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
@@ -17,7 +16,7 @@ type ExecutePipelineOptions = Required<CreatePipelineExecutorOptions> & {
17
16
  /**
18
17
  * @@@
19
18
  */
20
- onProgress?(taskProgress: TaskProgress): Promisable<void>;
19
+ onProgress?(newOngoingResult: PartialDeep<PipelineExecutorResult>): Promisable<void>;
21
20
  /**
22
21
  * @@@
23
22
  */
@@ -44,6 +43,3 @@ type ExecutePipelineOptions = Required<CreatePipelineExecutorOptions> & {
44
43
  */
45
44
  export declare function executePipeline(options: ExecutePipelineOptions): Promise<PipelineExecutorResult>;
46
45
  export {};
47
- /**
48
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
49
- */
@@ -1,9 +1,9 @@
1
- import type { Promisable, ReadonlyDeep, WritableDeep } from 'type-fest';
1
+ import type { PartialDeep, Promisable, ReadonlyDeep, WritableDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
- import type { TaskProgress } from '../../types/TaskProgress';
5
4
  import type { Parameters } from '../../types/typeAliases';
6
5
  import type { ExecutionReportJson } from '../execution-report/ExecutionReportJson';
6
+ import type { PipelineExecutorResult } from '../PipelineExecutorResult';
7
7
  import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
8
8
  /**
9
9
  * @@@
@@ -26,7 +26,7 @@ type executeSingleTaskOptions = Required<CreatePipelineExecutorOptions> & {
26
26
  /**
27
27
  * @@@
28
28
  */
29
- readonly onProgress: (taskProgress: TaskProgress) => Promisable<void>;
29
+ readonly onProgress: (newOngoingResult: PartialDeep<PipelineExecutorResult>) => Promisable<void>;
30
30
  /**
31
31
  * @@@
32
32
  */
@@ -46,6 +46,3 @@ export {};
46
46
  /**
47
47
  * TODO: [🤹‍♂️]
48
48
  */
49
- /**
50
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
51
- */
@@ -1,4 +1,13 @@
1
+ import type { string_filename } from '../../../types/typeAliases';
1
2
  import type { string_markdown } from '../../../types/typeAliases';
3
+ /**
4
+ * Pass the `.env` file which was used to configure LLM tools
5
+ *
6
+ * Note: `$` is used to indicate that this variable is making side effect
7
+ *
8
+ * @private internal log of `$provideLlmToolsConfigurationFromEnv` and `$registeredLlmToolsMessage`
9
+ */
10
+ export declare function $setUsedEnvFilename(filepath: string_filename): void;
2
11
  /**
3
12
  * Creates a message with all registered LLM tools
4
13
  *
@@ -0,0 +1,9 @@
1
+ import type { createDeepSeek } from '@ai-sdk/deepseek';
2
+ import type { VercelExecutionToolsOptions } from '../vercel/VercelExecutionToolsOptions';
3
+ /**
4
+ * Options for `DeepseekExecutionTools`
5
+ *
6
+ * This combines options for Promptbook, Deepseek and Vercel together
7
+ * @public exported from `@promptbook/deepseek`
8
+ */
9
+ export type DeepseekExecutionToolsOptions = Omit<VercelExecutionToolsOptions, 'title' | 'description' | 'vercelProvider' | 'availableModels'> & Parameters<typeof createDeepSeek>[0];
@@ -0,0 +1,14 @@
1
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
+ import type { DeepseekExecutionToolsOptions } from './DeepseekExecutionToolsOptions';
3
+ /**
4
+ * Execution Tools for calling Deepseek API.
5
+ *
6
+ * @public exported from `@promptbook/deepseek`
7
+ */
8
+ export declare const createDeepseekExecutionTools: ((options: DeepseekExecutionToolsOptions) => LlmExecutionTools) & {
9
+ packageName: string;
10
+ className: string;
11
+ };
12
+ /**
13
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
14
+ */
@@ -0,0 +1,14 @@
1
+ import type { Registration } from '../../utils/$Register';
2
+ /**
3
+ * Registration of LLM provider metadata
4
+ *
5
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
+ *
7
+ * @public exported from `@promptbook/core`
8
+ * @public exported from `@promptbook/wizzard`
9
+ * @public exported from `@promptbook/cli`
10
+ */
11
+ export declare const _DeepseekMetadataRegistration: Registration;
12
+ /**
13
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14
+ */
@@ -0,0 +1,15 @@
1
+ import type { Registration } from '../../utils/$Register';
2
+ /**
3
+ * Registration of LLM provider
4
+ *
5
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
+ *
7
+ * @public exported from `@promptbook/deepseek`
8
+ * @public exported from `@promptbook/wizzard`
9
+ * @public exported from `@promptbook/cli`
10
+ */
11
+ export declare const _DeepseekRegistration: Registration;
12
+ /**
13
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
14
+ * Note: [💞] Ignore a discrepancy between file name and entity name
15
+ */
@@ -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
@@ -13,5 +13,5 @@ import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOpt
13
13
  */
14
14
  export declare function preparePipelineOnRemoteServer<TCustomOptions = undefined>(pipeline: PipelineJson, options: RemoteClientOptions<TCustomOptions>): Promise<PipelineJson>;
15
15
  /**
16
- * TODO: !!!! Do not return Promise<PipelineJson> But PreparePipelineTask
16
+ * TODO: [🐚] Do not return `Promise<PipelineJson>` But `PreparationTask`
17
17
  */
@@ -9,7 +9,7 @@ import type { ApplicationRemoteServerClientOptions } from '../../types/RemoteSer
9
9
  */
10
10
  export type PromptbookServer_Identification<TCustomOptions> = PromptbookServer_ApplicationIdentification<TCustomOptions> | PromptbookServer_AnonymousIdentification;
11
11
  /**
12
- * Application mode is @@@!!!
12
+ * Application mode is situation when you run known and well-defined books with your own api keys
13
13
  *
14
14
  * @public exported from `@promptbook/remote-server`
15
15
  * @public exported from `@promptbook/remote-client`
@@ -21,7 +21,10 @@ export type PromptbookServer_ApplicationIdentification<TCustomOptions> = Applica
21
21
  readonly isAnonymous: false;
22
22
  };
23
23
  /**
24
- * Anonymous mode is @@@!!!
24
+ * Anonymous mode is when you run arbitrary user books without api keys from user
25
+ *
26
+ * Note: This is useful in situations when the LLM provider does not allow to call the API requests from the client side
27
+ * It is kind of a proxy mode
25
28
  *
26
29
  * @public exported from `@promptbook/remote-server`
27
30
  * @public exported from `@promptbook/remote-client`
@@ -11,6 +11,7 @@ import type { RemoteServerOptions } from './types/RemoteServerOptions';
11
11
  */
12
12
  export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): IDestroyable;
13
13
  /**
14
+ * TODO: [👩🏾‍🤝‍🧑🏾] Allow to pass custom fetch function here - PromptbookFetch
14
15
  * TODO: Split this file into multiple functions - handler for each request
15
16
  * TODO: Maybe use `$exportJson`
16
17
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
@@ -556,6 +556,7 @@ export type string_javascript_name = string;
556
556
  */
557
557
  export type string_postprocessing_function_name = string;
558
558
  export type id = string | number;
559
+ export type task_id = string;
559
560
  export type string_token = string;
560
561
  export type string_license_token = string_token;
561
562
  export type string_password = string;
@@ -588,6 +589,7 @@ export type number_tokens = number_integer & (number_positive | 0);
588
589
  export type number_positive = number;
589
590
  export type number_negative = number;
590
591
  export type number_integer = number;
592
+ export type number_port = number_positive & number_integer;
591
593
  /**
592
594
  * Semantic helper;
593
595
  * Percentage from 0 to 1 (100%) (and bellow and above)
@@ -6,3 +6,6 @@
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
8
  export declare const $isRunningInBrowser: Function;
9
+ /**
10
+ * TODO: [🎺]
11
+ */
@@ -6,3 +6,6 @@
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
8
  export declare const $isRunningInJest: Function;
9
+ /**
10
+ * TODO: [🎺]
11
+ */
@@ -6,3 +6,6 @@
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
8
  export declare const $isRunningInNode: Function;
9
+ /**
10
+ * TODO: [🎺]
11
+ */
@@ -6,3 +6,6 @@
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
8
  export declare const $isRunningInWebWorker: Function;
9
+ /**
10
+ * TODO: [🎺]
11
+ */
@@ -0,0 +1,10 @@
1
+ import type { string_file_extension } from '../../types/typeAliases';
2
+ import type { string_mime_type } from '../../types/typeAliases';
3
+ /**
4
+ * Convert mime type to file extension
5
+ *
6
+ * Note: If the mime type is invalid, `null` is returned
7
+ *
8
+ * @private within the repository
9
+ */
10
+ export declare function mimeTypeToExtension(value: string_mime_type): string_file_extension | null;
@@ -4,6 +4,7 @@ import type { number_seed } from '../../types/typeAliases';
4
4
  *
5
5
  * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
6
6
  * Warning: This function is NOT cryptographically secure (it uses Math.random internally)
7
- * @public exported from `@promptbook/utils`
7
+ *
8
+ * @private internal helper function
8
9
  */
9
10
  export declare function $randomSeed(): number_seed;
@@ -0,0 +1,13 @@
1
+ import type { string_token } from '../../types/typeAliases';
2
+ /**
3
+ * Generates random token
4
+ *
5
+ * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
6
+ *
7
+ * @private internal helper function
8
+ * @returns secure random token
9
+ */
10
+ export declare function $randomToken(randomness: number): string_token;
11
+ /**
12
+ * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
13
+ */
@@ -1,11 +1,10 @@
1
- import { Promisable } from 'type-fest';
2
1
  import type { ExecutionTools } from '../execution/ExecutionTools';
3
2
  import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
4
3
  import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
5
4
  import type { PipelineString } from '../pipeline/PipelineString';
6
- import type { TaskProgress } from '../types/TaskProgress';
7
5
  import type { InputParameters } from '../types/typeAliases';
8
6
  import type { string_filename } from '../types/typeAliases';
7
+ import type { string_parameter_value } from '../types/typeAliases';
9
8
  import type { string_pipeline_url } from '../types/typeAliases';
10
9
  /**
11
10
  * Wizzard for simple usage of the Promptbook
@@ -27,7 +26,12 @@ declare class Wizzard {
27
26
  *
28
27
  * Note: This works simmilar to the `ptbk run` command
29
28
  */
30
- execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
29
+ execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters): Promise<{
30
+ /**
31
+ * Simple result of the execution
32
+ */
33
+ result: string_parameter_value;
34
+ } & PipelineExecutorResult>;
31
35
  private executionTools;
32
36
  /**
33
37
  * Provides the tools automatically for the Node.js environment
@@ -59,5 +63,6 @@ declare class Wizzard {
59
63
  export declare const wizzard: Wizzard;
60
64
  export {};
61
65
  /**
66
+ * TODO: [🧠] Maybe some way how to handle the progress and streaming?
62
67
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
63
68
  */
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@promptbook/editable",
3
- "version": "0.84.0-9",
3
+ "version": "0.85.0-0",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
- "--note-0": " <- [🐊]",
6
5
  "private": false,
7
6
  "sideEffects": false,
8
7
  "repository": {
9
8
  "type": "git",
10
9
  "url": "https://github.com/webgptorg/promptbook"
11
10
  },
11
+ "author": "Pavol Hejný <pavol@ptbk.io> (https://www.pavolhejny.com/)",
12
12
  "contributors": [
13
- "Pavol Hejný <pavol@ptbk.io> (https://www.pavolhejny.com/)"
13
+ "Pavol Hejný <pavol@ptbk.io> (https://www.pavolhejny.com/)",
14
+ "Jiří Jahn <jiri@ptbk.io> (https://www.ptbk.io/)"
14
15
  ],
15
- "--todo-0": "TODO: [❇️] Make better list of keywords",
16
16
  "keywords": [
17
17
  "ai",
18
18
  "llm",
@@ -25,6 +25,9 @@
25
25
  "natural-language-processing",
26
26
  "nlp",
27
27
  "openai",
28
+ "o3",
29
+ "o3-mini",
30
+ "deepseek",
28
31
  "gpt-3",
29
32
  "gpt-4",
30
33
  "gpt-4o",
@@ -35,26 +38,16 @@
35
38
  "anthropic",
36
39
  "LLMOps"
37
40
  ],
38
- "license": "CC-BY-4.0",
41
+ "license": "BUSL-1.1",
39
42
  "bugs": {
40
43
  "url": "https://github.com/webgptorg/promptbook/issues"
41
44
  },
42
45
  "homepage": "https://www.npmjs.com/package/@promptbook/core",
43
- "funding": [
44
- {
45
- "type": "individual",
46
- "url": "https://buymeacoffee.com/hejny"
47
- },
48
- {
49
- "type": "github",
50
- "url": "https://github.com/webgptorg/promptbook/blob/main/README.md#%EF%B8%8F-contributing"
51
- }
52
- ],
53
46
  "main": "./umd/index.umd.js",
54
47
  "module": "./esm/index.es.js",
55
48
  "typings": "./esm/typings/src/_packages/editable.index.d.ts",
56
49
  "peerDependencies": {
57
- "@promptbook/core": "0.84.0-9"
50
+ "@promptbook/core": "0.85.0-0"
58
51
  },
59
52
  "dependencies": {
60
53
  "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-8';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0';
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
@@ -194,6 +194,12 @@
194
194
  * @public exported from `@promptbook/core`
195
195
  */
196
196
  var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
197
+ /**
198
+ * When the pipeline is flat and no name of return parameter is provided, this name is used
199
+ *
200
+ * @public exported from `@promptbook/core`
201
+ */
202
+ var DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
197
203
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
198
204
  /**
199
205
  * The maximum number of iterations for a loops
@@ -3874,6 +3880,21 @@
3874
3880
  return null;
3875
3881
  }
3876
3882
 
3883
+ /**
3884
+ * Checks if value is valid email
3885
+ *
3886
+ * @public exported from `@promptbook/utils`
3887
+ */
3888
+ function isValidEmail(email) {
3889
+ if (typeof email !== 'string') {
3890
+ return false;
3891
+ }
3892
+ if (email.split('\n').length > 1) {
3893
+ return false;
3894
+ }
3895
+ return /^.+@.+\..+$/.test(email);
3896
+ }
3897
+
3877
3898
  /**
3878
3899
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
3879
3900
  * 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.
@@ -3887,6 +3908,15 @@
3887
3908
  if (isValidJsonString(pipelineString)) {
3888
3909
  throw new ParseError('Expected a book, but got a JSON string');
3889
3910
  }
3911
+ else if (isValidUrl(pipelineString)) {
3912
+ throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
3913
+ }
3914
+ else if (isValidFilePath(pipelineString)) {
3915
+ throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
3916
+ }
3917
+ else if (isValidEmail(pipelineString)) {
3918
+ throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
3919
+ }
3890
3920
  // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
3891
3921
  return pipelineString;
3892
3922
  }
@@ -3914,12 +3944,15 @@
3914
3944
  pipelineString = removeMarkdownComments(pipelineString);
3915
3945
  pipelineString = spaceTrim__default["default"](pipelineString);
3916
3946
  var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
3917
- var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
3918
- // TODO: Also (double)check
3947
+ //const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
3948
+ var isBacktickBlockUsed = pipelineString.includes('```');
3949
+ var isQuoteBlocksUsed = /^>\s+/m.test(pipelineString);
3950
+ var isBlocksUsed = isBacktickBlockUsed || isQuoteBlocksUsed;
3951
+ // TODO: [🧉] Also (double)check
3919
3952
  // > const usedCommands
3920
3953
  // > const isBlocksUsed
3921
3954
  // > const returnStatementCount
3922
- var isFlat = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
3955
+ var isFlat = !isMarkdownBeginningWithHeadline && !isBlocksUsed; /* && isLastLineReturnStatement */
3923
3956
  return isFlat;
3924
3957
  }
3925
3958
 
@@ -3933,9 +3966,26 @@
3933
3966
  return pipelineString;
3934
3967
  }
3935
3968
  var pipelineStringLines = pipelineString.split('\n');
3936
- var returnStatement = pipelineStringLines.pop();
3969
+ var potentialReturnStatement = pipelineStringLines.pop();
3970
+ var returnStatement;
3971
+ if (/(-|=)>\s*\{.*\}/.test(potentialReturnStatement)) {
3972
+ // Note: Last line is return statement
3973
+ returnStatement = potentialReturnStatement;
3974
+ }
3975
+ else {
3976
+ // Note: Last line is not a return statement
3977
+ returnStatement = "-> {".concat(DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, "}");
3978
+ pipelineStringLines.push(potentialReturnStatement);
3979
+ }
3937
3980
  var prompt = spaceTrim__default["default"](pipelineStringLines.join('\n'));
3938
- pipelineString = validatePipelineString(spaceTrim__default["default"](function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt), "\n ```\n\n ").concat(returnStatement, "\n "); }));
3981
+ var quotedPrompt;
3982
+ if (prompt.split('\n').length <= 1) {
3983
+ quotedPrompt = "> ".concat(prompt);
3984
+ }
3985
+ else {
3986
+ quotedPrompt = spaceTrim__default["default"](function (block) { return "\n ```\n ".concat(block(prompt.split('`').join('\\`')), "\n ```\n "); });
3987
+ }
3988
+ pipelineString = validatePipelineString(spaceTrim__default["default"](function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ").concat(block(quotedPrompt), "\n\n ").concat(returnStatement, "\n "); }));
3939
3989
  // <- TODO: Maybe use book` notation
3940
3990
  return pipelineString;
3941
3991
  }