@promptbook/node 0.67.8 → 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.
@@ -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.8",
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.8"
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.7';
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.7",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.7",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.7",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.7",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
@@ -3082,7 +3088,7 @@
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] */
3091
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
3086
3092
  progress_1 = {
3087
3093
  name: name,
3088
3094
  title: title,
@@ -3485,7 +3491,7 @@
3485
3491
  if (resultString === null) {
3486
3492
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
3487
3493
  }
3488
- if (!onProgress /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3494
+ if (!(onProgress !== undefined) /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
3489
3495
  progress_2 = {
3490
3496
  name: name,
3491
3497
  title: title,
@@ -3543,7 +3549,7 @@
3543
3549
  }
3544
3550
  return outputParameters;
3545
3551
  }
3546
- var errors, warnings, executionReport, isReturned, _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;
3547
3553
  var e_1, _e, e_2, _f;
3548
3554
  return __generator(this, function (_g) {
3549
3555
  switch (_g.label) {
@@ -3569,79 +3575,122 @@
3569
3575
  promptExecutions: [],
3570
3576
  };
3571
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:
3572
3618
  try {
3573
- // Note: Check that all input input parameters are defined
3574
- for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
3575
- var isInput = _a.isInput;
3576
- return isInput;
3577
- })), _b = _a.next(); !_b.done; _b = _a.next()) {
3578
- parameter = _b.value;
3579
- if (inputParameters[parameter.name] === undefined) {
3580
- isReturned = true;
3581
- return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
3582
- isSuccessful: false,
3583
- errors: __spreadArray([
3584
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3585
- ], __read(errors), false).map(serializeError),
3586
- warnings: [],
3587
- executionReport: executionReport,
3588
- outputParameters: {},
3589
- usage: ZERO_USAGE,
3590
- preparedPipeline: preparedPipeline,
3591
- })];
3592
- }
3593
- }
3594
- }
3595
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3596
- finally {
3597
- try {
3598
- if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3599
- }
3600
- finally { if (e_1) throw e_1.error; }
3619
+ if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
3601
3620
  }
3621
+ finally { if (e_1) throw e_1.error; }
3622
+ return [7 /*endfinally*/];
3623
+ case 11:
3602
3624
  _loop_1 = function (parameterName) {
3603
- var parameter = preparedPipeline.parameters.find(function (_a) {
3604
- var name = _a.name;
3605
- 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
+ }
3606
3659
  });
3607
- if (parameter === undefined) {
3608
- 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 "); })));
3609
- }
3610
- else if (parameter.isInput === false) {
3611
- isReturned = true;
3612
- return { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
3613
- isSuccessful: false,
3614
- errors: __spreadArray([
3615
- 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 "); }))
3616
- ], __read(errors), false).map(serializeError),
3617
- warnings: warnings.map(serializeError),
3618
- executionReport: executionReport,
3619
- outputParameters: {},
3620
- usage: ZERO_USAGE,
3621
- preparedPipeline: preparedPipeline,
3622
- }) };
3623
- }
3624
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:
3625
3684
  try {
3626
- // Note: Check that no extra input parameters are passed
3627
- for (_c = __values(Object.keys(inputParameters)), _d = _c.next(); !_d.done; _d = _c.next()) {
3628
- parameterName = _d.value;
3629
- state_1 = _loop_1(parameterName);
3630
- if (typeof state_1 === "object")
3631
- return [2 /*return*/, state_1.value];
3632
- }
3633
- }
3634
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3635
- finally {
3636
- try {
3637
- if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3638
- }
3639
- finally { if (e_2) throw e_2.error; }
3685
+ if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
3640
3686
  }
3687
+ finally { if (e_2) throw e_2.error; }
3688
+ return [7 /*endfinally*/];
3689
+ case 19:
3641
3690
  parametersToPass = inputParameters;
3642
- _g.label = 3;
3643
- case 3:
3644
- _g.trys.push([3, 8, , 9]);
3691
+ _g.label = 20;
3692
+ case 20:
3693
+ _g.trys.push([20, 25, , 28]);
3645
3694
  resovedParameterNames_1 = preparedPipeline.parameters
3646
3695
  .filter(function (_a) {
3647
3696
  var isInput = _a.isInput;
@@ -3656,8 +3705,8 @@
3656
3705
  loopLimit = LOOP_LIMIT;
3657
3706
  _loop_2 = function () {
3658
3707
  var currentTemplate, work_1;
3659
- return __generator(this, function (_h) {
3660
- switch (_h.label) {
3708
+ return __generator(this, function (_j) {
3709
+ switch (_j.label) {
3661
3710
  case 0:
3662
3711
  if (loopLimit-- < 0) {
3663
3712
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
@@ -3683,7 +3732,7 @@
3683
3732
  if (!!currentTemplate) return [3 /*break*/, 3];
3684
3733
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
3685
3734
  case 2:
3686
- /* [5] */ _h.sent();
3735
+ /* [5] */ _j.sent();
3687
3736
  return [3 /*break*/, 4];
3688
3737
  case 3:
3689
3738
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
@@ -3695,23 +3744,23 @@
3695
3744
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
3696
3745
  });
3697
3746
  resolving_1.push(work_1);
3698
- _h.label = 4;
3747
+ _j.label = 4;
3699
3748
  case 4: return [2 /*return*/];
3700
3749
  }
3701
3750
  });
3702
3751
  };
3703
- _g.label = 4;
3704
- case 4:
3705
- 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];
3706
3755
  return [5 /*yield**/, _loop_2()];
3707
- case 5:
3756
+ case 22:
3708
3757
  _g.sent();
3709
- return [3 /*break*/, 4];
3710
- case 6: return [4 /*yield*/, Promise.all(resolving_1)];
3711
- case 7:
3758
+ return [3 /*break*/, 21];
3759
+ case 23: return [4 /*yield*/, Promise.all(resolving_1)];
3760
+ case 24:
3712
3761
  _g.sent();
3713
- return [3 /*break*/, 9];
3714
- case 8:
3762
+ return [3 /*break*/, 28];
3763
+ case 25:
3715
3764
  error_1 = _g.sent();
3716
3765
  if (!(error_1 instanceof Error)) {
3717
3766
  throw error_1;
@@ -3722,31 +3771,45 @@
3722
3771
  })), false));
3723
3772
  outputParameters_1 = filterJustOutputParameters();
3724
3773
  isReturned = true;
3725
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
3726
- isSuccessful: false,
3727
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
3728
- warnings: warnings.map(serializeError),
3729
- usage: usage_1,
3730
- executionReport: executionReport,
3731
- outputParameters: outputParameters_1,
3732
- preparedPipeline: preparedPipeline,
3733
- })];
3734
- case 9:
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:
3735
3791
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
3736
3792
  var result = _a.result;
3737
3793
  return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
3738
3794
  })), false));
3739
3795
  outputParameters = filterJustOutputParameters();
3740
3796
  isReturned = true;
3741
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
3742
- isSuccessful: true,
3743
- errors: errors.map(serializeError),
3744
- warnings: warnings.map(serializeError),
3745
- usage: usage,
3746
- executionReport: executionReport,
3747
- outputParameters: outputParameters,
3748
- preparedPipeline: preparedPipeline,
3749
- })];
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
+ })];
3750
3813
  }
3751
3814
  });
3752
3815
  }); };