@promptbook/website-crawler 0.100.0-33 → 0.100.0-35

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
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
29
29
  * @generated
30
30
  * @see https://github.com/webgptorg/promptbook
31
31
  */
32
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-33';
32
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-35';
33
33
  /**
34
34
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
35
35
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2715,6 +2715,55 @@ function createTask(options) {
2715
2715
  return status;
2716
2716
  // <- Note: [1] --||--
2717
2717
  },
2718
+ get tldr() {
2719
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2720
+ // Derive a short progress summary from currentValue, status and any errors/warnings.
2721
+ const cv = currentValue;
2722
+ // Try several common places where a percent might be stored on the partial result
2723
+ 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;
2724
+ // If we didn't find a numeric percent, infer from status
2725
+ if (typeof percentRaw !== 'number') {
2726
+ if (status === 'FINISHED') {
2727
+ percentRaw = 1;
2728
+ }
2729
+ else if (status === 'ERROR') {
2730
+ percentRaw = 0;
2731
+ }
2732
+ else {
2733
+ percentRaw = 0;
2734
+ }
2735
+ }
2736
+ // Clamp to [0,1]
2737
+ let percent = Number(percentRaw) || 0;
2738
+ if (percent < 0)
2739
+ percent = 0;
2740
+ if (percent > 1)
2741
+ percent = 1;
2742
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
2743
+ 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;
2744
+ let message = messageFromResult;
2745
+ if (!message) {
2746
+ if (errors.length) {
2747
+ message = errors[errors.length - 1].message || 'Error';
2748
+ }
2749
+ else if (warnings.length) {
2750
+ message = warnings[warnings.length - 1].message || 'Warning';
2751
+ }
2752
+ else if (status === 'FINISHED') {
2753
+ message = 'Finished';
2754
+ }
2755
+ else if (status === 'ERROR') {
2756
+ message = 'Error';
2757
+ }
2758
+ else {
2759
+ message = 'Running';
2760
+ }
2761
+ }
2762
+ return {
2763
+ percent: percent,
2764
+ message,
2765
+ };
2766
+ },
2718
2767
  get createdAt() {
2719
2768
  return createdAt;
2720
2769
  // <- Note: [1] --||--