@promptbook/cli 0.100.0-33 → 0.100.0-34

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-33';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-34';
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
@@ -5660,6 +5660,55 @@ function createTask(options) {
5660
5660
  return status;
5661
5661
  // <- Note: [1] --||--
5662
5662
  },
5663
+ get tldr() {
5664
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5665
+ // Derive a short progress summary from currentValue, status and any errors/warnings.
5666
+ const cv = currentValue;
5667
+ // Try several common places where a percent might be stored on the partial result
5668
+ 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
5670
+ if (typeof percentRaw !== 'number') {
5671
+ if (status === 'FINISHED') {
5672
+ percentRaw = 1;
5673
+ }
5674
+ else if (status === 'ERROR') {
5675
+ percentRaw = 0;
5676
+ }
5677
+ else {
5678
+ percentRaw = 0;
5679
+ }
5680
+ }
5681
+ // Clamp to [0,1]
5682
+ let percent = Number(percentRaw) || 0;
5683
+ if (percent < 0)
5684
+ percent = 0;
5685
+ if (percent > 1)
5686
+ percent = 1;
5687
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
5688
+ 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
+ let message = messageFromResult;
5690
+ 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';
5702
+ }
5703
+ else {
5704
+ message = 'Running';
5705
+ }
5706
+ }
5707
+ return {
5708
+ percent: percent,
5709
+ message,
5710
+ };
5711
+ },
5663
5712
  get createdAt() {
5664
5713
  return createdAt;
5665
5714
  // <- Note: [1] --||--
@@ -14751,7 +14800,7 @@ function startRemoteServer(options) {
14751
14800
  });
14752
14801
  function exportExecutionTask(executionTask, isFull) {
14753
14802
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
14754
- const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
14803
+ const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
14755
14804
  if (isFull) {
14756
14805
  return {
14757
14806
  taskId,
@@ -14759,6 +14808,7 @@ function startRemoteServer(options) {
14759
14808
  taskType,
14760
14809
  promptbookVersion,
14761
14810
  status,
14811
+ tldr,
14762
14812
  errors: errors.map(serializeError),
14763
14813
  warnings: warnings.map(serializeError),
14764
14814
  createdAt,
@@ -14773,6 +14823,7 @@ function startRemoteServer(options) {
14773
14823
  taskType,
14774
14824
  promptbookVersion,
14775
14825
  status,
14826
+ tldr,
14776
14827
  createdAt,
14777
14828
  updatedAt,
14778
14829
  };