@promptbook/node 0.88.0-1 → 0.88.0-8
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 +50 -9
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/cli/cli-commands/common/handleActionErrors.d.ts +11 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +24 -0
- package/package.json +2 -2
- package/umd/index.umd.js +49 -8
- package/umd/index.umd.js.map +1 -1
|
@@ -40,6 +40,7 @@ import type { ExecutionReportString } from '../execution/execution-report/Execut
|
|
|
40
40
|
import type { ExecutionReportStringOptions } from '../execution/execution-report/ExecutionReportStringOptions';
|
|
41
41
|
import type { ExecutionTask } from '../execution/ExecutionTask';
|
|
42
42
|
import type { PreparationTask } from '../execution/ExecutionTask';
|
|
43
|
+
import type { task_status } from '../execution/ExecutionTask';
|
|
43
44
|
import type { AbstractTask } from '../execution/ExecutionTask';
|
|
44
45
|
import type { Task } from '../execution/ExecutionTask';
|
|
45
46
|
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
@@ -322,6 +323,7 @@ export type { ExecutionReportString };
|
|
|
322
323
|
export type { ExecutionReportStringOptions };
|
|
323
324
|
export type { ExecutionTask };
|
|
324
325
|
export type { PreparationTask };
|
|
326
|
+
export type { task_status };
|
|
325
327
|
export type { AbstractTask };
|
|
326
328
|
export type { Task };
|
|
327
329
|
export type { ExecutionTools };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command as Program } from 'commander';
|
|
2
|
+
type actionCallbackFunction = Parameters<Program['action']>[0];
|
|
3
|
+
/**
|
|
4
|
+
* Wraps action to handle error console logging and exit process with error code
|
|
5
|
+
*
|
|
6
|
+
* @param action Action to be wrapped in error handling
|
|
7
|
+
* @returns Wrapped action
|
|
8
|
+
* @private internal helper function for CLI commands
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleActionErrors(action: actionCallbackFunction): actionCallbackFunction;
|
|
11
|
+
export {};
|
|
@@ -40,6 +40,10 @@ export type PreparationTask = AbstractTask<PipelineExecutorResult> & {
|
|
|
40
40
|
readonly taskType: 'PREPARATION';
|
|
41
41
|
readonly taskId: `prep-${task_id}`;
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Status of a task
|
|
45
|
+
*/
|
|
46
|
+
export type task_status = 'RUNNING' | 'FINISHED' | 'ERROR';
|
|
43
47
|
/**
|
|
44
48
|
* Base interface for all task types
|
|
45
49
|
*/
|
|
@@ -52,6 +56,18 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
|
|
|
52
56
|
* Unique identifier for the task
|
|
53
57
|
*/
|
|
54
58
|
readonly taskId: task_id;
|
|
59
|
+
/**
|
|
60
|
+
* Status of the task
|
|
61
|
+
*/
|
|
62
|
+
readonly status: task_status;
|
|
63
|
+
/**
|
|
64
|
+
* Date when the task was created
|
|
65
|
+
*/
|
|
66
|
+
readonly createdAt: Date;
|
|
67
|
+
/**
|
|
68
|
+
* Date when the task was last updated
|
|
69
|
+
*/
|
|
70
|
+
readonly updatedAt: Date;
|
|
55
71
|
/**
|
|
56
72
|
* Gets a promise that resolves with the task result
|
|
57
73
|
*/
|
|
@@ -66,6 +82,14 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
|
|
|
66
82
|
* Gets just the current value which is mutated during the task processing
|
|
67
83
|
*/
|
|
68
84
|
currentValue: PartialDeep<TTaskResult>;
|
|
85
|
+
/**
|
|
86
|
+
* List of errors that occurred during the task processing
|
|
87
|
+
*/
|
|
88
|
+
readonly errors: Array<Error>;
|
|
89
|
+
/**
|
|
90
|
+
* List of warnings that occurred during the task processing
|
|
91
|
+
*/
|
|
92
|
+
readonly warnings: Array<Error>;
|
|
69
93
|
};
|
|
70
94
|
export type Task = ExecutionTask | PreparationTask;
|
|
71
95
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.88.0-
|
|
3
|
+
"version": "0.88.0-8",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.88.0-
|
|
50
|
+
"@promptbook/core": "0.88.0-8"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @generated
|
|
47
47
|
* @see https://github.com/webgptorg/promptbook
|
|
48
48
|
*/
|
|
49
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-8';
|
|
50
50
|
/**
|
|
51
51
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
52
52
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1886,21 +1886,41 @@
|
|
|
1886
1886
|
function createTask(options) {
|
|
1887
1887
|
const { taskType, taskProcessCallback } = options;
|
|
1888
1888
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
1889
|
-
|
|
1889
|
+
let status = 'RUNNING';
|
|
1890
|
+
const createdAt = new Date();
|
|
1891
|
+
let updatedAt = createdAt;
|
|
1892
|
+
const errors = [];
|
|
1893
|
+
const warnings = [];
|
|
1894
|
+
const currentValue = {};
|
|
1895
|
+
const partialResultSubject = new rxjs.Subject();
|
|
1896
|
+
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
1890
1897
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
1898
|
+
Object.assign(currentValue, newOngoingResult);
|
|
1891
1899
|
partialResultSubject.next(newOngoingResult);
|
|
1892
1900
|
});
|
|
1893
1901
|
finalResultPromise
|
|
1894
1902
|
.catch((error) => {
|
|
1903
|
+
errors.push(error);
|
|
1895
1904
|
partialResultSubject.error(error);
|
|
1896
1905
|
})
|
|
1897
|
-
.then((
|
|
1898
|
-
if (
|
|
1906
|
+
.then((executionResult) => {
|
|
1907
|
+
if (executionResult) {
|
|
1899
1908
|
try {
|
|
1900
|
-
|
|
1901
|
-
|
|
1909
|
+
updatedAt = new Date();
|
|
1910
|
+
errors.push(...executionResult.errors);
|
|
1911
|
+
warnings.push(...executionResult.warnings);
|
|
1912
|
+
// <- TODO: !!! Only unique errors and warnings should be added (or filtered)
|
|
1913
|
+
// TODO: [🧠] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
1914
|
+
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
1915
|
+
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
1916
|
+
assertsTaskSuccessful(executionResult);
|
|
1917
|
+
status = 'FINISHED';
|
|
1918
|
+
Object.assign(currentValue, executionResult);
|
|
1919
|
+
partialResultSubject.next(executionResult);
|
|
1902
1920
|
}
|
|
1903
1921
|
catch (error) {
|
|
1922
|
+
status = 'ERROR';
|
|
1923
|
+
errors.push(error);
|
|
1904
1924
|
partialResultSubject.error(error);
|
|
1905
1925
|
}
|
|
1906
1926
|
}
|
|
@@ -1917,12 +1937,33 @@
|
|
|
1917
1937
|
return {
|
|
1918
1938
|
taskType,
|
|
1919
1939
|
taskId,
|
|
1940
|
+
get status() {
|
|
1941
|
+
return status;
|
|
1942
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
1943
|
+
},
|
|
1944
|
+
get createdAt() {
|
|
1945
|
+
return createdAt;
|
|
1946
|
+
// <- Note: [1]
|
|
1947
|
+
},
|
|
1948
|
+
get updatedAt() {
|
|
1949
|
+
return updatedAt;
|
|
1950
|
+
// <- Note: [1]
|
|
1951
|
+
},
|
|
1920
1952
|
asPromise,
|
|
1921
1953
|
asObservable() {
|
|
1922
1954
|
return partialResultSubject.asObservable();
|
|
1923
1955
|
},
|
|
1956
|
+
get errors() {
|
|
1957
|
+
return errors;
|
|
1958
|
+
// <- Note: [1]
|
|
1959
|
+
},
|
|
1960
|
+
get warnings() {
|
|
1961
|
+
return warnings;
|
|
1962
|
+
// <- Note: [1]
|
|
1963
|
+
},
|
|
1924
1964
|
get currentValue() {
|
|
1925
|
-
return
|
|
1965
|
+
return currentValue;
|
|
1966
|
+
// <- Note: [1]
|
|
1926
1967
|
},
|
|
1927
1968
|
};
|
|
1928
1969
|
}
|
|
@@ -3689,7 +3730,7 @@
|
|
|
3689
3730
|
Last result:
|
|
3690
3731
|
${block($ongoingTaskResult.$resultString === null
|
|
3691
3732
|
? 'null'
|
|
3692
|
-
: $ongoingTaskResult.$resultString
|
|
3733
|
+
: spaceTrim.spaceTrim($ongoingTaskResult.$resultString)
|
|
3693
3734
|
.split('\n')
|
|
3694
3735
|
.map((line) => `> ${line}`)
|
|
3695
3736
|
.join('\n'))}
|