@promptbook/node 0.100.0-32 → 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
@@ -30,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-32';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-34';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2155,6 +2155,55 @@ function createTask(options) {
2155
2155
  return status;
2156
2156
  // <- Note: [1] --||--
2157
2157
  },
2158
+ get tldr() {
2159
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2160
+ // Derive a short progress summary from currentValue, status and any errors/warnings.
2161
+ const cv = currentValue;
2162
+ // Try several common places where a percent might be stored on the partial result
2163
+ 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;
2164
+ // If we didn't find a numeric percent, infer from status
2165
+ if (typeof percentRaw !== 'number') {
2166
+ if (status === 'FINISHED') {
2167
+ percentRaw = 1;
2168
+ }
2169
+ else if (status === 'ERROR') {
2170
+ percentRaw = 0;
2171
+ }
2172
+ else {
2173
+ percentRaw = 0;
2174
+ }
2175
+ }
2176
+ // Clamp to [0,1]
2177
+ let percent = Number(percentRaw) || 0;
2178
+ if (percent < 0)
2179
+ percent = 0;
2180
+ if (percent > 1)
2181
+ percent = 1;
2182
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
2183
+ 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;
2184
+ let message = messageFromResult;
2185
+ if (!message) {
2186
+ if (errors.length) {
2187
+ message = errors[errors.length - 1].message || 'Error';
2188
+ }
2189
+ else if (warnings.length) {
2190
+ message = warnings[warnings.length - 1].message || 'Warning';
2191
+ }
2192
+ else if (status === 'FINISHED') {
2193
+ message = 'Finished';
2194
+ }
2195
+ else if (status === 'ERROR') {
2196
+ message = 'Error';
2197
+ }
2198
+ else {
2199
+ message = 'Running';
2200
+ }
2201
+ }
2202
+ return {
2203
+ percent: percent,
2204
+ message,
2205
+ };
2206
+ },
2158
2207
  get createdAt() {
2159
2208
  return createdAt;
2160
2209
  // <- Note: [1] --||--