@promptbook/remote-server 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
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
33
33
  * @generated
34
34
  * @see https://github.com/webgptorg/promptbook
35
35
  */
36
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-33';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-34';
37
37
  /**
38
38
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
39
39
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2073,6 +2073,55 @@ function createTask(options) {
2073
2073
  return status;
2074
2074
  // <- Note: [1] --||--
2075
2075
  },
2076
+ get tldr() {
2077
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2078
+ // Derive a short progress summary from currentValue, status and any errors/warnings.
2079
+ const cv = currentValue;
2080
+ // Try several common places where a percent might be stored on the partial result
2081
+ 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;
2082
+ // If we didn't find a numeric percent, infer from status
2083
+ if (typeof percentRaw !== 'number') {
2084
+ if (status === 'FINISHED') {
2085
+ percentRaw = 1;
2086
+ }
2087
+ else if (status === 'ERROR') {
2088
+ percentRaw = 0;
2089
+ }
2090
+ else {
2091
+ percentRaw = 0;
2092
+ }
2093
+ }
2094
+ // Clamp to [0,1]
2095
+ let percent = Number(percentRaw) || 0;
2096
+ if (percent < 0)
2097
+ percent = 0;
2098
+ if (percent > 1)
2099
+ percent = 1;
2100
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
2101
+ 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;
2102
+ let message = messageFromResult;
2103
+ if (!message) {
2104
+ if (errors.length) {
2105
+ message = errors[errors.length - 1].message || 'Error';
2106
+ }
2107
+ else if (warnings.length) {
2108
+ message = warnings[warnings.length - 1].message || 'Warning';
2109
+ }
2110
+ else if (status === 'FINISHED') {
2111
+ message = 'Finished';
2112
+ }
2113
+ else if (status === 'ERROR') {
2114
+ message = 'Error';
2115
+ }
2116
+ else {
2117
+ message = 'Running';
2118
+ }
2119
+ }
2120
+ return {
2121
+ percent: percent,
2122
+ message,
2123
+ };
2124
+ },
2076
2125
  get createdAt() {
2077
2126
  return createdAt;
2078
2127
  // <- Note: [1] --||--
@@ -8148,7 +8197,7 @@ function startRemoteServer(options) {
8148
8197
  });
8149
8198
  function exportExecutionTask(executionTask, isFull) {
8150
8199
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
8151
- const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
8200
+ const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
8152
8201
  if (isFull) {
8153
8202
  return {
8154
8203
  taskId,
@@ -8156,6 +8205,7 @@ function startRemoteServer(options) {
8156
8205
  taskType,
8157
8206
  promptbookVersion,
8158
8207
  status,
8208
+ tldr,
8159
8209
  errors: errors.map(serializeError),
8160
8210
  warnings: warnings.map(serializeError),
8161
8211
  createdAt,
@@ -8170,6 +8220,7 @@ function startRemoteServer(options) {
8170
8220
  taskType,
8171
8221
  promptbookVersion,
8172
8222
  status,
8223
+ tldr,
8173
8224
  createdAt,
8174
8225
  updatedAt,
8175
8226
  };