@promptbook/website-crawler 0.100.0-35 → 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
|
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
29
29
|
* @generated
|
|
30
30
|
* @see https://github.com/webgptorg/promptbook
|
|
31
31
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
32
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-36';
|
|
33
33
|
/**
|
|
34
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
35
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -248,6 +248,12 @@ let DEFAULT_IS_VERBOSE = false;
|
|
|
248
248
|
* @public exported from `@promptbook/core`
|
|
249
249
|
*/
|
|
250
250
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
251
|
+
/**
|
|
252
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
253
|
+
*
|
|
254
|
+
* @public exported from `@promptbook/core`
|
|
255
|
+
*/
|
|
256
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
251
257
|
/**
|
|
252
258
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
253
259
|
*
|
|
@@ -2717,21 +2723,31 @@ function createTask(options) {
|
|
|
2717
2723
|
},
|
|
2718
2724
|
get tldr() {
|
|
2719
2725
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2720
|
-
//
|
|
2726
|
+
// Simulate progress based on elapsed time and subtasks
|
|
2721
2727
|
const cv = currentValue;
|
|
2722
|
-
//
|
|
2728
|
+
// If explicit percent is provided, use it
|
|
2723
2729
|
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;
|
|
2724
|
-
//
|
|
2730
|
+
// Simulate progress if not provided
|
|
2725
2731
|
if (typeof percentRaw !== 'number') {
|
|
2726
|
-
|
|
2732
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2733
|
+
const now = new Date();
|
|
2734
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2735
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2736
|
+
// If subtasks are defined, split progress evenly
|
|
2737
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2738
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2739
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2740
|
+
: 0;
|
|
2741
|
+
// Progress from completed subtasks
|
|
2742
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2743
|
+
// Progress from elapsed time for current subtask
|
|
2744
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2745
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2746
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2747
|
+
if (status === 'FINISHED')
|
|
2727
2748
|
percentRaw = 1;
|
|
2728
|
-
|
|
2729
|
-
else if (status === 'ERROR') {
|
|
2749
|
+
if (status === 'ERROR')
|
|
2730
2750
|
percentRaw = 0;
|
|
2731
|
-
}
|
|
2732
|
-
else {
|
|
2733
|
-
percentRaw = 0;
|
|
2734
|
-
}
|
|
2735
2751
|
}
|
|
2736
2752
|
// Clamp to [0,1]
|
|
2737
2753
|
let percent = Number(percentRaw) || 0;
|
|
@@ -2743,20 +2759,29 @@ function createTask(options) {
|
|
|
2743
2759
|
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;
|
|
2744
2760
|
let message = messageFromResult;
|
|
2745
2761
|
if (!message) {
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
else if (status === 'FINISHED') {
|
|
2753
|
-
message = 'Finished';
|
|
2754
|
-
}
|
|
2755
|
-
else if (status === 'ERROR') {
|
|
2756
|
-
message = 'Error';
|
|
2762
|
+
// If subtasks, show current subtask
|
|
2763
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2764
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2765
|
+
if (current && current.title) {
|
|
2766
|
+
message = `Working on ${current.title}`;
|
|
2767
|
+
}
|
|
2757
2768
|
}
|
|
2758
|
-
|
|
2759
|
-
|
|
2769
|
+
if (!message) {
|
|
2770
|
+
if (errors.length) {
|
|
2771
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2772
|
+
}
|
|
2773
|
+
else if (warnings.length) {
|
|
2774
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2775
|
+
}
|
|
2776
|
+
else if (status === 'FINISHED') {
|
|
2777
|
+
message = 'Finished';
|
|
2778
|
+
}
|
|
2779
|
+
else if (status === 'ERROR') {
|
|
2780
|
+
message = 'Error';
|
|
2781
|
+
}
|
|
2782
|
+
else {
|
|
2783
|
+
message = 'Running';
|
|
2784
|
+
}
|
|
2760
2785
|
}
|
|
2761
2786
|
}
|
|
2762
2787
|
return {
|