@promptbook/pdf 0.100.0-34 → 0.100.0-36

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.
package/esm/index.es.js CHANGED
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-34';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-36';
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
@@ -218,6 +218,12 @@ let DEFAULT_IS_VERBOSE = false;
218
218
  * @public exported from `@promptbook/core`
219
219
  */
220
220
  const DEFAULT_IS_AUTO_INSTALLED = false;
221
+ /**
222
+ * Default simulated duration for a task in milliseconds (used for progress reporting)
223
+ *
224
+ * @public exported from `@promptbook/core`
225
+ */
226
+ const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
221
227
  /**
222
228
  * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
223
229
  *
@@ -2601,21 +2607,31 @@ function createTask(options) {
2601
2607
  },
2602
2608
  get tldr() {
2603
2609
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2604
- // Derive a short progress summary from currentValue, status and any errors/warnings.
2610
+ // Simulate progress based on elapsed time and subtasks
2605
2611
  const cv = currentValue;
2606
- // Try several common places where a percent might be stored on the partial result
2612
+ // If explicit percent is provided, use it
2607
2613
  let percentRaw = (_f = (_d = (_b = (_a = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : (_c = cv === null || cv === void 0 ? void 0 : cv.usage) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : (_e = cv === null || cv === void 0 ? void 0 : cv.progress) === null || _e === void 0 ? void 0 : _e.percent) !== null && _f !== void 0 ? _f : cv === null || cv === void 0 ? void 0 : cv.percent;
2608
- // If we didn't find a numeric percent, infer from status
2614
+ // Simulate progress if not provided
2609
2615
  if (typeof percentRaw !== 'number') {
2610
- if (status === 'FINISHED') {
2616
+ // Simulate progress: evenly split across subtasks, based on elapsed time
2617
+ const now = new Date();
2618
+ const elapsedMs = now.getTime() - createdAt.getTime();
2619
+ const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
2620
+ // If subtasks are defined, split progress evenly
2621
+ const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
2622
+ const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
2623
+ ? cv.subtasks.filter((s) => s.done || s.completed).length
2624
+ : 0;
2625
+ // Progress from completed subtasks
2626
+ const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
2627
+ // Progress from elapsed time for current subtask
2628
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
2629
+ // Combine: completed subtasks + time progress for current subtask
2630
+ percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
2631
+ if (status === 'FINISHED')
2611
2632
  percentRaw = 1;
2612
- }
2613
- else if (status === 'ERROR') {
2633
+ if (status === 'ERROR')
2614
2634
  percentRaw = 0;
2615
- }
2616
- else {
2617
- percentRaw = 0;
2618
- }
2619
2635
  }
2620
2636
  // Clamp to [0,1]
2621
2637
  let percent = Number(percentRaw) || 0;
@@ -2627,20 +2643,29 @@ function createTask(options) {
2627
2643
  const messageFromResult = (_k = (_j = (_h = (_g = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _g === void 0 ? void 0 : _g.message) !== null && _h !== void 0 ? _h : cv === null || cv === void 0 ? void 0 : cv.message) !== null && _j !== void 0 ? _j : cv === null || cv === void 0 ? void 0 : cv.summary) !== null && _k !== void 0 ? _k : cv === null || cv === void 0 ? void 0 : cv.statusMessage;
2628
2644
  let message = messageFromResult;
2629
2645
  if (!message) {
2630
- if (errors.length) {
2631
- message = errors[errors.length - 1].message || 'Error';
2632
- }
2633
- else if (warnings.length) {
2634
- message = warnings[warnings.length - 1].message || 'Warning';
2635
- }
2636
- else if (status === 'FINISHED') {
2637
- message = 'Finished';
2638
- }
2639
- else if (status === 'ERROR') {
2640
- message = 'Error';
2646
+ // If subtasks, show current subtask
2647
+ if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
2648
+ const current = cv.subtasks.find((s) => !s.done && !s.completed);
2649
+ if (current && current.title) {
2650
+ message = `Working on ${current.title}`;
2651
+ }
2641
2652
  }
2642
- else {
2643
- message = 'Running';
2653
+ if (!message) {
2654
+ if (errors.length) {
2655
+ message = errors[errors.length - 1].message || 'Error';
2656
+ }
2657
+ else if (warnings.length) {
2658
+ message = warnings[warnings.length - 1].message || 'Warning';
2659
+ }
2660
+ else if (status === 'FINISHED') {
2661
+ message = 'Finished';
2662
+ }
2663
+ else if (status === 'ERROR') {
2664
+ message = 'Error';
2665
+ }
2666
+ else {
2667
+ message = 'Running';
2668
+ }
2644
2669
  }
2645
2670
  }
2646
2671
  return {