@promptbook/node 0.100.0-34 → 0.100.0-36
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 +49 -24
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/config.d.ts +6 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +49 -24
- package/umd/index.umd.js.map +1 -1
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-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-36';
|
|
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
|
|
@@ -232,6 +232,12 @@ let DEFAULT_IS_VERBOSE = false;
|
|
|
232
232
|
* @public exported from `@promptbook/core`
|
|
233
233
|
*/
|
|
234
234
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
235
|
+
/**
|
|
236
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
237
|
+
*
|
|
238
|
+
* @public exported from `@promptbook/core`
|
|
239
|
+
*/
|
|
240
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
235
241
|
/**
|
|
236
242
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
237
243
|
*
|
|
@@ -2157,21 +2163,31 @@ function createTask(options) {
|
|
|
2157
2163
|
},
|
|
2158
2164
|
get tldr() {
|
|
2159
2165
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2160
|
-
//
|
|
2166
|
+
// Simulate progress based on elapsed time and subtasks
|
|
2161
2167
|
const cv = currentValue;
|
|
2162
|
-
//
|
|
2168
|
+
// If explicit percent is provided, use it
|
|
2163
2169
|
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
|
-
//
|
|
2170
|
+
// Simulate progress if not provided
|
|
2165
2171
|
if (typeof percentRaw !== 'number') {
|
|
2166
|
-
|
|
2172
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2173
|
+
const now = new Date();
|
|
2174
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2175
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2176
|
+
// If subtasks are defined, split progress evenly
|
|
2177
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2178
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2179
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2180
|
+
: 0;
|
|
2181
|
+
// Progress from completed subtasks
|
|
2182
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2183
|
+
// Progress from elapsed time for current subtask
|
|
2184
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2185
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2186
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2187
|
+
if (status === 'FINISHED')
|
|
2167
2188
|
percentRaw = 1;
|
|
2168
|
-
|
|
2169
|
-
else if (status === 'ERROR') {
|
|
2189
|
+
if (status === 'ERROR')
|
|
2170
2190
|
percentRaw = 0;
|
|
2171
|
-
}
|
|
2172
|
-
else {
|
|
2173
|
-
percentRaw = 0;
|
|
2174
|
-
}
|
|
2175
2191
|
}
|
|
2176
2192
|
// Clamp to [0,1]
|
|
2177
2193
|
let percent = Number(percentRaw) || 0;
|
|
@@ -2183,20 +2199,29 @@ function createTask(options) {
|
|
|
2183
2199
|
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
2200
|
let message = messageFromResult;
|
|
2185
2201
|
if (!message) {
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
else if (status === 'FINISHED') {
|
|
2193
|
-
message = 'Finished';
|
|
2194
|
-
}
|
|
2195
|
-
else if (status === 'ERROR') {
|
|
2196
|
-
message = 'Error';
|
|
2202
|
+
// If subtasks, show current subtask
|
|
2203
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2204
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2205
|
+
if (current && current.title) {
|
|
2206
|
+
message = `Working on ${current.title}`;
|
|
2207
|
+
}
|
|
2197
2208
|
}
|
|
2198
|
-
|
|
2199
|
-
|
|
2209
|
+
if (!message) {
|
|
2210
|
+
if (errors.length) {
|
|
2211
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2212
|
+
}
|
|
2213
|
+
else if (warnings.length) {
|
|
2214
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2215
|
+
}
|
|
2216
|
+
else if (status === 'FINISHED') {
|
|
2217
|
+
message = 'Finished';
|
|
2218
|
+
}
|
|
2219
|
+
else if (status === 'ERROR') {
|
|
2220
|
+
message = 'Error';
|
|
2221
|
+
}
|
|
2222
|
+
else {
|
|
2223
|
+
message = 'Running';
|
|
2224
|
+
}
|
|
2200
2225
|
}
|
|
2201
2226
|
}
|
|
2202
2227
|
return {
|