@promptbook/website-crawler 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 +212 -159
  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 +214 -163
  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/README.md CHANGED
@@ -24,6 +24,10 @@
24
24
 
25
25
 
26
26
 
27
+ <blockquote style="color: #ff8811">
28
+ <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
29
+ </blockquote>
30
+
27
31
  ## 📦 Package `@promptbook/website-crawler`
28
32
 
29
33
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
package/esm/index.es.js CHANGED
@@ -7,6 +7,8 @@ import { mkdir, rm } from 'fs/promises';
7
7
  import { basename, join, dirname } from 'path';
8
8
  import { format } from 'prettier';
9
9
  import parserHtml from 'prettier/parser-html';
10
+ import { BehaviorSubject, concat, from } from 'rxjs';
11
+ import { randomBytes } from 'crypto';
10
12
  import { forTime } from 'waitasecond';
11
13
  import sha256 from 'crypto-js/sha256';
12
14
  import { lookup, extension } from 'mime-types';
@@ -27,7 +29,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
27
29
  * @generated
28
30
  * @see https://github.com/webgptorg/promptbook
29
31
  */
30
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-21';
32
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0';
31
33
  /**
32
34
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
35
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2379,6 +2381,58 @@ var PipelineExecutionError = /** @class */ (function (_super) {
2379
2381
  return PipelineExecutionError;
2380
2382
  }(Error));
2381
2383
 
2384
+ /**
2385
+ * Determine if the pipeline is fully prepared
2386
+ *
2387
+ * @see https://github.com/webgptorg/promptbook/discussions/196
2388
+ *
2389
+ * @public exported from `@promptbook/core`
2390
+ */
2391
+ function isPipelinePrepared(pipeline) {
2392
+ // Note: Ignoring `pipeline.preparations` @@@
2393
+ // Note: Ignoring `pipeline.knowledgePieces` @@@
2394
+ if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
2395
+ return false;
2396
+ }
2397
+ if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
2398
+ return false;
2399
+ }
2400
+ if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
2401
+ return false;
2402
+ }
2403
+ /*
2404
+ TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
2405
+ > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
2406
+ > return false;
2407
+ > }
2408
+ */
2409
+ return true;
2410
+ }
2411
+ /**
2412
+ * TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
2413
+ * TODO: [🐠] Maybe base this on `makeValidator`
2414
+ * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2415
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2416
+ * - [🏍] ? Is context in each task
2417
+ * - [♨] Are examples prepared
2418
+ * - [♨] Are tasks prepared
2419
+ */
2420
+
2421
+ /**
2422
+ * Generates random token
2423
+ *
2424
+ * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
2425
+ *
2426
+ * @private internal helper function
2427
+ * @returns secure random token
2428
+ */
2429
+ function $randomToken(randomness) {
2430
+ return randomBytes(randomness).toString('hex');
2431
+ }
2432
+ /**
2433
+ * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
2434
+ */
2435
+
2382
2436
  /**
2383
2437
  * This error indicates problems parsing the format value
2384
2438
  *
@@ -2548,9 +2602,9 @@ function deserializeError(error) {
2548
2602
  *
2549
2603
  * @param executionResult - The partial result of the Promptbook execution
2550
2604
  * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
2551
- * @public exported from `@promptbook/core`
2605
+ * @private internal helper function of `asPromise` method of `ExecutionTask`
2552
2606
  */
2553
- function assertsExecutionSuccessful(executionResult) {
2607
+ function assertsTaskSuccessful(executionResult) {
2554
2608
  var e_1, _a;
2555
2609
  var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
2556
2610
  try {
@@ -2585,121 +2639,54 @@ function assertsExecutionSuccessful(executionResult) {
2585
2639
  }
2586
2640
  }
2587
2641
  /**
2588
- * TODO: [🐚] This function should be removed OR changed OR be completely rewritten
2589
2642
  * TODO: [🧠] Can this return type be better typed than void
2590
2643
  */
2591
2644
 
2592
2645
  /**
2593
- * Determine if the pipeline is fully prepared
2594
- *
2595
- * @see https://github.com/webgptorg/promptbook/discussions/196
2596
- *
2597
- * @public exported from `@promptbook/core`
2598
- */
2599
- function isPipelinePrepared(pipeline) {
2600
- // Note: Ignoring `pipeline.preparations` @@@
2601
- // Note: Ignoring `pipeline.knowledgePieces` @@@
2602
- if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
2603
- return false;
2604
- }
2605
- if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
2606
- return false;
2607
- }
2608
- if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
2609
- return false;
2610
- }
2611
- /*
2612
- TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
2613
- > if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
2614
- > return false;
2615
- > }
2616
- */
2617
- return true;
2618
- }
2619
- /**
2620
- * TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
2621
- * TODO: [🐠] Maybe base this on `makeValidator`
2622
- * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2623
- * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2624
- * - [🏍] ? Is context in each task
2625
- * - [♨] Are examples prepared
2626
- * - [♨] Are tasks prepared
2627
- */
2628
-
2629
- /**
2630
- * Format either small or big number
2646
+ * Helper to create a new task
2631
2647
  *
2632
- * @public exported from `@promptbook/utils`
2648
+ * @private internal helper function
2633
2649
  */
2634
- function numberToString(value) {
2635
- if (value === 0) {
2636
- return '0';
2637
- }
2638
- else if (Number.isNaN(value)) {
2639
- return VALUE_STRINGS.nan;
2640
- }
2641
- else if (value === Infinity) {
2642
- return VALUE_STRINGS.infinity;
2643
- }
2644
- else if (value === -Infinity) {
2645
- return VALUE_STRINGS.negativeInfinity;
2646
- }
2647
- for (var exponent = 0; exponent < 15; exponent++) {
2648
- var factor = Math.pow(10, exponent);
2649
- var valueRounded = Math.round(value * factor) / factor;
2650
- if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
2651
- return valueRounded.toFixed(exponent);
2652
- }
2650
+ function createTask(options) {
2651
+ var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
2652
+ var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
2653
+ var resultSubject = new BehaviorSubject({});
2654
+ var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
2655
+ resultSubject.next(newOngoingResult);
2656
+ });
2657
+ function asPromise(options) {
2658
+ return __awaiter(this, void 0, void 0, function () {
2659
+ var _a, isCrashedOnError, finalResult;
2660
+ return __generator(this, function (_b) {
2661
+ switch (_b.label) {
2662
+ case 0:
2663
+ _a = (options || {}).isCrashedOnError, isCrashedOnError = _a === void 0 ? true : _a;
2664
+ return [4 /*yield*/, finalResultPromise];
2665
+ case 1:
2666
+ finalResult = _b.sent();
2667
+ if (isCrashedOnError) {
2668
+ assertsTaskSuccessful(finalResult);
2669
+ }
2670
+ return [2 /*return*/, finalResult];
2671
+ }
2672
+ });
2673
+ });
2653
2674
  }
2654
- return value.toString();
2675
+ return {
2676
+ taskType: taskType,
2677
+ taskId: taskId,
2678
+ asPromise: asPromise,
2679
+ asObservable: function () {
2680
+ return concat(resultSubject.asObservable(), from(asPromise({
2681
+ isCrashedOnError: true,
2682
+ })));
2683
+ },
2684
+ };
2655
2685
  }
2656
-
2657
2686
  /**
2658
- * Function `valueToString` will convert the given value to string
2659
- * This is useful and used in the `templateParameters` function
2660
- *
2661
- * Note: This function is not just calling `toString` method
2662
- * It's more complex and can handle this conversion specifically for LLM models
2663
- * See `VALUE_STRINGS`
2664
- *
2665
- * Note: There are 2 similar functions
2666
- * - `valueToString` converts value to string for LLM models as human-readable string
2667
- * - `asSerializable` converts value to string to preserve full information to be able to convert it back
2668
- *
2669
- * @public exported from `@promptbook/utils`
2687
+ * TODO: Maybe allow to terminate the task and add getter `isFinished` or `status`
2688
+ * TODO: [🐚] Split into more files and make `PrepareTask` & `RemoteTask` + split the function
2670
2689
  */
2671
- function valueToString(value) {
2672
- try {
2673
- if (value === '') {
2674
- return VALUE_STRINGS.empty;
2675
- }
2676
- else if (value === null) {
2677
- return VALUE_STRINGS.null;
2678
- }
2679
- else if (value === undefined) {
2680
- return VALUE_STRINGS.undefined;
2681
- }
2682
- else if (typeof value === 'string') {
2683
- return value;
2684
- }
2685
- else if (typeof value === 'number') {
2686
- return numberToString(value);
2687
- }
2688
- else if (value instanceof Date) {
2689
- return value.toISOString();
2690
- }
2691
- else {
2692
- return JSON.stringify(value);
2693
- }
2694
- }
2695
- catch (error) {
2696
- if (!(error instanceof Error)) {
2697
- throw error;
2698
- }
2699
- console.error(error);
2700
- return VALUE_STRINGS.unserializable;
2701
- }
2702
- }
2703
2690
 
2704
2691
  /**
2705
2692
  * Serializes an error into a [🚉] JSON-serializable object
@@ -3363,10 +3350,9 @@ function preparePersona(personaDescription, tools, options) {
3363
3350
  return modelName;
3364
3351
  })
3365
3352
  .join(',');
3366
- return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription })];
3353
+ return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription }).asPromise()];
3367
3354
  case 3:
3368
3355
  result = _d.sent();
3369
- assertsExecutionSuccessful(result);
3370
3356
  outputParameters = result.outputParameters;
3371
3357
  modelRequirementsRaw = outputParameters.modelRequirements;
3372
3358
  modelRequirements = JSON.parse(modelRequirementsRaw);
@@ -4049,10 +4035,9 @@ function preparePipeline(pipeline, tools, options) {
4049
4035
  var content = _a.content;
4050
4036
  return content;
4051
4037
  }).join('\n\n'),
4052
- })];
4038
+ }).asPromise()];
4053
4039
  case 2:
4054
4040
  result = _e.sent();
4055
- assertsExecutionSuccessful(result);
4056
4041
  outputParameters = result.outputParameters;
4057
4042
  titleRaw = outputParameters.title;
4058
4043
  if (isVerbose) {
@@ -4124,6 +4109,81 @@ function preparePipeline(pipeline, tools, options) {
4124
4109
  * @see https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#specify-the-desired-output-format
4125
4110
  */
4126
4111
 
4112
+ /**
4113
+ * Format either small or big number
4114
+ *
4115
+ * @public exported from `@promptbook/utils`
4116
+ */
4117
+ function numberToString(value) {
4118
+ if (value === 0) {
4119
+ return '0';
4120
+ }
4121
+ else if (Number.isNaN(value)) {
4122
+ return VALUE_STRINGS.nan;
4123
+ }
4124
+ else if (value === Infinity) {
4125
+ return VALUE_STRINGS.infinity;
4126
+ }
4127
+ else if (value === -Infinity) {
4128
+ return VALUE_STRINGS.negativeInfinity;
4129
+ }
4130
+ for (var exponent = 0; exponent < 15; exponent++) {
4131
+ var factor = Math.pow(10, exponent);
4132
+ var valueRounded = Math.round(value * factor) / factor;
4133
+ if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
4134
+ return valueRounded.toFixed(exponent);
4135
+ }
4136
+ }
4137
+ return value.toString();
4138
+ }
4139
+
4140
+ /**
4141
+ * Function `valueToString` will convert the given value to string
4142
+ * This is useful and used in the `templateParameters` function
4143
+ *
4144
+ * Note: This function is not just calling `toString` method
4145
+ * It's more complex and can handle this conversion specifically for LLM models
4146
+ * See `VALUE_STRINGS`
4147
+ *
4148
+ * Note: There are 2 similar functions
4149
+ * - `valueToString` converts value to string for LLM models as human-readable string
4150
+ * - `asSerializable` converts value to string to preserve full information to be able to convert it back
4151
+ *
4152
+ * @public exported from `@promptbook/utils`
4153
+ */
4154
+ function valueToString(value) {
4155
+ try {
4156
+ if (value === '') {
4157
+ return VALUE_STRINGS.empty;
4158
+ }
4159
+ else if (value === null) {
4160
+ return VALUE_STRINGS.null;
4161
+ }
4162
+ else if (value === undefined) {
4163
+ return VALUE_STRINGS.undefined;
4164
+ }
4165
+ else if (typeof value === 'string') {
4166
+ return value;
4167
+ }
4168
+ else if (typeof value === 'number') {
4169
+ return numberToString(value);
4170
+ }
4171
+ else if (value instanceof Date) {
4172
+ return value.toISOString();
4173
+ }
4174
+ else {
4175
+ return JSON.stringify(value);
4176
+ }
4177
+ }
4178
+ catch (error) {
4179
+ if (!(error instanceof Error)) {
4180
+ throw error;
4181
+ }
4182
+ console.error(error);
4183
+ return VALUE_STRINGS.unserializable;
4184
+ }
4185
+ }
4186
+
4127
4187
  /**
4128
4188
  * Parses the given script and returns the list of all used variables that are not defined in the script
4129
4189
  *
@@ -5568,27 +5628,20 @@ function getReservedParametersForTask(options) {
5568
5628
  */
5569
5629
  function executeTask(options) {
5570
5630
  return __awaiter(this, void 0, void 0, function () {
5571
- 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;
5572
- var e_1, _f, _g;
5573
- return __generator(this, function (_h) {
5574
- switch (_h.label) {
5631
+ 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;
5632
+ var _f, e_1, _g, _h, _j;
5633
+ return __generator(this, function (_k) {
5634
+ switch (_k.label) {
5575
5635
  case 0:
5576
5636
  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;
5577
- name = "pipeline-executor-frame-".concat(currentTask.name);
5578
- title = currentTask.title;
5579
5637
  priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
5580
5638
  return [4 /*yield*/, onProgress({
5581
- name: name,
5582
- title: title,
5583
- isStarted: false,
5584
- isDone: false,
5585
- taskType: currentTask.taskType,
5586
- parameterName: currentTask.resultingParameterName,
5587
- parameterValue: null,
5588
- // <- [🍸]
5639
+ outputParameters: (_f = {},
5640
+ _f[currentTask.resultingParameterName] = '',
5641
+ _f),
5589
5642
  })];
5590
5643
  case 1:
5591
- _h.sent();
5644
+ _k.sent();
5592
5645
  usedParameterNames = extractParameterNamesFromTask(currentTask);
5593
5646
  dependentParameterNames = new Set(currentTask.dependentParameterNames);
5594
5647
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
@@ -5607,7 +5660,7 @@ function executeTask(options) {
5607
5660
  pipelineIdentification: pipelineIdentification,
5608
5661
  })];
5609
5662
  case 2:
5610
- definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_h.sent())])), parametersToPass])]);
5663
+ definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_k.sent())])), parametersToPass])]);
5611
5664
  definedParameterNames = new Set(Object.keys(definedParameters));
5612
5665
  parameters = {};
5613
5666
  _loop_1 = function (parameterName) {
@@ -5635,7 +5688,7 @@ function executeTask(options) {
5635
5688
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
5636
5689
  finally {
5637
5690
  try {
5638
- if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
5691
+ if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
5639
5692
  }
5640
5693
  finally { if (e_1) throw e_1.error; }
5641
5694
  }
@@ -5666,24 +5719,19 @@ function executeTask(options) {
5666
5719
  isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
5667
5720
  })];
5668
5721
  case 3:
5669
- resultString = _h.sent();
5722
+ resultString = _k.sent();
5670
5723
  return [4 /*yield*/, onProgress({
5671
- name: name,
5672
- title: title,
5673
- isStarted: true,
5674
- isDone: true,
5675
- taskType: currentTask.taskType,
5676
- parameterName: currentTask.resultingParameterName,
5677
- parameterValue: resultString,
5678
- // <- [🍸]
5724
+ outputParameters: (_h = {},
5725
+ _h[currentTask.resultingParameterName] = resultString,
5726
+ _h),
5679
5727
  })];
5680
5728
  case 4:
5681
- _h.sent();
5682
- return [2 /*return*/, Object.freeze((_g = {},
5683
- _g[currentTask.resultingParameterName] =
5729
+ _k.sent();
5730
+ return [2 /*return*/, Object.freeze((_j = {},
5731
+ _j[currentTask.resultingParameterName] =
5684
5732
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
5685
5733
  resultString,
5686
- _g))];
5734
+ _j))];
5687
5735
  }
5688
5736
  });
5689
5737
  });
@@ -5691,9 +5739,6 @@ function executeTask(options) {
5691
5739
  /**
5692
5740
  * TODO: [🤹‍♂️]
5693
5741
  */
5694
- /**
5695
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
5696
- */
5697
5742
 
5698
5743
  /**
5699
5744
  * @@@
@@ -5955,15 +6000,15 @@ function executePipeline(options) {
5955
6000
  return [3 /*break*/, 4];
5956
6001
  case 3:
5957
6002
  unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
5958
- work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
6003
+ work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (newOngoingResult) {
5959
6004
  if (isReturned) {
5960
- throw new UnexpectedError(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)
6005
+ throw new UnexpectedError(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)
5961
6006
  .split('\n')
5962
6007
  .map(function (line) { return "> ".concat(line); })
5963
6008
  .join('\n')), "\n "); }));
5964
6009
  }
5965
6010
  if (onProgress) {
5966
- onProgress(progress);
6011
+ onProgress(newOngoingResult);
5967
6012
  }
5968
6013
  }, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
5969
6014
  .then(function (newParametersToPass) {
@@ -6066,9 +6111,6 @@ function executePipeline(options) {
6066
6111
  });
6067
6112
  });
6068
6113
  }
6069
- /**
6070
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
6071
- */
6072
6114
 
6073
6115
  /**
6074
6116
  * Creates executor function from pipeline and execution tools.
@@ -6100,7 +6142,7 @@ function createPipelineExecutor(options) {
6100
6142
  console.warn(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 "); }));
6101
6143
  }
6102
6144
  var runCount = 0;
6103
- var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
6145
+ var pipelineExecutorWithCallback = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
6104
6146
  return __generator(this, function (_a) {
6105
6147
  runCount++;
6106
6148
  return [2 /*return*/, /* not await */ executePipeline({
@@ -6125,11 +6167,23 @@ function createPipelineExecutor(options) {
6125
6167
  })];
6126
6168
  });
6127
6169
  }); };
6170
+ var pipelineExecutor = function (inputParameters) {
6171
+ return createTask({
6172
+ taskType: 'EXECUTION',
6173
+ taskProcessCallback: function (updateOngoingResult) {
6174
+ var _this = this;
6175
+ return pipelineExecutorWithCallback(inputParameters, function (newOngoingResult) { return __awaiter(_this, void 0, void 0, function () {
6176
+ return __generator(this, function (_a) {
6177
+ updateOngoingResult(newOngoingResult);
6178
+ return [2 /*return*/];
6179
+ });
6180
+ }); });
6181
+ },
6182
+ });
6183
+ };
6184
+ // <- TODO: Make types such as there is no need to do `as` for `createTask`
6128
6185
  return pipelineExecutor;
6129
6186
  }
6130
- /**
6131
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
6132
- */
6133
6187
 
6134
6188
  /**
6135
6189
  * Metadata of the scraper
@@ -6231,10 +6285,9 @@ var MarkdownScraper = /** @class */ (function () {
6231
6285
  return [4 /*yield*/, source.asText()];
6232
6286
  case 4:
6233
6287
  knowledgeContent = _k.sent();
6234
- return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent })];
6288
+ return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent }).asPromise()];
6235
6289
  case 5:
6236
6290
  result = _k.sent();
6237
- assertsExecutionSuccessful(result);
6238
6291
  outputParameters = result.outputParameters;
6239
6292
  knowledgePiecesRaw = outputParameters.knowledgePieces;
6240
6293
  knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
@@ -6257,13 +6310,13 @@ var MarkdownScraper = /** @class */ (function () {
6257
6310
  _c.label = 1;
6258
6311
  case 1:
6259
6312
  _c.trys.push([1, 7, , 8]);
6260
- return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent })];
6313
+ return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent }).asPromise()];
6261
6314
  case 2:
6262
6315
  titleResult = _c.sent();
6263
6316
  _a = titleResult.outputParameters.title, titleRaw = _a === void 0 ? 'Untitled' : _a;
6264
6317
  title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
6265
6318
  name = titleToName(title);
6266
- return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent })];
6319
+ return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent }).asPromise()];
6267
6320
  case 3:
6268
6321
  keywordsResult = _c.sent();
6269
6322
  _b = keywordsResult.outputParameters.keywords, keywordsRaw = _b === void 0 ? '' : _b;