@promptbook/core 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
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-33';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-35';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4434,6 +4434,55 @@ function createTask(options) {
4434
4434
  return status;
4435
4435
  // <- Note: [1] --||--
4436
4436
  },
4437
+ get tldr() {
4438
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4439
+ // Derive a short progress summary from currentValue, status and any errors/warnings.
4440
+ const cv = currentValue;
4441
+ // Try several common places where a percent might be stored on the partial result
4442
+ 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;
4443
+ // If we didn't find a numeric percent, infer from status
4444
+ if (typeof percentRaw !== 'number') {
4445
+ if (status === 'FINISHED') {
4446
+ percentRaw = 1;
4447
+ }
4448
+ else if (status === 'ERROR') {
4449
+ percentRaw = 0;
4450
+ }
4451
+ else {
4452
+ percentRaw = 0;
4453
+ }
4454
+ }
4455
+ // Clamp to [0,1]
4456
+ let percent = Number(percentRaw) || 0;
4457
+ if (percent < 0)
4458
+ percent = 0;
4459
+ if (percent > 1)
4460
+ percent = 1;
4461
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
4462
+ 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;
4463
+ let message = messageFromResult;
4464
+ if (!message) {
4465
+ if (errors.length) {
4466
+ message = errors[errors.length - 1].message || 'Error';
4467
+ }
4468
+ else if (warnings.length) {
4469
+ message = warnings[warnings.length - 1].message || 'Warning';
4470
+ }
4471
+ else if (status === 'FINISHED') {
4472
+ message = 'Finished';
4473
+ }
4474
+ else if (status === 'ERROR') {
4475
+ message = 'Error';
4476
+ }
4477
+ else {
4478
+ message = 'Running';
4479
+ }
4480
+ }
4481
+ return {
4482
+ percent: percent,
4483
+ message,
4484
+ };
4485
+ },
4437
4486
  get createdAt() {
4438
4487
  return createdAt;
4439
4488
  // <- Note: [1] --||--