@promptbook/cli 0.67.7 → 0.67.9

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.
@@ -12,3 +12,6 @@ export type ExpectAmountCommand = {
12
12
  readonly unit: ExpectationUnit;
13
13
  readonly amount: ExpectationAmount;
14
14
  };
15
+ /**
16
+ * TODO: [🍋] Allow to `EXPECT` relative amounts like `EXPECT MAX 130% {foo} Words`
17
+ */
@@ -42,6 +42,12 @@ export declare const CONNECTION_TIMEOUT_MS: number;
42
42
  * @private within the repository - too low-level in comparison with other `MAX_...`
43
43
  */
44
44
  export declare const CONNECTION_RETRIES_LIMIT = 5;
45
+ /**
46
+ * Short time interval to prevent race conditions in milliseconds
47
+ *
48
+ * @private within the repository - too low-level in comparison with other `MAX_...`
49
+ */
50
+ export declare const IMMEDIATE_TIME = 10;
45
51
  /**
46
52
  * The maximum number of (LLM) tasks running in parallel
47
53
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.67.7",
3
+ "version": "0.67.9",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -39,7 +39,7 @@
39
39
  /**
40
40
  * The version of the Promptbook library
41
41
  */
42
- var PROMPTBOOK_VERSION = '0.67.6';
42
+ var PROMPTBOOK_VERSION = '0.67.8';
43
43
  // TODO: !!!! List here all the versions and annotate + put into script
44
44
 
45
45
  /*! *****************************************************************************
@@ -438,6 +438,12 @@
438
438
  * @private within the repository - too low-level in comparison with other `MAX_...`
439
439
  */
440
440
  var CONNECTION_RETRIES_LIMIT = 5;
441
+ /**
442
+ * Short time interval to prevent race conditions in milliseconds
443
+ *
444
+ * @private within the repository - too low-level in comparison with other `MAX_...`
445
+ */
446
+ var IMMEDIATE_TIME = 10;
441
447
  /**
442
448
  * The maximum number of (LLM) tasks running in parallel
443
449
  *
@@ -1053,7 +1059,7 @@
1053
1059
  });
1054
1060
  }
1055
1061
 
1056
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.6",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.67.6",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.67.6",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.67.6",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1062
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.8",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.67.8",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.67.8",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.67.8",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1057
1063
 
1058
1064
  /**
1059
1065
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -3222,7 +3228,7 @@
3222
3228
  }
3223
3229
  function executeSingleTemplate(currentTemplate) {
3224
3230
  return __awaiter(this, void 0, void 0, function () {
3225
- var name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2;
3231
+ var name, title, priority, progress_1, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2, progress_2;
3226
3232
  var e_4, _f, _g;
3227
3233
  return __generator(this, function (_h) {
3228
3234
  switch (_h.label) {
@@ -3230,17 +3236,24 @@
3230
3236
  name = "pipeline-executor-frame-".concat(currentTemplate.name);
3231
3237
  title = currentTemplate.title;
3232
3238
  priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
3233
- if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3234
- return [4 /*yield*/, onProgress({
3235
- name: name,
3236
- title: title,
3237
- isStarted: false,
3238
- isDone: false,
3239
- blockType: currentTemplate.blockType,
3240
- parameterName: currentTemplate.resultingParameterName,
3241
- parameterValue: null,
3242
- // <- [3]
3243
- })];
3239
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3240
+ progress_1 = {
3241
+ name: name,
3242
+ title: title,
3243
+ isStarted: false,
3244
+ isDone: false,
3245
+ blockType: currentTemplate.blockType,
3246
+ parameterName: currentTemplate.resultingParameterName,
3247
+ parameterValue: null,
3248
+ // <- [3]
3249
+ };
3250
+ if (isReturned) {
3251
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4F\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_1, null, 4)
3252
+ .split('\n')
3253
+ .map(function (line) { return "> ".concat(line); })
3254
+ .join('\n')), "\n "); }));
3255
+ }
3256
+ return [4 /*yield*/, onProgress(progress_1)];
3244
3257
  case 1:
3245
3258
  _h.sent();
3246
3259
  _h.label = 2;
@@ -3626,18 +3639,28 @@
3626
3639
  if (resultString === null) {
3627
3640
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3628
3641
  }
3629
- if (onProgress /* <- [3] */) {
3630
- onProgress({
3631
- name: name,
3632
- title: title,
3633
- isStarted: true,
3634
- isDone: true,
3635
- blockType: currentTemplate.blockType,
3636
- parameterName: currentTemplate.resultingParameterName,
3637
- parameterValue: resultString,
3638
- // <- [3]
3639
- });
3642
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3643
+ progress_2 = {
3644
+ name: name,
3645
+ title: title,
3646
+ isStarted: true,
3647
+ isDone: true,
3648
+ blockType: currentTemplate.blockType,
3649
+ parameterName: currentTemplate.resultingParameterName,
3650
+ parameterValue: resultString,
3651
+ // <- [3]
3652
+ };
3653
+ if (isReturned) {
3654
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4E\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_2, null, 4)
3655
+ .split('\n')
3656
+ .map(function (line) { return "> ".concat(line); })
3657
+ .join('\n')), "\n\n "); }));
3640
3658
  }
3659
+ return [4 /*yield*/, onProgress(progress_2)];
3660
+ case 8:
3661
+ _h.sent();
3662
+ _h.label = 9;
3663
+ case 9:
3641
3664
  parametersToPass = Object.freeze(__assign(__assign({}, parametersToPass), (_g = {}, _g[currentTemplate.resultingParameterName] = resultString /* <- Note: Not need to detect parameter collision here because pipeline checks logic consistency during construction */, _g)));
3642
3665
  return [2 /*return*/];
3643
3666
  }
@@ -3674,7 +3697,7 @@
3674
3697
  }
3675
3698
  return outputParameters;
3676
3699
  }
3677
- var errors, warnings, executionReport, _a, _b, parameter, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
3700
+ var errors, warnings, executionReport, isReturned, _a, _b, parameter, e_1_1, _loop_1, _c, _d, parameterName, state_1, e_2_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
3678
3701
  var e_1, _e, e_2, _f;
3679
3702
  return __generator(this, function (_g) {
3680
3703
  switch (_g.label) {
@@ -3699,77 +3722,123 @@
3699
3722
  description: preparedPipeline.description,
3700
3723
  promptExecutions: [],
3701
3724
  };
3725
+ isReturned = false;
3726
+ _g.label = 3;
3727
+ case 3:
3728
+ _g.trys.push([3, 9, 10, 11]);
3729
+ _a = __values(preparedPipeline.parameters.filter(function (_a) {
3730
+ var isInput = _a.isInput;
3731
+ return isInput;
3732
+ })), _b = _a.next();
3733
+ _g.label = 4;
3734
+ case 4:
3735
+ if (!!_b.done) return [3 /*break*/, 8];
3736
+ parameter = _b.value;
3737
+ if (!(inputParameters[parameter.name] === undefined)) return [3 /*break*/, 7];
3738
+ isReturned = true;
3739
+ if (!(onProgress !== undefined)) return [3 /*break*/, 6];
3740
+ // Note: Wait a short time to prevent race conditions
3741
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3742
+ case 5:
3743
+ // Note: Wait a short time to prevent race conditions
3744
+ _g.sent();
3745
+ _g.label = 6;
3746
+ case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3747
+ isSuccessful: false,
3748
+ errors: __spreadArray([
3749
+ new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3750
+ ], __read(errors), false).map(serializeError),
3751
+ warnings: [],
3752
+ executionReport: executionReport,
3753
+ outputParameters: {},
3754
+ usage: ZERO_USAGE,
3755
+ preparedPipeline: preparedPipeline,
3756
+ })];
3757
+ case 7:
3758
+ _b = _a.next();
3759
+ return [3 /*break*/, 4];
3760
+ case 8: return [3 /*break*/, 11];
3761
+ case 9:
3762
+ e_1_1 = _g.sent();
3763
+ e_1 = { error: e_1_1 };
3764
+ return [3 /*break*/, 11];
3765
+ case 10:
3702
3766
  try {
3703
- // Note: Check that all input input parameters are defined
3704
- for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
3705
- var isInput = _a.isInput;
3706
- return isInput;
3707
- })), _b = _a.next(); !_b.done; _b = _a.next()) {
3708
- parameter = _b.value;
3709
- if (inputParameters[parameter.name] === undefined) {
3710
- return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3711
- isSuccessful: false,
3712
- errors: __spreadArray([
3713
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3714
- ], __read(errors), false).map(serializeError),
3715
- warnings: [],
3716
- executionReport: executionReport,
3717
- outputParameters: {},
3718
- usage: ZERO_USAGE,
3719
- preparedPipeline: preparedPipeline,
3720
- })];
3721
- }
3722
- }
3723
- }
3724
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3725
- finally {
3726
- try {
3727
- if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3728
- }
3729
- finally { if (e_1) throw e_1.error; }
3767
+ if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3730
3768
  }
3769
+ finally { if (e_1) throw e_1.error; }
3770
+ return [7 /*endfinally*/];
3771
+ case 11:
3731
3772
  _loop_1 = function (parameterName) {
3732
- var parameter = preparedPipeline.parameters.find(function (_a) {
3733
- var name = _a.name;
3734
- return name === parameterName;
3773
+ var parameter;
3774
+ return __generator(this, function (_h) {
3775
+ switch (_h.label) {
3776
+ case 0:
3777
+ parameter = preparedPipeline.parameters.find(function (_a) {
3778
+ var name = _a.name;
3779
+ return name === parameterName;
3780
+ });
3781
+ if (!(parameter === undefined)) return [3 /*break*/, 1];
3782
+ warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
3783
+ return [3 /*break*/, 4];
3784
+ case 1:
3785
+ if (!(parameter.isInput === false)) return [3 /*break*/, 4];
3786
+ isReturned = true;
3787
+ if (!(onProgress !== undefined)) return [3 /*break*/, 3];
3788
+ // Note: Wait a short time to prevent race conditions
3789
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3790
+ case 2:
3791
+ // Note: Wait a short time to prevent race conditions
3792
+ _h.sent();
3793
+ _h.label = 3;
3794
+ case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
3795
+ isSuccessful: false,
3796
+ errors: __spreadArray([
3797
+ new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
3798
+ ], __read(errors), false).map(serializeError),
3799
+ warnings: warnings.map(serializeError),
3800
+ executionReport: executionReport,
3801
+ outputParameters: {},
3802
+ usage: ZERO_USAGE,
3803
+ preparedPipeline: preparedPipeline,
3804
+ }) }];
3805
+ case 4: return [2 /*return*/];
3806
+ }
3735
3807
  });
3736
- if (parameter === undefined) {
3737
- warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
3738
- }
3739
- else if (parameter.isInput === false) {
3740
- return { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
3741
- isSuccessful: false,
3742
- errors: __spreadArray([
3743
- new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
3744
- ], __read(errors), false).map(serializeError),
3745
- warnings: warnings.map(serializeError),
3746
- executionReport: executionReport,
3747
- outputParameters: {},
3748
- usage: ZERO_USAGE,
3749
- preparedPipeline: preparedPipeline,
3750
- }) };
3751
- }
3752
3808
  };
3809
+ _g.label = 12;
3810
+ case 12:
3811
+ _g.trys.push([12, 17, 18, 19]);
3812
+ _c = __values(Object.keys(inputParameters)), _d = _c.next();
3813
+ _g.label = 13;
3814
+ case 13:
3815
+ if (!!_d.done) return [3 /*break*/, 16];
3816
+ parameterName = _d.value;
3817
+ return [5 /*yield**/, _loop_1(parameterName)];
3818
+ case 14:
3819
+ state_1 = _g.sent();
3820
+ if (typeof state_1 === "object")
3821
+ return [2 /*return*/, state_1.value];
3822
+ _g.label = 15;
3823
+ case 15:
3824
+ _d = _c.next();
3825
+ return [3 /*break*/, 13];
3826
+ case 16: return [3 /*break*/, 19];
3827
+ case 17:
3828
+ e_2_1 = _g.sent();
3829
+ e_2 = { error: e_2_1 };
3830
+ return [3 /*break*/, 19];
3831
+ case 18:
3753
3832
  try {
3754
- // Note: Check that no extra input parameters are passed
3755
- for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
3756
- parameterName = _d.value;
3757
- state_1 = _loop_1(parameterName);
3758
- if (typeof state_1 === "object")
3759
- return [2 /*return*/, state_1.value];
3760
- }
3761
- }
3762
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3763
- finally {
3764
- try {
3765
- if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3766
- }
3767
- finally { if (e_2) throw e_2.error; }
3833
+ if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3768
3834
  }
3835
+ finally { if (e_2) throw e_2.error; }
3836
+ return [7 /*endfinally*/];
3837
+ case 19:
3769
3838
  parametersToPass = inputParameters;
3770
- _g.label = 3;
3771
- case 3:
3772
- _g.trys.push([3, 8, , 9]);
3839
+ _g.label = 20;
3840
+ case 20:
3841
+ _g.trys.push([20, 25, , 28]);
3773
3842
  resovedParameterNames_1 = preparedPipeline.parameters
3774
3843
  .filter(function (_a) {
3775
3844
  var isInput = _a.isInput;
@@ -3784,8 +3853,8 @@
3784
3853
  loopLimit = LOOP_LIMIT;
3785
3854
  _loop_2 = function () {
3786
3855
  var currentTemplate, work_1;
3787
- return __generator(this, function (_h) {
3788
- switch (_h.label) {
3856
+ return __generator(this, function (_j) {
3857
+ switch (_j.label) {
3789
3858
  case 0:
3790
3859
  if (loopLimit-- < 0) {
3791
3860
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
@@ -3811,7 +3880,7 @@
3811
3880
  if (!!currentTemplate) return [3 /*break*/, 3];
3812
3881
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
3813
3882
  case 2:
3814
- /* [5] */ _h.sent();
3883
+ /* [5] */ _j.sent();
3815
3884
  return [3 /*break*/, 4];
3816
3885
  case 3:
3817
3886
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
@@ -3823,23 +3892,23 @@
3823
3892
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
3824
3893
  });
3825
3894
  resolving_1.push(work_1);
3826
- _h.label = 4;
3895
+ _j.label = 4;
3827
3896
  case 4: return [2 /*return*/];
3828
3897
  }
3829
3898
  });
3830
3899
  };
3831
- _g.label = 4;
3832
- case 4:
3833
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 6];
3900
+ _g.label = 21;
3901
+ case 21:
3902
+ if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
3834
3903
  return [5 /*yield**/, _loop_2()];
3835
- case 5:
3904
+ case 22:
3836
3905
  _g.sent();
3837
- return [3 /*break*/, 4];
3838
- case 6: return [4 /*yield*/, Promise.all(resolving_1)];
3839
- case 7:
3906
+ return [3 /*break*/, 21];
3907
+ case 23: return [4 /*yield*/, Promise.all(resolving_1)];
3908
+ case 24:
3840
3909
  _g.sent();
3841
- return [3 /*break*/, 9];
3842
- case 8:
3910
+ return [3 /*break*/, 28];
3911
+ case 25:
3843
3912
  error_1 = _g.sent();
3844
3913
  if (!(error_1 instanceof Error)) {
3845
3914
  throw error_1;
@@ -3849,30 +3918,46 @@
3849
3918
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
3850
3919
  })), false));
3851
3920
  outputParameters_1 = filterJustOutputParameters();
3852
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
3853
- isSuccessful: false,
3854
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
3855
- warnings: warnings.map(serializeError),
3856
- usage: usage_1,
3857
- executionReport: executionReport,
3858
- outputParameters: outputParameters_1,
3859
- preparedPipeline: preparedPipeline,
3860
- })];
3861
- case 9:
3921
+ isReturned = true;
3922
+ if (!(onProgress !== undefined)) return [3 /*break*/, 27];
3923
+ // Note: Wait a short time to prevent race conditions
3924
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3925
+ case 26:
3926
+ // Note: Wait a short time to prevent race conditions
3927
+ _g.sent();
3928
+ _g.label = 27;
3929
+ case 27: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
3930
+ isSuccessful: false,
3931
+ errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
3932
+ warnings: warnings.map(serializeError),
3933
+ usage: usage_1,
3934
+ executionReport: executionReport,
3935
+ outputParameters: outputParameters_1,
3936
+ preparedPipeline: preparedPipeline,
3937
+ })];
3938
+ case 28:
3862
3939
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
3863
3940
  var result = _a.result;
3864
3941
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
3865
3942
  })), false));
3866
3943
  outputParameters = filterJustOutputParameters();
3867
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
3868
- isSuccessful: true,
3869
- errors: errors.map(serializeError),
3870
- warnings: warnings.map(serializeError),
3871
- usage: usage,
3872
- executionReport: executionReport,
3873
- outputParameters: outputParameters,
3874
- preparedPipeline: preparedPipeline,
3875
- })];
3944
+ isReturned = true;
3945
+ if (!(onProgress !== undefined)) return [3 /*break*/, 30];
3946
+ // Note: Wait a short time to prevent race conditions
3947
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3948
+ case 29:
3949
+ // Note: Wait a short time to prevent race conditions
3950
+ _g.sent();
3951
+ _g.label = 30;
3952
+ case 30: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
3953
+ isSuccessful: true,
3954
+ errors: errors.map(serializeError),
3955
+ warnings: warnings.map(serializeError),
3956
+ usage: usage,
3957
+ executionReport: executionReport,
3958
+ outputParameters: outputParameters,
3959
+ preparedPipeline: preparedPipeline,
3960
+ })];
3876
3961
  }
3877
3962
  });
3878
3963
  }); };