@promptbook/cli 0.100.0-35 → 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
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-35';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-36';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -356,6 +356,12 @@ let DEFAULT_IS_VERBOSE = false;
356
356
  * @public exported from `@promptbook/core`
357
357
  */
358
358
  const DEFAULT_IS_AUTO_INSTALLED = false;
359
+ /**
360
+ * Default simulated duration for a task in milliseconds (used for progress reporting)
361
+ *
362
+ * @public exported from `@promptbook/core`
363
+ */
364
+ const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
359
365
  /**
360
366
  * Function name for generated function via `ptbk make` to get the pipeline collection
361
367
  *
@@ -5662,21 +5668,31 @@ function createTask(options) {
5662
5668
  },
5663
5669
  get tldr() {
5664
5670
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5665
- // Derive a short progress summary from currentValue, status and any errors/warnings.
5671
+ // Simulate progress based on elapsed time and subtasks
5666
5672
  const cv = currentValue;
5667
- // Try several common places where a percent might be stored on the partial result
5673
+ // If explicit percent is provided, use it
5668
5674
  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;
5669
- // If we didn't find a numeric percent, infer from status
5675
+ // Simulate progress if not provided
5670
5676
  if (typeof percentRaw !== 'number') {
5671
- if (status === 'FINISHED') {
5677
+ // Simulate progress: evenly split across subtasks, based on elapsed time
5678
+ const now = new Date();
5679
+ const elapsedMs = now.getTime() - createdAt.getTime();
5680
+ const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
5681
+ // If subtasks are defined, split progress evenly
5682
+ const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
5683
+ const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
5684
+ ? cv.subtasks.filter((s) => s.done || s.completed).length
5685
+ : 0;
5686
+ // Progress from completed subtasks
5687
+ const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
5688
+ // Progress from elapsed time for current subtask
5689
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
5690
+ // Combine: completed subtasks + time progress for current subtask
5691
+ percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
5692
+ if (status === 'FINISHED')
5672
5693
  percentRaw = 1;
5673
- }
5674
- else if (status === 'ERROR') {
5694
+ if (status === 'ERROR')
5675
5695
  percentRaw = 0;
5676
- }
5677
- else {
5678
- percentRaw = 0;
5679
- }
5680
5696
  }
5681
5697
  // Clamp to [0,1]
5682
5698
  let percent = Number(percentRaw) || 0;
@@ -5688,20 +5704,29 @@ function createTask(options) {
5688
5704
  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;
5689
5705
  let message = messageFromResult;
5690
5706
  if (!message) {
5691
- if (errors.length) {
5692
- message = errors[errors.length - 1].message || 'Error';
5693
- }
5694
- else if (warnings.length) {
5695
- message = warnings[warnings.length - 1].message || 'Warning';
5696
- }
5697
- else if (status === 'FINISHED') {
5698
- message = 'Finished';
5699
- }
5700
- else if (status === 'ERROR') {
5701
- message = 'Error';
5707
+ // If subtasks, show current subtask
5708
+ if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
5709
+ const current = cv.subtasks.find((s) => !s.done && !s.completed);
5710
+ if (current && current.title) {
5711
+ message = `Working on ${current.title}`;
5712
+ }
5702
5713
  }
5703
- else {
5704
- message = 'Running';
5714
+ if (!message) {
5715
+ if (errors.length) {
5716
+ message = errors[errors.length - 1].message || 'Error';
5717
+ }
5718
+ else if (warnings.length) {
5719
+ message = warnings[warnings.length - 1].message || 'Warning';
5720
+ }
5721
+ else if (status === 'FINISHED') {
5722
+ message = 'Finished';
5723
+ }
5724
+ else if (status === 'ERROR') {
5725
+ message = 'Error';
5726
+ }
5727
+ else {
5728
+ message = 'Running';
5729
+ }
5705
5730
  }
5706
5731
  }
5707
5732
  return {