@promptbook/remote-server 0.68.0-0 → 0.68.0-2

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 (87) hide show
  1. package/README.md +4 -4
  2. package/esm/index.es.js +11 -8
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +7 -16
  5. package/esm/typings/src/_packages/core.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +20 -24
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  8. package/esm/typings/src/commands/BLOCK/BlockTypes.d.ts +1 -1
  9. package/esm/typings/src/commands/BLOCK/blockCommandParser.d.ts +2 -2
  10. package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +14 -6
  11. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -2
  12. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +9 -0
  13. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +14 -0
  14. package/esm/typings/src/commands/{EXPECT/ExpectFormatCommand.d.ts → FORMAT/FormatCommand.d.ts} +2 -2
  15. package/esm/typings/src/commands/FORMAT/formatCommand.test.d.ts +1 -0
  16. package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +9 -0
  17. package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +2 -2
  18. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +2 -2
  19. package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -2
  20. package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +2 -2
  21. package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +2 -2
  22. package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +2 -2
  23. package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +2 -2
  24. package/esm/typings/src/commands/URL/urlCommandParser.d.ts +2 -2
  25. package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +2 -2
  26. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +2 -2
  27. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +6 -4
  28. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  29. package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
  30. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +137 -30
  31. package/esm/typings/src/commands/index.d.ts +1 -1
  32. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
  33. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -1
  34. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
  35. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  36. package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +14 -0
  37. package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.test.d.ts +1 -0
  38. package/esm/typings/src/conversion/utils/extractVariables.d.ts +1 -1
  39. package/esm/typings/src/conversion/utils/renameParameter.d.ts +2 -2
  40. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  41. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +1 -1
  42. package/esm/typings/src/errors/{ParsingError.d.ts → ParseError.d.ts} +5 -2
  43. package/esm/typings/src/errors/index.d.ts +2 -2
  44. package/esm/typings/src/execution/CommonExecutionToolsOptions.d.ts +5 -0
  45. package/esm/typings/src/execution/PromptResult.d.ts +2 -0
  46. package/esm/typings/src/execution/PromptResultUsage.d.ts +1 -1
  47. package/esm/typings/src/execution/createPipelineExecutor.d.ts +1 -1
  48. package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
  49. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -1
  50. package/esm/typings/src/postprocessing/utils/extractBlock.d.ts +2 -2
  51. package/esm/typings/src/postprocessing/utils/extractJsonBlock.d.ts +3 -3
  52. package/esm/typings/src/prepare/prepareTemplates.d.ts +4 -5
  53. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -1
  54. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -1
  55. package/esm/typings/src/storage/utils/PrefixStorage.d.ts +1 -1
  56. package/esm/typings/src/types/ModelRequirements.d.ts +2 -0
  57. package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +13 -0
  58. package/esm/typings/src/types/PipelineJson/Expectations.d.ts +1 -1
  59. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +1 -1
  60. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  61. package/esm/typings/src/types/PipelineJson/{PromptTemplateParameterJson.d.ts → ParameterJson.d.ts} +2 -2
  62. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
  63. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +13 -8
  64. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  65. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +20 -9
  66. package/esm/typings/src/types/PipelineJson/{ScriptJson.d.ts → ScriptTemplateJson.d.ts} +4 -4
  67. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +3 -3
  68. package/esm/typings/src/types/PipelineJson/TemplateJson.d.ts +11 -0
  69. package/esm/typings/src/types/PipelineJson/{PromptTemplateJsonCommon.d.ts → TemplateJsonCommon.d.ts} +12 -13
  70. package/esm/typings/src/types/PipelineString.d.ts +1 -1
  71. package/esm/typings/src/types/Prompt.d.ts +4 -2
  72. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
  73. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +1 -0
  74. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  75. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  76. package/esm/typings/src/utils/organization/___and___.d.ts +7 -0
  77. package/esm/typings/src/utils/organization/{___.d.ts → ___or___.d.ts} +1 -1
  78. package/esm/typings/src/utils/parseNumber.d.ts +1 -1
  79. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +1 -1
  80. package/package.json +2 -2
  81. package/umd/index.umd.js +11 -8
  82. package/umd/index.umd.js.map +1 -1
  83. package/esm/typings/src/commands/EXPECT/ExpectAmountCommand.d.ts +0 -17
  84. package/esm/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts +0 -14
  85. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +0 -27
  86. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +0 -14
  87. /package/esm/typings/src/{conversion/utils/extractParameterNamesFromPromptTemplate.test.d.ts → commands/FOREACH/foreachCommand.test.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineTemplateCommandParser } from '../_common/types/CommandParser';
2
2
  import type { JokerCommand } from './JokerCommand';
3
3
  /**
4
4
  * Parses the joker command
@@ -6,4 +6,4 @@ import type { JokerCommand } from './JokerCommand';
6
6
  * @see ./JOKER-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const jokerCommandParser: CommandParser<JokerCommand>;
9
+ export declare const jokerCommandParser: PipelineTemplateCommandParser<JokerCommand>;
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
2
2
  import type { KnowledgeCommand } from './KnowledgeCommand';
3
3
  /**
4
4
  * Parses the knowledge command
@@ -6,4 +6,4 @@ import type { KnowledgeCommand } from './KnowledgeCommand';
6
6
  * @see ./KNOWLEDGE-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const knowledgeCommandParser: CommandParser<KnowledgeCommand>;
9
+ export declare const knowledgeCommandParser: PipelineHeadCommandParser<KnowledgeCommand>;
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineBothCommandParser } from '../_common/types/CommandParser';
2
2
  import type { ModelCommand } from './ModelCommand';
3
3
  /**
4
4
  * Parses the model command
@@ -6,4 +6,4 @@ import type { ModelCommand } from './ModelCommand';
6
6
  * @see ./MODEL-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const modelCommandParser: CommandParser<ModelCommand>;
9
+ export declare const modelCommandParser: PipelineBothCommandParser<ModelCommand>;
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineBothCommandParser } from '../_common/types/CommandParser';
2
2
  import type { ParameterCommand } from './ParameterCommand';
3
3
  /**
4
4
  * Parses the parameter command
@@ -6,4 +6,4 @@ import type { ParameterCommand } from './ParameterCommand';
6
6
  * @see ./PARAMETER-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const parameterCommandParser: CommandParser<ParameterCommand>;
9
+ export declare const parameterCommandParser: PipelineBothCommandParser<ParameterCommand>;
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineBothCommandParser } from '../_common/types/CommandParser';
2
2
  import type { PersonaCommand } from './PersonaCommand';
3
3
  /**
4
4
  * Parses the persona command
@@ -6,4 +6,4 @@ import type { PersonaCommand } from './PersonaCommand';
6
6
  * @see ./PERSONA-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const personaCommandParser: CommandParser<PersonaCommand>;
9
+ export declare const personaCommandParser: PipelineBothCommandParser<PersonaCommand>;
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineTemplateCommandParser } from '../_common/types/CommandParser';
2
2
  import type { PostprocessCommand } from './PostprocessCommand';
3
3
  /**
4
4
  * Parses the postprocess command
@@ -6,4 +6,4 @@ import type { PostprocessCommand } from './PostprocessCommand';
6
6
  * @see ./POSTPROCESS-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const postprocessCommandParser: CommandParser<PostprocessCommand>;
9
+ export declare const postprocessCommandParser: PipelineTemplateCommandParser<PostprocessCommand>;
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
2
2
  import type { PromptbookVersionCommand } from './PromptbookVersionCommand';
3
3
  /**
4
4
  * Parses the PROMPTBOOK_VERSION command
@@ -6,4 +6,4 @@ import type { PromptbookVersionCommand } from './PromptbookVersionCommand';
6
6
  * @see ./PROMPTBOOK_VERSION-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const promptbookVersionCommandParser: CommandParser<PromptbookVersionCommand>;
9
+ export declare const promptbookVersionCommandParser: PipelineHeadCommandParser<PromptbookVersionCommand>;
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
2
2
  import type { UrlCommand } from './UrlCommand';
3
3
  /**
4
4
  * Parses the url command
@@ -6,4 +6,4 @@ import type { UrlCommand } from './UrlCommand';
6
6
  * @see ./URL-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const urlCommandParser: CommandParser<UrlCommand>;
9
+ export declare const urlCommandParser: PipelineHeadCommandParser<UrlCommand>;
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
2
2
  import type { ActionCommand } from './ActionCommand';
3
3
  /**
4
4
  * Parses the action command
@@ -6,4 +6,4 @@ import type { ActionCommand } from './ActionCommand';
6
6
  * @see ./ACTION-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const actionCommandParser: CommandParser<ActionCommand>;
9
+ export declare const actionCommandParser: PipelineHeadCommandParser<ActionCommand>;
@@ -1,4 +1,4 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineHeadCommandParser } from '../_common/types/CommandParser';
2
2
  import type { InstrumentCommand } from './InstrumentCommand';
3
3
  /**
4
4
  * Parses the instrument command
@@ -6,4 +6,4 @@ import type { InstrumentCommand } from './InstrumentCommand';
6
6
  * @see ./INSTRUMENT-README.md for more details
7
7
  * @private within the commands folder
8
8
  */
9
- export declare const instrumentCommandParser: CommandParser<InstrumentCommand>;
9
+ export declare const instrumentCommandParser: PipelineHeadCommandParser<InstrumentCommand>;
@@ -1,12 +1,14 @@
1
- import type { CommandParser } from '../_common/types/CommandParser';
1
+ import type { PipelineBothCommandParser } from '../_common/types/CommandParser';
2
2
  import type { BoilerplateCommand } from './BoilerplateCommand';
3
3
  /**
4
4
  * Parses the boilerplate command
5
5
  *
6
- * @see ./BOILERPLATE-README.md for more details
6
+ * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.ptbk.md` file
7
+ *
8
+ * @see ./BOILERPLATE-README.md for more details <- TODO: @@@ Write theese README files OR remove this link + add annotation here (to all commands)
7
9
  * @private within the commands folder
8
10
  */
9
- export declare const boilerplateCommandParser: CommandParser<BoilerplateCommand>;
11
+ export declare const boilerplateCommandParser: PipelineBothCommandParser<BoilerplateCommand>;
10
12
  /**
11
- * TODO: [💐] Implement BOILERPLATE command into `pipelineStringToJsonSync` function
13
+ * TODO: !!!!!! Make .ptbk.md file with examples of the BOILERPLATE command and fail
12
14
  */
@@ -5,7 +5,7 @@ import type { CommandUsagePlace } from './types/CommandUsagePlaces';
5
5
  * Parses one line of ul/ol to command
6
6
  *
7
7
  * @returns parsed command object
8
- * @throws {ParsingError} if the command is invalid
8
+ * @throws {ParseError} if the command is invalid
9
9
  *
10
10
  * @private within the pipelineStringToJson
11
11
  */
@@ -1,6 +1,6 @@
1
1
  import { COMMANDS } from '../../index';
2
2
  /**
3
- * Command is one piece of the prompt template which adds some logic to the prompt template or the whole pipeline.
3
+ * Command is one piece of the template which adds some logic to the template or the whole pipeline.
4
4
  * It is parsed from the markdown from ul/ol items - one command per one item.
5
5
  */
6
6
  export type Command = ReturnType<typeof COMMANDS[number]['parse']>;
@@ -1,64 +1,171 @@
1
1
  import type { WritableDeep } from 'type-fest';
2
- import type { PromptTemplateJson } from '../../../types/PipelineJson/PromptTemplateJson';
3
2
  import type { PipelineJson } from '../../../types/PipelineJson/PipelineJson';
3
+ import type { TemplateJson } from '../../../types/PipelineJson/TemplateJson';
4
4
  import type { string_markdown_text } from '../../../types/typeAliases';
5
5
  import type { string_name } from '../../../types/typeAliases';
6
6
  import type { string_promptbook_documentation_url } from '../../../types/typeAliases';
7
7
  import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
8
+ import type { ___and___ } from '../../../utils/organization/___and___';
8
9
  import type { CommandUsagePlace } from './CommandUsagePlaces';
9
- export type CommandParser<TCommand extends {
10
+ /**
11
+ * @@@
12
+ *
13
+ * @private just abstract helper for command parsers
14
+ */
15
+ export type CommandBase = {
10
16
  type: string_name & string_SCREAMING_CASE;
11
- }> = {
17
+ };
18
+ /**
19
+ * @@@
20
+ */
21
+ export type CommandParser<TCommand extends CommandBase> = PipelineHeadCommandParser<TCommand> | PipelineTemplateCommandParser<TCommand> | PipelineBothCommandParser<TCommand>;
22
+ /**
23
+ * @@@
24
+ *
25
+ * @private just abstract the common properties of the command parsers
26
+ */
27
+ export type CommonCommandParser<TCommand extends CommandBase> = {
28
+ /**
29
+ * @@@
30
+ */
12
31
  readonly name: string_name & string_SCREAMING_CASE;
32
+ /**
33
+ * @@@
34
+ */
35
+ readonly isUsedInPipelineHead: boolean;
36
+ /**
37
+ * @@@
38
+ */
39
+ readonly isUsedInPipelineTemplate: boolean;
40
+ /**
41
+ * @@@
42
+ */
13
43
  readonly aliasNames?: Array<string_name & string_SCREAMING_CASE>;
44
+ /**
45
+ * @@@
46
+ */
14
47
  readonly deprecatedNames?: Array<string_name & string_SCREAMING_CASE>;
15
- readonly usagePlaces: Array<CommandUsagePlace>;
48
+ /**
49
+ * @@@
50
+ */
16
51
  readonly description: string_markdown_text;
52
+ /**
53
+ * @@@
54
+ */
17
55
  readonly documentationUrl: string_promptbook_documentation_url;
56
+ /**
57
+ * @@@
58
+ */
18
59
  readonly examples: Array<string_markdown_text>;
19
60
  /**
20
- * @throws {ParsingError} if the parsing fails
61
+ * @throws {ParseError} if the parsing fails
21
62
  */
22
63
  parse(input: CommandParserInput): TCommand;
23
64
  /**
24
- * @@@ Mutated by the command
65
+ * Converts the command back to string
66
+ *
67
+ * Note: This is used in `pipelineJsonToString` utility
25
68
  */
26
- applyToPipelineJson?(command: TCommand, subjects: ApplyToPipelineJsonSubjects): void;
69
+ stringify(command: TCommand): string_markdown_text;
27
70
  };
28
- export type CommandParserInput = {
29
- readonly usagePlace: CommandUsagePlace;
30
- readonly raw: string_markdown_text;
31
- readonly rawArgs: string_markdown_text;
32
- readonly normalized: string_name & string_SCREAMING_CASE;
33
- readonly args: Array<string_name & string_SCREAMING_CASE>;
71
+ /**
72
+ * @@@
73
+ */
74
+ export type PipelineBothCommandParser<TCommand extends CommandBase> = ___and___ & Omit<PipelineHeadCommandParser<TCommand>, 'isUsedInPipelineTemplate'> & Omit<PipelineTemplateCommandParser<TCommand>, 'isUsedInPipelineHead'>;
75
+ /**
76
+ * @@@
77
+ */
78
+ export type PipelineHeadCommandParser<TCommand extends CommandBase> = CommonCommandParser<TCommand> & {
79
+ /**
80
+ * @@@
81
+ */
82
+ readonly isUsedInPipelineHead: true;
83
+ /**
84
+ * @@@
85
+ */
86
+ readonly isUsedInPipelineTemplate: false;
87
+ /**
88
+ * Apply the command to the `pipelineJson`
89
+ *
90
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
91
+ */
92
+ $applyToPipelineJson(command: TCommand, $pipelineJson: $PipelineJson): void;
93
+ /**
94
+ * Reads the command from the `PipelineJson`
95
+ *
96
+ * Note: This is used in `pipelineJsonToString` utility
97
+ */
98
+ takeFromPipelineJson(pipelineJson: PipelineJson): Array<TCommand>;
34
99
  };
35
100
  /**
36
- * @@@ Mutated by the command
101
+ * @@@
37
102
  */
38
- export type ApplyToPipelineJsonSubjects = {
103
+ export type PipelineTemplateCommandParser<TCommand extends CommandBase> = CommonCommandParser<TCommand> & {
39
104
  /**
40
- * @@@ Mutated by the command
105
+ * @@@
41
106
  */
42
- readonly pipelineJson: WritableDeep<PipelineJson>;
107
+ readonly isUsedInPipelineHead: false;
43
108
  /**
44
109
  * @@@
110
+ */
111
+ readonly isUsedInPipelineTemplate: true;
112
+ /**
113
+ * Apply the command to the `pipelineJson`
45
114
  *
46
- * @@@ Mutated by the command
115
+ * Note: `$` is used to indicate that this function mutates given `templateJson` and/or `pipelineJson`
116
+ */
117
+ $applyToTemplateJson(command: TCommand, $templateJson: $TemplateJson, $pipelineJson: $PipelineJson): void;
118
+ /**
119
+ * Reads the command from the `TemplateJson`
47
120
  *
48
- * When used in
49
- * - `PIPELINE_HEAD` it is `null`
50
- * - `PIPELINE_TEMPLATE` it is the prompt template
121
+ * Note: This is used in `pipelineJsonToString` utility
51
122
  */
52
- readonly templateJson: null | Partial<WritableDeep<PromptTemplateJson>>;
123
+ takeFromTemplateJson($templateJson: $TemplateJson): Array<TCommand>;
53
124
  };
54
125
  /**
55
- * TODO: @@@ Annotate all
56
- * TODO: [🍧][♓️] Add order here
57
- * TODO: [🧠] Maybe put flag if it is for whole `.ptbk.md` file of just one section
58
- * TODO: [🍧] All commands must implement `applyToPipelineJson` method
59
- * which will apply parsed command to the pipeline JSON
60
- * it will be called from `pipelineStringToJsonSync`
61
- * and replace hardcoded switch statement and [💐]
62
- * and throw ParsingError
126
+ * @@@
63
127
  *
128
+ * Note: `$` is used to indicate that purpose of this type is to mutate the given object
129
+ *
130
+ * @private internal helper for command parsers
131
+ */
132
+ export type $TemplateJson = {
133
+ isBlockTypeSet: boolean;
134
+ isTemplateBlock: boolean;
135
+ } & Partial<WritableDeep<TemplateJson>>;
136
+ /**
137
+ * @@@
138
+ *
139
+ * Note: `$` is used to indicate that purpose of this type is to mutate the given object
140
+ *
141
+ * @private internal helper for command parsers
142
+ */
143
+ export type $PipelineJson = WritableDeep<PipelineJson>;
144
+ /**
145
+ * @@@
146
+ */
147
+ export type CommandParserInput = {
148
+ /**
149
+ * @@@
150
+ */
151
+ readonly usagePlace: CommandUsagePlace;
152
+ /**
153
+ * @@@
154
+ */
155
+ readonly raw: string_markdown_text;
156
+ /**
157
+ * @@@
158
+ */
159
+ readonly rawArgs: string_markdown_text;
160
+ /**
161
+ * @@@
162
+ */
163
+ readonly normalized: string_name & string_SCREAMING_CASE;
164
+ /**
165
+ * @@@
166
+ */
167
+ readonly args: Array<string_name & string_SCREAMING_CASE>;
168
+ };
169
+ /**
170
+ * TODO: [♓️] Add order here
64
171
  */
@@ -3,4 +3,4 @@
3
3
  *
4
4
  * @private internal index of `parseCommand`
5
5
  */
6
- export declare const COMMANDS: readonly [import("./_common/types/CommandParser").CommandParser<import("./BLOCK/BlockCommand").BlockCommand>, import("./_common/types/CommandParser").CommandParser<import("./EXPECT/ExpectCommand").ExpectCommand>, import("./_common/types/CommandParser").CommandParser<import("./JOKER/JokerCommand").JokerCommand>, import("./_common/types/CommandParser").CommandParser<import("./MODEL/ModelCommand").ModelCommand>, import("./_common/types/CommandParser").CommandParser<import("./PARAMETER/ParameterCommand").ParameterCommand>, import("./_common/types/CommandParser").CommandParser<import("./POSTPROCESS/PostprocessCommand").PostprocessCommand>, import("./_common/types/CommandParser").CommandParser<import("./PROMPTBOOK_VERSION/PromptbookVersionCommand").PromptbookVersionCommand>, import("./_common/types/CommandParser").CommandParser<import("./URL/UrlCommand").UrlCommand>, import("./_common/types/CommandParser").CommandParser<import("./KNOWLEDGE/KnowledgeCommand").KnowledgeCommand>, import("./_common/types/CommandParser").CommandParser<import("./X_ACTION/ActionCommand").ActionCommand>, import("./_common/types/CommandParser").CommandParser<import("./X_INSTRUMENT/InstrumentCommand").InstrumentCommand>, import("./_common/types/CommandParser").CommandParser<import("./PERSONA/PersonaCommand").PersonaCommand>, import("./_common/types/CommandParser").CommandParser<import("./_BOILERPLATE/BoilerplateCommand").BoilerplateCommand>];
6
+ export declare const COMMANDS: readonly [import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./BLOCK/BlockCommand").BlockCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./EXPECT/ExpectCommand").ExpectCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./FORMAT/FormatCommand").FormatCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./JOKER/JokerCommand").JokerCommand>, import("./_common/types/CommandParser").PipelineBothCommandParser<import("./MODEL/ModelCommand").ModelCommand>, import("./_common/types/CommandParser").PipelineBothCommandParser<import("./PARAMETER/ParameterCommand").ParameterCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./POSTPROCESS/PostprocessCommand").PostprocessCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./PROMPTBOOK_VERSION/PromptbookVersionCommand").PromptbookVersionCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./URL/UrlCommand").UrlCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./KNOWLEDGE/KnowledgeCommand").KnowledgeCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./X_ACTION/ActionCommand").ActionCommand>, import("./_common/types/CommandParser").PipelineHeadCommandParser<import("./X_INSTRUMENT/InstrumentCommand").InstrumentCommand>, import("./_common/types/CommandParser").PipelineBothCommandParser<import("./PERSONA/PersonaCommand").PersonaCommand>, import("./_common/types/CommandParser").PipelineTemplateCommandParser<import("./FOREACH/ForeachCommand").ForeachCommand>, import("./_common/types/CommandParser").PipelineBothCommandParser<import("./_BOILERPLATE/BoilerplateCommand").BoilerplateCommand>];
@@ -9,7 +9,7 @@ import type { PipelineString } from '../types/PipelineString';
9
9
  */
10
10
  export declare function pipelineJsonToString(pipelineJson: PipelineJson): PipelineString;
11
11
  /**
12
- * TODO: !!!! Implement new features and commands into `promptTemplateParameterJsonToString`
12
+ * TODO: !!!!!! Implement new features and commands into `templateParameterJsonToString`
13
13
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
14
14
  * TODO: [🏛] Maybe make some markdown builder
15
15
  * TODO: [🏛] Escape all
@@ -28,7 +28,7 @@ export type PipelineStringToJsonOptions = {
28
28
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
29
29
  * @param options - Options and tools for the compilation
30
30
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
31
- * @throws {ParsingError} if the promptbook string is not valid
31
+ * @throws {ParseError} if the promptbook string is not valid
32
32
  * @public exported from `@promptbook/core`
33
33
  */
34
34
  export declare function pipelineStringToJson(pipelineString: PipelineString, options?: PipelineStringToJsonOptions): Promise<PipelineJson>;
@@ -13,7 +13,7 @@ import type { PipelineString } from '../types/PipelineString';
13
13
  *
14
14
  * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
15
15
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
16
- * @throws {ParsingError} if the promptbook string is not valid
16
+ * @throws {ParseError} if the promptbook string is not valid
17
17
  * @public exported from `@promptbook/core`
18
18
  */
19
19
  export declare function pipelineStringToJsonSync(pipelineString: PipelineString): PipelineJson;
@@ -25,5 +25,5 @@ export declare function pipelineStringToJsonSync(pipelineString: PipelineString)
25
25
  * TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
26
26
  * TODO: [♈] Probbably move expectations from templates to parameters
27
27
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
28
- * TODO: [🍙] Make some standart order of json properties
28
+ * TODO: [🍙] Make some standard order of json properties
29
29
  */
@@ -1,14 +1,14 @@
1
1
  import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
2
- import type { PromptTemplateJson } from '../../types/PipelineJson/PromptTemplateJson';
2
+ import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
3
3
  import type { string_href } from '../../types/typeAliases';
4
4
  /**
5
5
  * Addtional options for rendering Mermaid graph
6
6
  */
7
7
  export type renderPipelineMermaidOptions = {
8
8
  /**
9
- * Callback for creating from prompt template graph node
9
+ * Callback for creating from template graph node
10
10
  */
11
- linkPromptTemplate?(promptTemplate: PromptTemplateJson): {
11
+ linkTemplate?(template: TemplateJson): {
12
12
  href: string_href;
13
13
  title: string;
14
14
  } | null;
@@ -0,0 +1,14 @@
1
+ import type { TemplateJson } from '../../types/PipelineJson/TemplateJson';
2
+ import type { string_parameter_name } from '../../types/typeAliases';
3
+ /**
4
+ * Parses the template and returns the set of all used parameters
5
+ *
6
+ * @param template the template with used parameters
7
+ * @returns the set of parameter names
8
+ * @throws {ParseError} if the script is invalid
9
+ * @public exported from `@promptbook/utils`
10
+ */
11
+ export declare function extractParameterNamesFromTemplate(template: Pick<TemplateJson, 'title' | 'description' | 'blockType' | 'content' | 'preparedContent' | 'jokerParameterNames'>): Set<string_parameter_name>;
12
+ /**
13
+ * TODO: [🔣] If script require contentLanguage
14
+ */
@@ -5,7 +5,7 @@ import type { string_javascript_name } from '../../types/typeAliases';
5
5
  *
6
6
  * @param script from which to extract the variables
7
7
  * @returns the list of variable names
8
- * @throws {ParsingError} if the script is invalid
8
+ * @throws {ParseError} if the script is invalid
9
9
  * @public exported from `@promptbook/utils`
10
10
  */
11
11
  export declare function extractVariables(script: string_javascript): Set<string_javascript_name>;
@@ -16,8 +16,8 @@ type RenameParameterOptions = {
16
16
  readonly newParameterName: string_name;
17
17
  };
18
18
  /**
19
- * Function renameParameter will find all usable parameters for given prompt template
20
- * In other words, it will find all parameters that are not used in the prompt template itseld and all its dependencies
19
+ * Function `renameParameter` will find all usable parameters for given template
20
+ * In other words, it will find all parameters that are not used in the template itseld and all its dependencies
21
21
  *
22
22
  * @throws {PipelineLogicError} If the new parameter name is already used in the pipeline
23
23
  * @public exported from `@promptbook/utils`
@@ -12,5 +12,5 @@ export declare function stringifyPipelineJson<TType>(pipeline: TType): string_js
12
12
  * TODO: [🐝] Not Working propperly @see https://promptbook.studio/samples/mixed-knowledge.ptbk.md
13
13
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
14
14
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
15
- * TODO: [🍙] Make some standart order of json properties
15
+ * TODO: [🍙] Make some standard order of json properties
16
16
  */
@@ -7,7 +7,7 @@ import type { string_json } from '../../types/typeAliases';
7
7
  * Note: Using here custom import to work in jest tests
8
8
  * Note: Using sync version is 💩 in the production code, but it's ok here in tests
9
9
  *
10
- * @param path - The path to the file relative to samples/templates directory
10
+ * @param path - The path to the file relative to samples/pipelines directory
11
11
  * @private internal function of tests
12
12
  */
13
13
  export declare function importPipelineWithoutPreparation(path: `${string}.ptbk.md`): PipelineString;
@@ -3,7 +3,10 @@
3
3
  *
4
4
  * @public exported from `@promptbook/core`
5
5
  */
6
- export declare class ParsingError extends Error {
7
- readonly name = "ParsingError";
6
+ export declare class ParseError extends Error {
7
+ readonly name = "ParseError";
8
8
  constructor(message: string);
9
9
  }
10
+ /**
11
+ * TODO: Maybe split `ParseError` and `ApplyError`
12
+ */
@@ -4,7 +4,7 @@ import { ExpectError } from './ExpectError';
4
4
  import { LimitReachedError } from './LimitReachedError';
5
5
  import { NotFoundError } from './NotFoundError';
6
6
  import { NotYetImplementedError } from './NotYetImplementedError';
7
- import { ParsingError } from './ParsingError';
7
+ import { ParseError } from './ParseError';
8
8
  import { PipelineExecutionError } from './PipelineExecutionError';
9
9
  import { PipelineLogicError } from './PipelineLogicError';
10
10
  import { PipelineUrlError } from './PipelineUrlError';
@@ -21,7 +21,7 @@ export declare const ERRORS: {
21
21
  readonly LimitReachedError: typeof LimitReachedError;
22
22
  readonly NotFoundError: typeof NotFoundError;
23
23
  readonly NotYetImplementedError: typeof NotYetImplementedError;
24
- readonly ParsingError: typeof ParsingError;
24
+ readonly ParseError: typeof ParseError;
25
25
  readonly PipelineExecutionError: typeof PipelineExecutionError;
26
26
  readonly PipelineLogicError: typeof PipelineLogicError;
27
27
  readonly PipelineUrlError: typeof PipelineUrlError;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @@@
3
+ *
4
+ * @private just abstract the common properties for the execution tools
5
+ */
1
6
  export type CommonExecutionToolsOptions = {
2
7
  /**
3
8
  * If true, the internal executions will be logged
@@ -39,6 +39,8 @@ export type EmbeddingPromptResult = Omit<CommonPromptResult, 'content'> & {
39
39
  * Common properties for all prompt results
40
40
  *
41
41
  * Note: [🚉] This is fully serializable as JSON
42
+ *
43
+ * @private just abstract the common properties of the prompt results
42
44
  */
43
45
  export type CommonPromptResult = {
44
46
  /**
@@ -29,5 +29,5 @@ export type PromptResultUsage = {
29
29
  */
30
30
  export type PromptResultUsageCounts = Record<`${KebabCase<'TOKENS' | ExpectationUnit>}Count`, UncertainNumber>;
31
31
  /**
32
- * TODO: [🍙] Make some standart order of json properties
32
+ * TODO: [🍙] Make some standard order of json properties
33
33
  */
@@ -63,7 +63,7 @@ export {};
63
63
  * TODO: [🧠][🌳] Use here `countTotalUsage` and put preparation and prepared pipiline to report
64
64
  * TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
65
65
  * TODO: [♈] Probbably move expectations from templates to parameters
66
- * TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
66
+ * TODO: [🧠] When not meet expectations in DIALOG_TEMPLATE, make some way to tell the user
67
67
  * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
68
68
  * Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
69
69
  * TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
@@ -13,7 +13,7 @@ export declare class SimplePromptInterfaceTools implements UserInterfaceTools {
13
13
  private readonly options;
14
14
  constructor(options?: CommonExecutionToolsOptions);
15
15
  /**
16
- * Trigger window.PROMPT DIALOG
16
+ * Trigger window.DIALOG BLOCK
17
17
  */
18
18
  promptDialog(options: UserInterfaceToolsPromptDialogOptions): Promise<string>;
19
19
  }
@@ -39,7 +39,7 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
39
39
  /**
40
40
  * Calls OpenAI API to use a chat model.
41
41
  */
42
- callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'expectFormat'>): Promise<ChatPromptResult>;
42
+ callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
43
43
  /**
44
44
  * Calls OpenAI API to use a complete model.
45
45
  */
@@ -2,7 +2,7 @@ import type { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Extracts code block from markdown.
4
4
  *
5
- * - When there are multiple or no code blocks the function throws a `ParsingError`
5
+ * - When there are multiple or no code blocks the function throws a `ParseError`
6
6
  *
7
7
  * Note: There are multiple simmilar function:
8
8
  * - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
@@ -11,6 +11,6 @@ import type { string_markdown } from '../../types/typeAliases';
11
11
  * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
12
12
  *
13
13
  * @public exported from `@promptbook/markdown-utils`
14
- * @throws {ParsingError} if there is not exactly one code block in the markdown
14
+ * @throws {ParseError} if there is not exactly one code block in the markdown
15
15
  */
16
16
  export declare function extractBlock(markdown: string_markdown): string;
@@ -5,8 +5,8 @@ import type { really_unknown } from '../../utils/organization/really_unknown';
5
5
  * Extracts extracts exactly one valid JSON code block
6
6
  *
7
7
  * - When given string is a valid JSON as it is, it just returns it
8
- * - When there is no JSON code block the function throws a `ParsingError`
9
- * - When there are multiple JSON code blocks the function throws a `ParsingError`
8
+ * - When there is no JSON code block the function throws a `ParseError`
9
+ * - When there are multiple JSON code blocks the function throws a `ParseError`
10
10
  *
11
11
  * Note: It is not important if marked as ```json BUT if it is VALID JSON
12
12
  * Note: There are multiple simmilar function:
@@ -16,7 +16,7 @@ import type { really_unknown } from '../../utils/organization/really_unknown';
16
16
  * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
17
17
  *
18
18
  * @public exported from `@promptbook/markdown-utils`
19
- * @throws {ParsingError} if there is no valid JSON block in the markdown
19
+ * @throws {ParseError} if there is no valid JSON block in the markdown
20
20
  */
21
21
  export declare function extractJsonBlock(markdown: string_markdown): string_json<really_unknown>;
22
22
  /**