@promptbook/cli 0.100.0-36 → 0.100.0-38

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-36';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-38';
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
@@ -5593,7 +5593,7 @@ function assertsTaskSuccessful(executionResult) {
5593
5593
  * @private internal helper function
5594
5594
  */
5595
5595
  function createTask(options) {
5596
- const { taskType, taskProcessCallback } = options;
5596
+ const { taskType, taskProcessCallback, tldrProvider } = options;
5597
5597
  let { title } = options;
5598
5598
  // TODO: [🐙] DRY
5599
5599
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
@@ -5668,7 +5668,11 @@ function createTask(options) {
5668
5668
  },
5669
5669
  get tldr() {
5670
5670
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5671
- // Simulate progress based on elapsed time and subtasks
5671
+ // Use custom tldr provider if available
5672
+ if (tldrProvider) {
5673
+ return tldrProvider(createdAt, status, currentValue, errors, warnings);
5674
+ }
5675
+ // Fallback to default implementation
5672
5676
  const cv = currentValue;
5673
5677
  // If explicit percent is provided, use it
5674
5678
  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;
@@ -7596,6 +7600,71 @@ function createPipelineExecutor(options) {
7596
7600
  updateOngoingResult(newOngoingResult);
7597
7601
  });
7598
7602
  },
7603
+ tldrProvider(createdAt, status, currentValue, errors) {
7604
+ var _a;
7605
+ // Better progress estimation based on pipeline structure
7606
+ const cv = currentValue;
7607
+ // Handle finished/error states
7608
+ if (status === 'FINISHED') {
7609
+ return {
7610
+ percent: 1,
7611
+ message: 'Finished',
7612
+ };
7613
+ }
7614
+ if (status === 'ERROR') {
7615
+ const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
7616
+ return {
7617
+ percent: 0,
7618
+ message: errorMessage,
7619
+ };
7620
+ }
7621
+ // Calculate progress based on pipeline tasks
7622
+ const totalTasks = pipeline.tasks.length;
7623
+ let completedTasks = 0;
7624
+ let currentTaskName = '';
7625
+ // Check execution report for completed tasks
7626
+ if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
7627
+ const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
7628
+ // Count completed tasks by matching titles
7629
+ const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
7630
+ completedTasks = completedTasksByTitle.length;
7631
+ // Find current task being executed (first task not yet completed)
7632
+ const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
7633
+ if (remainingTasks.length > 0) {
7634
+ currentTaskName = remainingTasks[0].name;
7635
+ }
7636
+ }
7637
+ // Calculate progress percentage
7638
+ let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
7639
+ // Add time-based progress for current task (assuming 5 minutes total)
7640
+ if (completedTasks < totalTasks) {
7641
+ const elapsedMs = new Date().getTime() - createdAt.getTime();
7642
+ const totalMs = 5 * 60 * 1000; // 5 minutes
7643
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
7644
+ // Add partial progress for current task
7645
+ percent += (1 / totalTasks) * timeProgress;
7646
+ }
7647
+ // Clamp to [0,1]
7648
+ percent = Math.min(Math.max(percent, 0), 1);
7649
+ // Generate message
7650
+ let message = '';
7651
+ if (currentTaskName) {
7652
+ // Find the task to get its title
7653
+ const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
7654
+ const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
7655
+ message = `Working on task ${taskTitle}`;
7656
+ }
7657
+ else if (completedTasks === 0) {
7658
+ message = 'Starting pipeline execution';
7659
+ }
7660
+ else {
7661
+ message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
7662
+ }
7663
+ return {
7664
+ percent,
7665
+ message,
7666
+ };
7667
+ },
7599
7668
  });
7600
7669
  // <- TODO: Make types such as there is no need to do `as` for `createTask`
7601
7670
  return pipelineExecutor;