@promptbook/legacy-documents 0.84.0 โ†’ 0.85.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +213 -160
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +0 -2
  5. package/esm/typings/src/_packages/types.index.d.ts +14 -2
  6. package/esm/typings/src/_packages/utils.index.d.ts +0 -2
  7. package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +13 -0
  8. package/esm/typings/src/cli/cli-commands/start-server.d.ts +13 -0
  9. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
  10. package/esm/typings/src/execution/AbstractTaskResult.d.ts +25 -0
  11. package/esm/typings/src/execution/ExecutionTask.d.ts +71 -0
  12. package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -5
  13. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -15
  14. package/esm/typings/src/execution/PromptbookFetch.d.ts +8 -1
  15. package/esm/typings/src/execution/{assertsExecutionSuccessful.d.ts โ†’ assertsTaskSuccessful.d.ts} +2 -3
  16. package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +0 -3
  17. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -6
  18. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +3 -6
  19. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
  20. package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -0
  21. package/esm/typings/src/types/typeAliases.d.ts +2 -0
  22. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +2 -2
  23. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +2 -2
  24. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +2 -2
  25. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
  26. package/esm/typings/src/utils/random/$randomSeed.d.ts +2 -1
  27. package/esm/typings/src/utils/random/$randomToken.d.ts +13 -0
  28. package/esm/typings/src/wizzard/wizzard.d.ts +2 -3
  29. package/package.json +4 -2
  30. package/umd/index.umd.js +215 -164
  31. package/umd/index.umd.js.map +1 -1
  32. package/esm/typings/src/remote-server/socket-types/_common/PromptbookServer_Progress.d.ts +0 -10
  33. package/esm/typings/src/types/TaskProgress.d.ts +0 -43
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('fs/promises'), require('path'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('prettier'), require('prettier/parser-html'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'path', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'prettier', 'prettier/parser-html', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-legacy-documents"] = {}, global.promises, global.path, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.prettier, global.parserHtml, global.sha256, global.mimeTypes, global.papaparse));
5
- })(this, (function (exports, promises, path, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder, prettier, parserHtml, sha256, mimeTypes, papaparse) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('path'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('prettier'), require('prettier/parser-html'), require('rxjs'), require('crypto'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'path', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-legacy-documents"] = {}, global.promises, global.path, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.sha256, global.mimeTypes, global.papaparse));
5
+ })(this, (function (exports, promises, path, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder, prettier, parserHtml, rxjs, crypto, sha256, mimeTypes, papaparse) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -26,7 +26,7 @@
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-21';
29
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -407,7 +407,7 @@
407
407
  */
408
408
  var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
409
409
  /**
410
- * TODO: [โ˜‘]
410
+ * TODO: [๐ŸŽบ]
411
411
  */
412
412
 
413
413
  /**
@@ -2402,6 +2402,58 @@
2402
2402
  return PipelineExecutionError;
2403
2403
  }(Error));
2404
2404
 
2405
+ /**
2406
+ * Determine if the pipeline is fully prepared
2407
+ *
2408
+ * @see https://github.com/webgptorg/promptbook/discussions/196
2409
+ *
2410
+ * @public exported from `@promptbook/core`
2411
+ */
2412
+ function isPipelinePrepared(pipeline) {
2413
+ // Note: Ignoring `pipeline.preparations` @@@
2414
+ // Note: Ignoring `pipeline.knowledgePieces` @@@
2415
+ if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
2416
+ return false;
2417
+ }
2418
+ if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
2419
+ return false;
2420
+ }
2421
+ if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
2422
+ return false;
2423
+ }
2424
+ /*
2425
+ TODO: [๐Ÿง ][๐Ÿซ] `tasks` can not be determined if they are fully prepared SO ignoring them
2426
+ > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
2427
+ > return false;
2428
+ > }
2429
+ */
2430
+ return true;
2431
+ }
2432
+ /**
2433
+ * TODO: [๐Ÿ”ƒ][main] If the pipeline was prepared with different version or different set of models, prepare it once again
2434
+ * TODO: [๐Ÿ ] Maybe base this on `makeValidator`
2435
+ * TODO: [๐ŸงŠ] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2436
+ * TODO: [๐Ÿงฟ] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2437
+ * - [๐Ÿ] ? Is context in each task
2438
+ * - [โ™จ] Are examples prepared
2439
+ * - [โ™จ] Are tasks prepared
2440
+ */
2441
+
2442
+ /**
2443
+ * Generates random token
2444
+ *
2445
+ * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
2446
+ *
2447
+ * @private internal helper function
2448
+ * @returns secure random token
2449
+ */
2450
+ function $randomToken(randomness) {
2451
+ return crypto.randomBytes(randomness).toString('hex');
2452
+ }
2453
+ /**
2454
+ * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
2455
+ */
2456
+
2405
2457
  /**
2406
2458
  * This error indicates problems parsing the format value
2407
2459
  *
@@ -2587,9 +2639,9 @@
2587
2639
  *
2588
2640
  * @param executionResult - The partial result of the Promptbook execution
2589
2641
  * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
2590
- * @public exported from `@promptbook/core`
2642
+ * @private internal helper function of `asPromise` method of `ExecutionTask`
2591
2643
  */
2592
- function assertsExecutionSuccessful(executionResult) {
2644
+ function assertsTaskSuccessful(executionResult) {
2593
2645
  var e_1, _a;
2594
2646
  var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
2595
2647
  try {
@@ -2624,121 +2676,54 @@
2624
2676
  }
2625
2677
  }
2626
2678
  /**
2627
- * TODO: [๐Ÿš] This function should be removed OR changed OR be completely rewritten
2628
2679
  * TODO: [๐Ÿง ] Can this return type be better typed than void
2629
2680
  */
2630
2681
 
2631
2682
  /**
2632
- * Determine if the pipeline is fully prepared
2633
- *
2634
- * @see https://github.com/webgptorg/promptbook/discussions/196
2635
- *
2636
- * @public exported from `@promptbook/core`
2637
- */
2638
- function isPipelinePrepared(pipeline) {
2639
- // Note: Ignoring `pipeline.preparations` @@@
2640
- // Note: Ignoring `pipeline.knowledgePieces` @@@
2641
- if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
2642
- return false;
2643
- }
2644
- if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
2645
- return false;
2646
- }
2647
- if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
2648
- return false;
2649
- }
2650
- /*
2651
- TODO: [๐Ÿง ][๐Ÿซ] `tasks` can not be determined if they are fully prepared SO ignoring them
2652
- > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
2653
- > return false;
2654
- > }
2655
- */
2656
- return true;
2657
- }
2658
- /**
2659
- * TODO: [๐Ÿ”ƒ][main] If the pipeline was prepared with different version or different set of models, prepare it once again
2660
- * TODO: [๐Ÿ ] Maybe base this on `makeValidator`
2661
- * TODO: [๐ŸงŠ] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2662
- * TODO: [๐Ÿงฟ] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2663
- * - [๐Ÿ] ? Is context in each task
2664
- * - [โ™จ] Are examples prepared
2665
- * - [โ™จ] Are tasks prepared
2666
- */
2667
-
2668
- /**
2669
- * Format either small or big number
2683
+ * Helper to create a new task
2670
2684
  *
2671
- * @public exported from `@promptbook/utils`
2685
+ * @private internal helper function
2672
2686
  */
2673
- function numberToString(value) {
2674
- if (value === 0) {
2675
- return '0';
2676
- }
2677
- else if (Number.isNaN(value)) {
2678
- return VALUE_STRINGS.nan;
2679
- }
2680
- else if (value === Infinity) {
2681
- return VALUE_STRINGS.infinity;
2682
- }
2683
- else if (value === -Infinity) {
2684
- return VALUE_STRINGS.negativeInfinity;
2685
- }
2686
- for (var exponent = 0; exponent < 15; exponent++) {
2687
- var factor = Math.pow(10, exponent);
2688
- var valueRounded = Math.round(value * factor) / factor;
2689
- if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
2690
- return valueRounded.toFixed(exponent);
2691
- }
2687
+ function createTask(options) {
2688
+ var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
2689
+ var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
2690
+ var resultSubject = new rxjs.BehaviorSubject({});
2691
+ var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
2692
+ resultSubject.next(newOngoingResult);
2693
+ });
2694
+ function asPromise(options) {
2695
+ return __awaiter(this, void 0, void 0, function () {
2696
+ var _a, isCrashedOnError, finalResult;
2697
+ return __generator(this, function (_b) {
2698
+ switch (_b.label) {
2699
+ case 0:
2700
+ _a = (options || {}).isCrashedOnError, isCrashedOnError = _a === void 0 ? true : _a;
2701
+ return [4 /*yield*/, finalResultPromise];
2702
+ case 1:
2703
+ finalResult = _b.sent();
2704
+ if (isCrashedOnError) {
2705
+ assertsTaskSuccessful(finalResult);
2706
+ }
2707
+ return [2 /*return*/, finalResult];
2708
+ }
2709
+ });
2710
+ });
2692
2711
  }
2693
- return value.toString();
2712
+ return {
2713
+ taskType: taskType,
2714
+ taskId: taskId,
2715
+ asPromise: asPromise,
2716
+ asObservable: function () {
2717
+ return rxjs.concat(resultSubject.asObservable(), rxjs.from(asPromise({
2718
+ isCrashedOnError: true,
2719
+ })));
2720
+ },
2721
+ };
2694
2722
  }
2695
-
2696
2723
  /**
2697
- * Function `valueToString` will convert the given value to string
2698
- * This is useful and used in the `templateParameters` function
2699
- *
2700
- * Note: This function is not just calling `toString` method
2701
- * It's more complex and can handle this conversion specifically for LLM models
2702
- * See `VALUE_STRINGS`
2703
- *
2704
- * Note: There are 2 similar functions
2705
- * - `valueToString` converts value to string for LLM models as human-readable string
2706
- * - `asSerializable` converts value to string to preserve full information to be able to convert it back
2707
- *
2708
- * @public exported from `@promptbook/utils`
2724
+ * TODO: Maybe allow to terminate the task and add getter `isFinished` or `status`
2725
+ * TODO: [๐Ÿš] Split into more files and make `PrepareTask` & `RemoteTask` + split the function
2709
2726
  */
2710
- function valueToString(value) {
2711
- try {
2712
- if (value === '') {
2713
- return VALUE_STRINGS.empty;
2714
- }
2715
- else if (value === null) {
2716
- return VALUE_STRINGS.null;
2717
- }
2718
- else if (value === undefined) {
2719
- return VALUE_STRINGS.undefined;
2720
- }
2721
- else if (typeof value === 'string') {
2722
- return value;
2723
- }
2724
- else if (typeof value === 'number') {
2725
- return numberToString(value);
2726
- }
2727
- else if (value instanceof Date) {
2728
- return value.toISOString();
2729
- }
2730
- else {
2731
- return JSON.stringify(value);
2732
- }
2733
- }
2734
- catch (error) {
2735
- if (!(error instanceof Error)) {
2736
- throw error;
2737
- }
2738
- console.error(error);
2739
- return VALUE_STRINGS.unserializable;
2740
- }
2741
- }
2742
2727
 
2743
2728
  /**
2744
2729
  * Serializes an error into a [๐Ÿš‰] JSON-serializable object
@@ -3402,10 +3387,9 @@
3402
3387
  return modelName;
3403
3388
  })
3404
3389
  .join(',');
3405
- return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription })];
3390
+ return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription }).asPromise()];
3406
3391
  case 3:
3407
3392
  result = _d.sent();
3408
- assertsExecutionSuccessful(result);
3409
3393
  outputParameters = result.outputParameters;
3410
3394
  modelRequirementsRaw = outputParameters.modelRequirements;
3411
3395
  modelRequirements = JSON.parse(modelRequirementsRaw);
@@ -4193,10 +4177,9 @@
4193
4177
  var content = _a.content;
4194
4178
  return content;
4195
4179
  }).join('\n\n'),
4196
- })];
4180
+ }).asPromise()];
4197
4181
  case 2:
4198
4182
  result = _e.sent();
4199
- assertsExecutionSuccessful(result);
4200
4183
  outputParameters = result.outputParameters;
4201
4184
  titleRaw = outputParameters.title;
4202
4185
  if (isVerbose) {
@@ -4268,6 +4251,81 @@
4268
4251
  * @see https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#specify-the-desired-output-format
4269
4252
  */
4270
4253
 
4254
+ /**
4255
+ * Format either small or big number
4256
+ *
4257
+ * @public exported from `@promptbook/utils`
4258
+ */
4259
+ function numberToString(value) {
4260
+ if (value === 0) {
4261
+ return '0';
4262
+ }
4263
+ else if (Number.isNaN(value)) {
4264
+ return VALUE_STRINGS.nan;
4265
+ }
4266
+ else if (value === Infinity) {
4267
+ return VALUE_STRINGS.infinity;
4268
+ }
4269
+ else if (value === -Infinity) {
4270
+ return VALUE_STRINGS.negativeInfinity;
4271
+ }
4272
+ for (var exponent = 0; exponent < 15; exponent++) {
4273
+ var factor = Math.pow(10, exponent);
4274
+ var valueRounded = Math.round(value * factor) / factor;
4275
+ if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
4276
+ return valueRounded.toFixed(exponent);
4277
+ }
4278
+ }
4279
+ return value.toString();
4280
+ }
4281
+
4282
+ /**
4283
+ * Function `valueToString` will convert the given value to string
4284
+ * This is useful and used in the `templateParameters` function
4285
+ *
4286
+ * Note: This function is not just calling `toString` method
4287
+ * It's more complex and can handle this conversion specifically for LLM models
4288
+ * See `VALUE_STRINGS`
4289
+ *
4290
+ * Note: There are 2 similar functions
4291
+ * - `valueToString` converts value to string for LLM models as human-readable string
4292
+ * - `asSerializable` converts value to string to preserve full information to be able to convert it back
4293
+ *
4294
+ * @public exported from `@promptbook/utils`
4295
+ */
4296
+ function valueToString(value) {
4297
+ try {
4298
+ if (value === '') {
4299
+ return VALUE_STRINGS.empty;
4300
+ }
4301
+ else if (value === null) {
4302
+ return VALUE_STRINGS.null;
4303
+ }
4304
+ else if (value === undefined) {
4305
+ return VALUE_STRINGS.undefined;
4306
+ }
4307
+ else if (typeof value === 'string') {
4308
+ return value;
4309
+ }
4310
+ else if (typeof value === 'number') {
4311
+ return numberToString(value);
4312
+ }
4313
+ else if (value instanceof Date) {
4314
+ return value.toISOString();
4315
+ }
4316
+ else {
4317
+ return JSON.stringify(value);
4318
+ }
4319
+ }
4320
+ catch (error) {
4321
+ if (!(error instanceof Error)) {
4322
+ throw error;
4323
+ }
4324
+ console.error(error);
4325
+ return VALUE_STRINGS.unserializable;
4326
+ }
4327
+ }
4328
+
4271
4329
  /**
4272
4330
  * Parses the given script and returns the list of all used variables that are not defined in the script
4273
4331
  *
@@ -5712,27 +5770,20 @@
5712
5770
  */
5713
5771
  function executeTask(options) {
5714
5772
  return __awaiter(this, void 0, void 0, function () {
5715
- var currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_1, _d, _e, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
5716
- var e_1, _f, _g;
5717
- return __generator(this, function (_h) {
5718
- switch (_h.label) {
5773
+ var currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_1, _d, _e, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
5774
+ var _f, e_1, _g, _h, _j;
5775
+ return __generator(this, function (_k) {
5776
+ switch (_k.label) {
5719
5777
  case 0:
5720
5778
  currentTask = options.currentTask, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, maxExecutionAttempts = options.maxExecutionAttempts, maxParallelCount = options.maxParallelCount, csvSettings = options.csvSettings, isVerbose = options.isVerbose, rootDirname = options.rootDirname, cacheDirname = options.cacheDirname, intermediateFilesStrategy = options.intermediateFilesStrategy, isAutoInstalled = options.isAutoInstalled, isNotPreparedWarningSupressed = options.isNotPreparedWarningSupressed;
5721
- name = "pipeline-executor-frame-".concat(currentTask.name);
5722
- title = currentTask.title;
5723
5779
  priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5724
5780
  return [4 /*yield*/, onProgress({
5725
- name: name,
5726
- title: title,
5727
- isStarted: false,
5728
- isDone: false,
5729
- taskType: currentTask.taskType,
5730
- parameterName: currentTask.resultingParameterName,
5731
- parameterValue: null,
5732
- // <- [๐Ÿธ]
5781
+ outputParameters: (_f = {},
5782
+ _f[currentTask.resultingParameterName] = '',
5783
+ _f),
5733
5784
  })];
5734
5785
  case 1:
5735
- _h.sent();
5786
+ _k.sent();
5736
5787
  usedParameterNames = extractParameterNamesFromTask(currentTask);
5737
5788
  dependentParameterNames = new Set(currentTask.dependentParameterNames);
5738
5789
  // TODO: [๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘ฉ๐Ÿป] Use here `mapAvailableToExpectedParameters`
@@ -5751,7 +5802,7 @@
5751
5802
  pipelineIdentification: pipelineIdentification,
5752
5803
  })];
5753
5804
  case 2:
5754
- definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_h.sent())])), parametersToPass])]);
5805
+ definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_k.sent())])), parametersToPass])]);
5755
5806
  definedParameterNames = new Set(Object.keys(definedParameters));
5756
5807
  parameters = {};
5757
5808
  _loop_1 = function (parameterName) {
@@ -5779,7 +5830,7 @@
5779
5830
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
5780
5831
  finally {
5781
5832
  try {
5782
- if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
5833
+ if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
5783
5834
  }
5784
5835
  finally { if (e_1) throw e_1.error; }
5785
5836
  }
@@ -5810,24 +5861,19 @@
5810
5861
  isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
5811
5862
  })];
5812
5863
  case 3:
5813
- resultString = _h.sent();
5864
+ resultString = _k.sent();
5814
5865
  return [4 /*yield*/, onProgress({
5815
- name: name,
5816
- title: title,
5817
- isStarted: true,
5818
- isDone: true,
5819
- taskType: currentTask.taskType,
5820
- parameterName: currentTask.resultingParameterName,
5821
- parameterValue: resultString,
5822
- // <- [๐Ÿธ]
5866
+ outputParameters: (_h = {},
5867
+ _h[currentTask.resultingParameterName] = resultString,
5868
+ _h),
5823
5869
  })];
5824
5870
  case 4:
5825
- _h.sent();
5826
- return [2 /*return*/, Object.freeze((_g = {},
5827
- _g[currentTask.resultingParameterName] =
5871
+ _k.sent();
5872
+ return [2 /*return*/, Object.freeze((_j = {},
5873
+ _j[currentTask.resultingParameterName] =
5828
5874
  // <- Note: [๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘ง] No need to detect parameter collision here because pipeline checks logic consistency during construction
5829
5875
  resultString,
5830
- _g))];
5876
+ _j))];
5831
5877
  }
5832
5878
  });
5833
5879
  });
@@ -5835,9 +5881,6 @@
5835
5881
  /**
5836
5882
  * TODO: [๐Ÿคนโ€โ™‚๏ธ]
5837
5883
  */
5838
- /**
5839
- * TODO: [๐Ÿš] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
5840
- */
5841
5884
 
5842
5885
  /**
5843
5886
  * @@@
@@ -6099,15 +6142,15 @@
6099
6142
  return [3 /*break*/, 4];
6100
6143
  case 3:
6101
6144
  unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
6102
- work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
6145
+ work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (newOngoingResult) {
6103
6146
  if (isReturned) {
6104
- throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
6147
+ throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(newOngoingResult, null, 4)
6105
6148
  .split('\n')
6106
6149
  .map(function (line) { return "> ".concat(line); })
6107
6150
  .join('\n')), "\n "); }));
6108
6151
  }
6109
6152
  if (onProgress) {
6110
- onProgress(progress);
6153
+ onProgress(newOngoingResult);
6111
6154
  }
6112
6155
  }, $executionReport: executionReport, pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
6113
6156
  .then(function (newParametersToPass) {
@@ -6210,9 +6253,6 @@
6210
6253
  });
6211
6254
  });
6212
6255
  }
6213
- /**
6214
- * TODO: [๐Ÿš] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
6215
- */
6216
6256
 
6217
6257
  /**
6218
6258
  * Creates executor function from pipeline and execution tools.
@@ -6244,7 +6284,7 @@
6244
6284
  console.warn(spaceTrim.spaceTrim(function (block) { return "\n Pipeline is not prepared\n\n ".concat(block(pipelineIdentification), "\n\n It will be prepared ad-hoc before the first execution and **returned as `preparedPipeline` in `PipelineExecutorResult`**\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n "); }));
6245
6285
  }
6246
6286
  var runCount = 0;
6247
- var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
6287
+ var pipelineExecutorWithCallback = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
6248
6288
  return __generator(this, function (_a) {
6249
6289
  runCount++;
6250
6290
  return [2 /*return*/, /* not await */ executePipeline({
@@ -6269,11 +6309,23 @@
6269
6309
  })];
6270
6310
  });
6271
6311
  }); };
6312
+ var pipelineExecutor = function (inputParameters) {
6313
+ return createTask({
6314
+ taskType: 'EXECUTION',
6315
+ taskProcessCallback: function (updateOngoingResult) {
6316
+ var _this = this;
6317
+ return pipelineExecutorWithCallback(inputParameters, function (newOngoingResult) { return __awaiter(_this, void 0, void 0, function () {
6318
+ return __generator(this, function (_a) {
6319
+ updateOngoingResult(newOngoingResult);
6320
+ return [2 /*return*/];
6321
+ });
6322
+ }); });
6323
+ },
6324
+ });
6325
+ };
6326
+ // <- TODO: Make types such as there is no need to do `as` for `createTask`
6272
6327
  return pipelineExecutor;
6273
6328
  }
6274
- /**
6275
- * TODO: [๐Ÿš] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
6276
- */
6277
6329
 
6278
6330
  /**
6279
6331
  * Metadata of the scraper
@@ -6375,10 +6427,9 @@
6375
6427
  return [4 /*yield*/, source.asText()];
6376
6428
  case 4:
6377
6429
  knowledgeContent = _k.sent();
6378
- return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent })];
6430
+ return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent }).asPromise()];
6379
6431
  case 5:
6380
6432
  result = _k.sent();
6381
- assertsExecutionSuccessful(result);
6382
6433
  outputParameters = result.outputParameters;
6383
6434
  knowledgePiecesRaw = outputParameters.knowledgePieces;
6384
6435
  knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
@@ -6401,13 +6452,13 @@
6401
6452
  _c.label = 1;
6402
6453
  case 1:
6403
6454
  _c.trys.push([1, 7, , 8]);
6404
- return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent })];
6455
+ return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent }).asPromise()];
6405
6456
  case 2:
6406
6457
  titleResult = _c.sent();
6407
6458
  _a = titleResult.outputParameters.title, titleRaw = _a === void 0 ? 'Untitled' : _a;
6408
6459
  title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
6409
6460
  name = titleToName(title);
6410
- return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent })];
6461
+ return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent }).asPromise()];
6411
6462
  case 3:
6412
6463
  keywordsResult = _c.sent();
6413
6464
  _b = keywordsResult.outputParameters.keywords, keywordsRaw = _b === void 0 ? '' : _b;