@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.
@@ -1,5 +1,6 @@
1
1
  import type { Observable } from 'rxjs';
2
2
  import { PartialDeep } from 'type-fest';
3
+ import type { number_percent } from '../types/typeAliases';
3
4
  import type { task_id } from '../types/typeAliases';
4
5
  import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
5
6
  import type { string_promptbook_version } from '../version';
@@ -80,6 +81,19 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
80
81
  * Status of the task
81
82
  */
82
83
  readonly status: task_status;
84
+ /**
85
+ * Short summary of the task status for quick overview in the UI
86
+ */
87
+ readonly tldr: {
88
+ /**
89
+ * Progress in percentage from 0 to 1 (100%) that can be used to display a progress bar
90
+ */
91
+ readonly percent: number_percent;
92
+ /**
93
+ * Short summary message of the task status that can be displayed in the UI
94
+ */
95
+ readonly message: string;
96
+ };
83
97
  /**
84
98
  * Date when the task was created
85
99
  */
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.100.0-32`).
18
+ * It follows semantic versioning (e.g., `0.100.0-33`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.100.0-33",
3
+ "version": "0.100.0-34",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -95,7 +95,7 @@
95
95
  "module": "./esm/index.es.js",
96
96
  "typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
97
97
  "peerDependencies": {
98
- "@promptbook/core": "0.100.0-33"
98
+ "@promptbook/core": "0.100.0-34"
99
99
  },
100
100
  "dependencies": {
101
101
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-33';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-34';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2088,6 +2088,55 @@
2088
2088
  return status;
2089
2089
  // <- Note: [1] --||--
2090
2090
  },
2091
+ get tldr() {
2092
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2093
+ // Derive a short progress summary from currentValue, status and any errors/warnings.
2094
+ const cv = currentValue;
2095
+ // Try several common places where a percent might be stored on the partial result
2096
+ 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;
2097
+ // If we didn't find a numeric percent, infer from status
2098
+ if (typeof percentRaw !== 'number') {
2099
+ if (status === 'FINISHED') {
2100
+ percentRaw = 1;
2101
+ }
2102
+ else if (status === 'ERROR') {
2103
+ percentRaw = 0;
2104
+ }
2105
+ else {
2106
+ percentRaw = 0;
2107
+ }
2108
+ }
2109
+ // Clamp to [0,1]
2110
+ let percent = Number(percentRaw) || 0;
2111
+ if (percent < 0)
2112
+ percent = 0;
2113
+ if (percent > 1)
2114
+ percent = 1;
2115
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
2116
+ 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;
2117
+ let message = messageFromResult;
2118
+ if (!message) {
2119
+ if (errors.length) {
2120
+ message = errors[errors.length - 1].message || 'Error';
2121
+ }
2122
+ else if (warnings.length) {
2123
+ message = warnings[warnings.length - 1].message || 'Warning';
2124
+ }
2125
+ else if (status === 'FINISHED') {
2126
+ message = 'Finished';
2127
+ }
2128
+ else if (status === 'ERROR') {
2129
+ message = 'Error';
2130
+ }
2131
+ else {
2132
+ message = 'Running';
2133
+ }
2134
+ }
2135
+ return {
2136
+ percent: percent,
2137
+ message,
2138
+ };
2139
+ },
2091
2140
  get createdAt() {
2092
2141
  return createdAt;
2093
2142
  // <- Note: [1] --||--
@@ -8163,7 +8212,7 @@
8163
8212
  });
8164
8213
  function exportExecutionTask(executionTask, isFull) {
8165
8214
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
8166
- const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
8215
+ const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
8167
8216
  if (isFull) {
8168
8217
  return {
8169
8218
  taskId,
@@ -8171,6 +8220,7 @@
8171
8220
  taskType,
8172
8221
  promptbookVersion,
8173
8222
  status,
8223
+ tldr,
8174
8224
  errors: errors.map(serializeError),
8175
8225
  warnings: warnings.map(serializeError),
8176
8226
  createdAt,
@@ -8185,6 +8235,7 @@
8185
8235
  taskType,
8186
8236
  promptbookVersion,
8187
8237
  status,
8238
+ tldr,
8188
8239
  createdAt,
8189
8240
  updatedAt,
8190
8241
  };