@promptbook/wizard 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
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
38
38
|
* @generated
|
39
39
|
* @see https://github.com/webgptorg/promptbook
|
40
40
|
*/
|
41
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
41
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-36';
|
42
42
|
/**
|
43
43
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
44
44
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
@@ -312,6 +312,12 @@ let DEFAULT_IS_VERBOSE = false;
|
|
312
312
|
* @public exported from `@promptbook/core`
|
313
313
|
*/
|
314
314
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
315
|
+
/**
|
316
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
317
|
+
*
|
318
|
+
* @public exported from `@promptbook/core`
|
319
|
+
*/
|
320
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
315
321
|
/**
|
316
322
|
* Default rate limits (requests per minute)
|
317
323
|
*
|
@@ -7240,21 +7246,31 @@ function createTask(options) {
|
|
7240
7246
|
},
|
7241
7247
|
get tldr() {
|
7242
7248
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
7243
|
-
//
|
7249
|
+
// Simulate progress based on elapsed time and subtasks
|
7244
7250
|
const cv = currentValue;
|
7245
|
-
//
|
7251
|
+
// If explicit percent is provided, use it
|
7246
7252
|
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;
|
7247
|
-
//
|
7253
|
+
// Simulate progress if not provided
|
7248
7254
|
if (typeof percentRaw !== 'number') {
|
7249
|
-
|
7255
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
7256
|
+
const now = new Date();
|
7257
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
7258
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
7259
|
+
// If subtasks are defined, split progress evenly
|
7260
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
7261
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
7262
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
7263
|
+
: 0;
|
7264
|
+
// Progress from completed subtasks
|
7265
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
7266
|
+
// Progress from elapsed time for current subtask
|
7267
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
7268
|
+
// Combine: completed subtasks + time progress for current subtask
|
7269
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
7270
|
+
if (status === 'FINISHED')
|
7250
7271
|
percentRaw = 1;
|
7251
|
-
|
7252
|
-
else if (status === 'ERROR') {
|
7272
|
+
if (status === 'ERROR')
|
7253
7273
|
percentRaw = 0;
|
7254
|
-
}
|
7255
|
-
else {
|
7256
|
-
percentRaw = 0;
|
7257
|
-
}
|
7258
7274
|
}
|
7259
7275
|
// Clamp to [0,1]
|
7260
7276
|
let percent = Number(percentRaw) || 0;
|
@@ -7266,20 +7282,29 @@ function createTask(options) {
|
|
7266
7282
|
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;
|
7267
7283
|
let message = messageFromResult;
|
7268
7284
|
if (!message) {
|
7269
|
-
|
7270
|
-
|
7271
|
-
|
7272
|
-
|
7273
|
-
|
7274
|
-
|
7275
|
-
else if (status === 'FINISHED') {
|
7276
|
-
message = 'Finished';
|
7277
|
-
}
|
7278
|
-
else if (status === 'ERROR') {
|
7279
|
-
message = 'Error';
|
7285
|
+
// If subtasks, show current subtask
|
7286
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
7287
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
7288
|
+
if (current && current.title) {
|
7289
|
+
message = `Working on ${current.title}`;
|
7290
|
+
}
|
7280
7291
|
}
|
7281
|
-
|
7282
|
-
|
7292
|
+
if (!message) {
|
7293
|
+
if (errors.length) {
|
7294
|
+
message = errors[errors.length - 1].message || 'Error';
|
7295
|
+
}
|
7296
|
+
else if (warnings.length) {
|
7297
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
7298
|
+
}
|
7299
|
+
else if (status === 'FINISHED') {
|
7300
|
+
message = 'Finished';
|
7301
|
+
}
|
7302
|
+
else if (status === 'ERROR') {
|
7303
|
+
message = 'Error';
|
7304
|
+
}
|
7305
|
+
else {
|
7306
|
+
message = 'Running';
|
7307
|
+
}
|
7283
7308
|
}
|
7284
7309
|
}
|
7285
7310
|
return {
|