@promptbook/node 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/node",
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,
@@ -47,11 +47,12 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.67.7"
50
+ "@promptbook/core": "0.67.9"
51
51
  },
52
52
  "dependencies": {
53
53
  "colors": "1.4.0",
54
54
  "prettier": "2.8.1",
55
- "spacetrim": "0.11.39"
55
+ "spacetrim": "0.11.39",
56
+ "waitasecond": "1.11.83"
56
57
  }
57
58
  }
package/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('fs/promises'), require('path'), require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path/posix'), require('dotenv')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'colors', 'fs/promises', 'path', 'spacetrim', 'prettier', 'prettier/parser-html', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path/posix', 'dotenv'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.colors, global.promises, global.path, global.spaceTrim, global.prettier, global.parserHtml, global.hexEncoder, global.sha256, global.posix, global.dotenv));
5
- })(this, (function (exports, colors, promises, path, spaceTrim, prettier, parserHtml, hexEncoder, sha256, posix, dotenv) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('fs/promises'), require('path'), require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path/posix'), require('dotenv')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'colors', 'fs/promises', 'path', 'spacetrim', 'prettier', 'prettier/parser-html', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path/posix', 'dotenv'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.colors, global.promises, global.path, global.spaceTrim, global.prettier, global.parserHtml, global.waitasecond, global.hexEncoder, global.sha256, global.posix, global.dotenv));
5
+ })(this, (function (exports, colors, promises, path, spaceTrim, prettier, parserHtml, waitasecond, hexEncoder, sha256, posix, dotenv) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -35,7 +35,7 @@
35
35
  /**
36
36
  * The version of the Promptbook library
37
37
  */
38
- var PROMPTBOOK_VERSION = '0.67.6';
38
+ var PROMPTBOOK_VERSION = '0.67.8';
39
39
  // TODO: !!!! List here all the versions and annotate + put into script
40
40
 
41
41
  /*! *****************************************************************************
@@ -377,6 +377,12 @@
377
377
  * @private within the repository - too low-level in comparison with other `MAX_...`
378
378
  */
379
379
  var LOOP_LIMIT = 1000;
380
+ /**
381
+ * Short time interval to prevent race conditions in milliseconds
382
+ *
383
+ * @private within the repository - too low-level in comparison with other `MAX_...`
384
+ */
385
+ var IMMEDIATE_TIME = 10;
380
386
  /**
381
387
  * The maximum number of (LLM) tasks running in parallel
382
388
  *
@@ -889,7 +895,7 @@
889
895
  });
890
896
  }
891
897
 
892
- 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"}];
898
+ 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"}];
893
899
 
894
900
  /**
895
901
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -3074,7 +3080,7 @@
3074
3080
  }
3075
3081
  function executeSingleTemplate(currentTemplate) {
3076
3082
  return __awaiter(this, void 0, void 0, function () {
3077
- 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;
3083
+ 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;
3078
3084
  var e_4, _f, _g;
3079
3085
  return __generator(this, function (_h) {
3080
3086
  switch (_h.label) {
@@ -3082,17 +3088,24 @@
3082
3088
  name = "pipeline-executor-frame-".concat(currentTemplate.name);
3083
3089
  title = currentTemplate.title;
3084
3090
  priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
3085
- if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3086
- return [4 /*yield*/, onProgress({
3087
- name: name,
3088
- title: title,
3089
- isStarted: false,
3090
- isDone: false,
3091
- blockType: currentTemplate.blockType,
3092
- parameterName: currentTemplate.resultingParameterName,
3093
- parameterValue: null,
3094
- // <- [3]
3095
- })];
3091
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3092
+ progress_1 = {
3093
+ name: name,
3094
+ title: title,
3095
+ isStarted: false,
3096
+ isDone: false,
3097
+ blockType: currentTemplate.blockType,
3098
+ parameterName: currentTemplate.resultingParameterName,
3099
+ parameterValue: null,
3100
+ // <- [3]
3101
+ };
3102
+ if (isReturned) {
3103
+ 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)
3104
+ .split('\n')
3105
+ .map(function (line) { return "> ".concat(line); })
3106
+ .join('\n')), "\n "); }));
3107
+ }
3108
+ return [4 /*yield*/, onProgress(progress_1)];
3096
3109
  case 1:
3097
3110
  _h.sent();
3098
3111
  _h.label = 2;
@@ -3478,18 +3491,28 @@
3478
3491
  if (resultString === null) {
3479
3492
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3480
3493
  }
3481
- if (onProgress /* <- [3] */) {
3482
- onProgress({
3483
- name: name,
3484
- title: title,
3485
- isStarted: true,
3486
- isDone: true,
3487
- blockType: currentTemplate.blockType,
3488
- parameterName: currentTemplate.resultingParameterName,
3489
- parameterValue: resultString,
3490
- // <- [3]
3491
- });
3494
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3495
+ progress_2 = {
3496
+ name: name,
3497
+ title: title,
3498
+ isStarted: true,
3499
+ isDone: true,
3500
+ blockType: currentTemplate.blockType,
3501
+ parameterName: currentTemplate.resultingParameterName,
3502
+ parameterValue: resultString,
3503
+ // <- [3]
3504
+ };
3505
+ if (isReturned) {
3506
+ 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)
3507
+ .split('\n')
3508
+ .map(function (line) { return "> ".concat(line); })
3509
+ .join('\n')), "\n\n "); }));
3492
3510
  }
3511
+ return [4 /*yield*/, onProgress(progress_2)];
3512
+ case 8:
3513
+ _h.sent();
3514
+ _h.label = 9;
3515
+ case 9:
3493
3516
  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)));
3494
3517
  return [2 /*return*/];
3495
3518
  }
@@ -3526,7 +3549,7 @@
3526
3549
  }
3527
3550
  return outputParameters;
3528
3551
  }
3529
- 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;
3552
+ 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;
3530
3553
  var e_1, _e, e_2, _f;
3531
3554
  return __generator(this, function (_g) {
3532
3555
  switch (_g.label) {
@@ -3551,77 +3574,123 @@
3551
3574
  description: preparedPipeline.description,
3552
3575
  promptExecutions: [],
3553
3576
  };
3577
+ isReturned = false;
3578
+ _g.label = 3;
3579
+ case 3:
3580
+ _g.trys.push([3, 9, 10, 11]);
3581
+ _a = __values(preparedPipeline.parameters.filter(function (_a) {
3582
+ var isInput = _a.isInput;
3583
+ return isInput;
3584
+ })), _b = _a.next();
3585
+ _g.label = 4;
3586
+ case 4:
3587
+ if (!!_b.done) return [3 /*break*/, 8];
3588
+ parameter = _b.value;
3589
+ if (!(inputParameters[parameter.name] === undefined)) return [3 /*break*/, 7];
3590
+ isReturned = true;
3591
+ if (!(onProgress !== undefined)) return [3 /*break*/, 6];
3592
+ // Note: Wait a short time to prevent race conditions
3593
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3594
+ case 5:
3595
+ // Note: Wait a short time to prevent race conditions
3596
+ _g.sent();
3597
+ _g.label = 6;
3598
+ case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3599
+ isSuccessful: false,
3600
+ errors: __spreadArray([
3601
+ new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3602
+ ], __read(errors), false).map(serializeError),
3603
+ warnings: [],
3604
+ executionReport: executionReport,
3605
+ outputParameters: {},
3606
+ usage: ZERO_USAGE,
3607
+ preparedPipeline: preparedPipeline,
3608
+ })];
3609
+ case 7:
3610
+ _b = _a.next();
3611
+ return [3 /*break*/, 4];
3612
+ case 8: return [3 /*break*/, 11];
3613
+ case 9:
3614
+ e_1_1 = _g.sent();
3615
+ e_1 = { error: e_1_1 };
3616
+ return [3 /*break*/, 11];
3617
+ case 10:
3554
3618
  try {
3555
- // Note: Check that all input input parameters are defined
3556
- for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
3557
- var isInput = _a.isInput;
3558
- return isInput;
3559
- })), _b = _a.next(); !_b.done; _b = _a.next()) {
3560
- parameter = _b.value;
3561
- if (inputParameters[parameter.name] === undefined) {
3562
- return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3563
- isSuccessful: false,
3564
- errors: __spreadArray([
3565
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3566
- ], __read(errors), false).map(serializeError),
3567
- warnings: [],
3568
- executionReport: executionReport,
3569
- outputParameters: {},
3570
- usage: ZERO_USAGE,
3571
- preparedPipeline: preparedPipeline,
3572
- })];
3573
- }
3574
- }
3575
- }
3576
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3577
- finally {
3578
- try {
3579
- if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3580
- }
3581
- finally { if (e_1) throw e_1.error; }
3619
+ if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3582
3620
  }
3621
+ finally { if (e_1) throw e_1.error; }
3622
+ return [7 /*endfinally*/];
3623
+ case 11:
3583
3624
  _loop_1 = function (parameterName) {
3584
- var parameter = preparedPipeline.parameters.find(function (_a) {
3585
- var name = _a.name;
3586
- return name === parameterName;
3625
+ var parameter;
3626
+ return __generator(this, function (_h) {
3627
+ switch (_h.label) {
3628
+ case 0:
3629
+ parameter = preparedPipeline.parameters.find(function (_a) {
3630
+ var name = _a.name;
3631
+ return name === parameterName;
3632
+ });
3633
+ if (!(parameter === undefined)) return [3 /*break*/, 1];
3634
+ 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 "); })));
3635
+ return [3 /*break*/, 4];
3636
+ case 1:
3637
+ if (!(parameter.isInput === false)) return [3 /*break*/, 4];
3638
+ isReturned = true;
3639
+ if (!(onProgress !== undefined)) return [3 /*break*/, 3];
3640
+ // Note: Wait a short time to prevent race conditions
3641
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3642
+ case 2:
3643
+ // Note: Wait a short time to prevent race conditions
3644
+ _h.sent();
3645
+ _h.label = 3;
3646
+ 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 "); }), {
3647
+ isSuccessful: false,
3648
+ errors: __spreadArray([
3649
+ 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 "); }))
3650
+ ], __read(errors), false).map(serializeError),
3651
+ warnings: warnings.map(serializeError),
3652
+ executionReport: executionReport,
3653
+ outputParameters: {},
3654
+ usage: ZERO_USAGE,
3655
+ preparedPipeline: preparedPipeline,
3656
+ }) }];
3657
+ case 4: return [2 /*return*/];
3658
+ }
3587
3659
  });
3588
- if (parameter === undefined) {
3589
- 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 "); })));
3590
- }
3591
- else if (parameter.isInput === false) {
3592
- return { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
3593
- isSuccessful: false,
3594
- errors: __spreadArray([
3595
- 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 "); }))
3596
- ], __read(errors), false).map(serializeError),
3597
- warnings: warnings.map(serializeError),
3598
- executionReport: executionReport,
3599
- outputParameters: {},
3600
- usage: ZERO_USAGE,
3601
- preparedPipeline: preparedPipeline,
3602
- }) };
3603
- }
3604
3660
  };
3661
+ _g.label = 12;
3662
+ case 12:
3663
+ _g.trys.push([12, 17, 18, 19]);
3664
+ _c = __values(Object.keys(inputParameters)), _d = _c.next();
3665
+ _g.label = 13;
3666
+ case 13:
3667
+ if (!!_d.done) return [3 /*break*/, 16];
3668
+ parameterName = _d.value;
3669
+ return [5 /*yield**/, _loop_1(parameterName)];
3670
+ case 14:
3671
+ state_1 = _g.sent();
3672
+ if (typeof state_1 === "object")
3673
+ return [2 /*return*/, state_1.value];
3674
+ _g.label = 15;
3675
+ case 15:
3676
+ _d = _c.next();
3677
+ return [3 /*break*/, 13];
3678
+ case 16: return [3 /*break*/, 19];
3679
+ case 17:
3680
+ e_2_1 = _g.sent();
3681
+ e_2 = { error: e_2_1 };
3682
+ return [3 /*break*/, 19];
3683
+ case 18:
3605
3684
  try {
3606
- // Note: Check that no extra input parameters are passed
3607
- for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
3608
- parameterName = _d.value;
3609
- state_1 = _loop_1(parameterName);
3610
- if (typeof state_1 === "object")
3611
- return [2 /*return*/, state_1.value];
3612
- }
3613
- }
3614
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3615
- finally {
3616
- try {
3617
- if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3618
- }
3619
- finally { if (e_2) throw e_2.error; }
3685
+ if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3620
3686
  }
3687
+ finally { if (e_2) throw e_2.error; }
3688
+ return [7 /*endfinally*/];
3689
+ case 19:
3621
3690
  parametersToPass = inputParameters;
3622
- _g.label = 3;
3623
- case 3:
3624
- _g.trys.push([3, 8, , 9]);
3691
+ _g.label = 20;
3692
+ case 20:
3693
+ _g.trys.push([20, 25, , 28]);
3625
3694
  resovedParameterNames_1 = preparedPipeline.parameters
3626
3695
  .filter(function (_a) {
3627
3696
  var isInput = _a.isInput;
@@ -3636,8 +3705,8 @@
3636
3705
  loopLimit = LOOP_LIMIT;
3637
3706
  _loop_2 = function () {
3638
3707
  var currentTemplate, work_1;
3639
- return __generator(this, function (_h) {
3640
- switch (_h.label) {
3708
+ return __generator(this, function (_j) {
3709
+ switch (_j.label) {
3641
3710
  case 0:
3642
3711
  if (loopLimit-- < 0) {
3643
3712
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
@@ -3663,7 +3732,7 @@
3663
3732
  if (!!currentTemplate) return [3 /*break*/, 3];
3664
3733
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
3665
3734
  case 2:
3666
- /* [5] */ _h.sent();
3735
+ /* [5] */ _j.sent();
3667
3736
  return [3 /*break*/, 4];
3668
3737
  case 3:
3669
3738
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
@@ -3675,23 +3744,23 @@
3675
3744
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
3676
3745
  });
3677
3746
  resolving_1.push(work_1);
3678
- _h.label = 4;
3747
+ _j.label = 4;
3679
3748
  case 4: return [2 /*return*/];
3680
3749
  }
3681
3750
  });
3682
3751
  };
3683
- _g.label = 4;
3684
- case 4:
3685
- if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 6];
3752
+ _g.label = 21;
3753
+ case 21:
3754
+ if (!(unresovedTemplates_1.length > 0)) return [3 /*break*/, 23];
3686
3755
  return [5 /*yield**/, _loop_2()];
3687
- case 5:
3756
+ case 22:
3688
3757
  _g.sent();
3689
- return [3 /*break*/, 4];
3690
- case 6: return [4 /*yield*/, Promise.all(resolving_1)];
3691
- case 7:
3758
+ return [3 /*break*/, 21];
3759
+ case 23: return [4 /*yield*/, Promise.all(resolving_1)];
3760
+ case 24:
3692
3761
  _g.sent();
3693
- return [3 /*break*/, 9];
3694
- case 8:
3762
+ return [3 /*break*/, 28];
3763
+ case 25:
3695
3764
  error_1 = _g.sent();
3696
3765
  if (!(error_1 instanceof Error)) {
3697
3766
  throw error_1;
@@ -3701,30 +3770,46 @@
3701
3770
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
3702
3771
  })), false));
3703
3772
  outputParameters_1 = filterJustOutputParameters();
3704
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
3705
- isSuccessful: false,
3706
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
3707
- warnings: warnings.map(serializeError),
3708
- usage: usage_1,
3709
- executionReport: executionReport,
3710
- outputParameters: outputParameters_1,
3711
- preparedPipeline: preparedPipeline,
3712
- })];
3713
- case 9:
3773
+ isReturned = true;
3774
+ if (!(onProgress !== undefined)) return [3 /*break*/, 27];
3775
+ // Note: Wait a short time to prevent race conditions
3776
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3777
+ case 26:
3778
+ // Note: Wait a short time to prevent race conditions
3779
+ _g.sent();
3780
+ _g.label = 27;
3781
+ case 27: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
3782
+ isSuccessful: false,
3783
+ errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
3784
+ warnings: warnings.map(serializeError),
3785
+ usage: usage_1,
3786
+ executionReport: executionReport,
3787
+ outputParameters: outputParameters_1,
3788
+ preparedPipeline: preparedPipeline,
3789
+ })];
3790
+ case 28:
3714
3791
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
3715
3792
  var result = _a.result;
3716
3793
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
3717
3794
  })), false));
3718
3795
  outputParameters = filterJustOutputParameters();
3719
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
3720
- isSuccessful: true,
3721
- errors: errors.map(serializeError),
3722
- warnings: warnings.map(serializeError),
3723
- usage: usage,
3724
- executionReport: executionReport,
3725
- outputParameters: outputParameters,
3726
- preparedPipeline: preparedPipeline,
3727
- })];
3796
+ isReturned = true;
3797
+ if (!(onProgress !== undefined)) return [3 /*break*/, 30];
3798
+ // Note: Wait a short time to prevent race conditions
3799
+ return [4 /*yield*/, waitasecond.forTime(IMMEDIATE_TIME)];
3800
+ case 29:
3801
+ // Note: Wait a short time to prevent race conditions
3802
+ _g.sent();
3803
+ _g.label = 30;
3804
+ case 30: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
3805
+ isSuccessful: true,
3806
+ errors: errors.map(serializeError),
3807
+ warnings: warnings.map(serializeError),
3808
+ usage: usage,
3809
+ executionReport: executionReport,
3810
+ outputParameters: outputParameters,
3811
+ preparedPipeline: preparedPipeline,
3812
+ })];
3728
3813
  }
3729
3814
  });
3730
3815
  }); };