@promptbook/pdf 0.89.0-11 โ 0.89.0-13
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 +77 -33
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -0
- package/esm/typings/src/config.d.ts +1 -0
- package/esm/typings/src/errors/0-index.d.ts +7 -4
- package/esm/typings/src/errors/WrappedError.d.ts +10 -0
- package/esm/typings/src/errors/assertsError.d.ts +10 -0
- package/esm/typings/src/execution/PromptbookFetch.d.ts +1 -1
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +0 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +16 -1
- package/package.json +2 -2
- package/umd/index.umd.js +77 -33
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/cli/test/ptbk2.d.ts +0 -5
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-13';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -121,6 +121,7 @@ const VALUE_STRINGS = {
|
|
|
121
121
|
infinity: '(infinity; โ)',
|
|
122
122
|
negativeInfinity: '(negative infinity; -โ)',
|
|
123
123
|
unserializable: '(unserializable value)',
|
|
124
|
+
circular: '(circular JSON)',
|
|
124
125
|
};
|
|
125
126
|
/**
|
|
126
127
|
* Small number limit
|
|
@@ -891,6 +892,56 @@ class ParseError extends Error {
|
|
|
891
892
|
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
892
893
|
*/
|
|
893
894
|
|
|
895
|
+
/**
|
|
896
|
+
* This error type indicates that somewhere in the code non-Error object was thrown and it was wrapped into the `WrappedError`
|
|
897
|
+
*
|
|
898
|
+
* @public exported from `@promptbook/core`
|
|
899
|
+
*/
|
|
900
|
+
class WrappedError extends Error {
|
|
901
|
+
constructor(whatWasThrown) {
|
|
902
|
+
const tag = `[๐คฎ]`;
|
|
903
|
+
console.error(tag, whatWasThrown);
|
|
904
|
+
super(spaceTrim$1((block) => `
|
|
905
|
+
${ /* Fixing tests !!! block(valueToString(whatWasThrown)) */block(`non-Error object was thrown`)}
|
|
906
|
+
|
|
907
|
+
Note: Look for ${tag} in the console for more details
|
|
908
|
+
!!! Note: \`WrappedError\` indicates that somewhere in the code non-Error object was thrown and it was wrapped
|
|
909
|
+
|
|
910
|
+
Please report issue on ${ADMIN_EMAIL}
|
|
911
|
+
|
|
912
|
+
`));
|
|
913
|
+
this.name = 'WrappedError';
|
|
914
|
+
Object.setPrototypeOf(this, WrappedError.prototype);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* !!!@@@
|
|
920
|
+
*
|
|
921
|
+
* @param whatWasThrown !!!@@@
|
|
922
|
+
* @returns !!!@@@
|
|
923
|
+
*
|
|
924
|
+
* @private within the repository
|
|
925
|
+
*/
|
|
926
|
+
function assertsError(whatWasThrown) {
|
|
927
|
+
// Case 1: !!!@@@
|
|
928
|
+
if (whatWasThrown instanceof WrappedError) {
|
|
929
|
+
const wrappedError = whatWasThrown;
|
|
930
|
+
throw wrappedError;
|
|
931
|
+
}
|
|
932
|
+
// Case 2: !!!@@@
|
|
933
|
+
if (whatWasThrown instanceof UnexpectedError) {
|
|
934
|
+
const unexpectedError = whatWasThrown;
|
|
935
|
+
throw unexpectedError;
|
|
936
|
+
}
|
|
937
|
+
// Case 3: !!!@@@
|
|
938
|
+
if (whatWasThrown instanceof Error) {
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
// Case 4: !!!@@@
|
|
942
|
+
throw new WrappedError(whatWasThrown);
|
|
943
|
+
}
|
|
944
|
+
|
|
894
945
|
/**
|
|
895
946
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
896
947
|
*
|
|
@@ -902,9 +953,7 @@ function isValidJsonString(value /* <- [๐จโโ๏ธ] */) {
|
|
|
902
953
|
return true;
|
|
903
954
|
}
|
|
904
955
|
catch (error) {
|
|
905
|
-
|
|
906
|
-
throw error;
|
|
907
|
-
}
|
|
956
|
+
assertsError(error);
|
|
908
957
|
if (error.message.includes('Unexpected token')) {
|
|
909
958
|
return false;
|
|
910
959
|
}
|
|
@@ -1257,9 +1306,7 @@ function checkSerializableAsJson(options) {
|
|
|
1257
1306
|
JSON.stringify(value); // <- TODO: [0]
|
|
1258
1307
|
}
|
|
1259
1308
|
catch (error) {
|
|
1260
|
-
|
|
1261
|
-
throw error;
|
|
1262
|
-
}
|
|
1309
|
+
assertsError(error);
|
|
1263
1310
|
throw new UnexpectedError(spaceTrim((block) => `
|
|
1264
1311
|
\`${name}\` is not serializable
|
|
1265
1312
|
|
|
@@ -2259,7 +2306,10 @@ const PROMPTBOOK_ERRORS = {
|
|
|
2259
2306
|
PipelineExecutionError,
|
|
2260
2307
|
PipelineLogicError,
|
|
2261
2308
|
PipelineUrlError,
|
|
2309
|
+
AuthenticationError,
|
|
2310
|
+
PromptbookFetchError,
|
|
2262
2311
|
UnexpectedError,
|
|
2312
|
+
WrappedError,
|
|
2263
2313
|
// TODO: [๐ช]> VersionMismatchError,
|
|
2264
2314
|
};
|
|
2265
2315
|
/**
|
|
@@ -2276,8 +2326,6 @@ const COMMON_JAVASCRIPT_ERRORS = {
|
|
|
2276
2326
|
TypeError,
|
|
2277
2327
|
URIError,
|
|
2278
2328
|
AggregateError,
|
|
2279
|
-
AuthenticationError,
|
|
2280
|
-
PromptbookFetchError,
|
|
2281
2329
|
/*
|
|
2282
2330
|
Note: Not widely supported
|
|
2283
2331
|
> InternalError,
|
|
@@ -2411,6 +2459,7 @@ function createTask(options) {
|
|
|
2411
2459
|
partialResultSubject.next(executionResult);
|
|
2412
2460
|
}
|
|
2413
2461
|
catch (error) {
|
|
2462
|
+
assertsError(error);
|
|
2414
2463
|
status = 'ERROR';
|
|
2415
2464
|
errors.push(error);
|
|
2416
2465
|
partialResultSubject.error(error);
|
|
@@ -2802,14 +2851,15 @@ class MultipleLlmExecutionTools {
|
|
|
2802
2851
|
}
|
|
2803
2852
|
}
|
|
2804
2853
|
catch (error) {
|
|
2805
|
-
|
|
2854
|
+
assertsError(error);
|
|
2855
|
+
if (error instanceof UnexpectedError) {
|
|
2806
2856
|
throw error;
|
|
2807
2857
|
}
|
|
2808
2858
|
errors.push({ llmExecutionTools, error });
|
|
2809
2859
|
}
|
|
2810
2860
|
}
|
|
2811
2861
|
if (errors.length === 1) {
|
|
2812
|
-
throw errors[0];
|
|
2862
|
+
throw errors[0].error;
|
|
2813
2863
|
}
|
|
2814
2864
|
else if (errors.length > 1) {
|
|
2815
2865
|
throw new PipelineExecutionError(
|
|
@@ -3264,9 +3314,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
3264
3314
|
return await fetch(urlOrRequest, init);
|
|
3265
3315
|
}
|
|
3266
3316
|
catch (error) {
|
|
3267
|
-
|
|
3268
|
-
throw error;
|
|
3269
|
-
}
|
|
3317
|
+
assertsError(error);
|
|
3270
3318
|
let url;
|
|
3271
3319
|
if (typeof urlOrRequest === 'string') {
|
|
3272
3320
|
url = urlOrRequest;
|
|
@@ -3497,9 +3545,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3497
3545
|
knowledgePreparedUnflatten[index] = pieces;
|
|
3498
3546
|
}
|
|
3499
3547
|
catch (error) {
|
|
3500
|
-
|
|
3501
|
-
throw error;
|
|
3502
|
-
}
|
|
3548
|
+
assertsError(error);
|
|
3503
3549
|
console.warn(error);
|
|
3504
3550
|
// <- TODO: [๐ฎ] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3505
3551
|
}
|
|
@@ -3791,13 +3837,19 @@ function valueToString(value) {
|
|
|
3791
3837
|
return value.toISOString();
|
|
3792
3838
|
}
|
|
3793
3839
|
else {
|
|
3794
|
-
|
|
3840
|
+
try {
|
|
3841
|
+
return JSON.stringify(value);
|
|
3842
|
+
}
|
|
3843
|
+
catch (error) {
|
|
3844
|
+
if (error instanceof TypeError && error.message.includes('circular structure')) {
|
|
3845
|
+
return VALUE_STRINGS.circular;
|
|
3846
|
+
}
|
|
3847
|
+
throw error;
|
|
3848
|
+
}
|
|
3795
3849
|
}
|
|
3796
3850
|
}
|
|
3797
3851
|
catch (error) {
|
|
3798
|
-
|
|
3799
|
-
throw error;
|
|
3800
|
-
}
|
|
3852
|
+
assertsError(error);
|
|
3801
3853
|
console.error(error);
|
|
3802
3854
|
return VALUE_STRINGS.unserializable;
|
|
3803
3855
|
}
|
|
@@ -3854,9 +3906,7 @@ function extractVariablesFromJavascript(script) {
|
|
|
3854
3906
|
}
|
|
3855
3907
|
}
|
|
3856
3908
|
catch (error) {
|
|
3857
|
-
|
|
3858
|
-
throw error;
|
|
3859
|
-
}
|
|
3909
|
+
assertsError(error);
|
|
3860
3910
|
throw new ParseError(spaceTrim$1((block) => `
|
|
3861
3911
|
Can not extract variables from the script
|
|
3862
3912
|
${block(error.stack || error.message)}
|
|
@@ -4721,9 +4771,7 @@ async function executeAttempts(options) {
|
|
|
4721
4771
|
break scripts;
|
|
4722
4772
|
}
|
|
4723
4773
|
catch (error) {
|
|
4724
|
-
|
|
4725
|
-
throw error;
|
|
4726
|
-
}
|
|
4774
|
+
assertsError(error);
|
|
4727
4775
|
if (error instanceof UnexpectedError) {
|
|
4728
4776
|
throw error;
|
|
4729
4777
|
}
|
|
@@ -4793,9 +4841,7 @@ async function executeAttempts(options) {
|
|
|
4793
4841
|
break scripts;
|
|
4794
4842
|
}
|
|
4795
4843
|
catch (error) {
|
|
4796
|
-
|
|
4797
|
-
throw error;
|
|
4798
|
-
}
|
|
4844
|
+
assertsError(error);
|
|
4799
4845
|
if (error instanceof UnexpectedError) {
|
|
4800
4846
|
throw error;
|
|
4801
4847
|
}
|
|
@@ -5416,9 +5462,7 @@ async function executePipeline(options) {
|
|
|
5416
5462
|
await Promise.all(resolving);
|
|
5417
5463
|
}
|
|
5418
5464
|
catch (error /* <- Note: [3] */) {
|
|
5419
|
-
|
|
5420
|
-
throw error;
|
|
5421
|
-
}
|
|
5465
|
+
assertsError(error);
|
|
5422
5466
|
// Note: No need to rethrow UnexpectedError
|
|
5423
5467
|
// if (error instanceof UnexpectedError) {
|
|
5424
5468
|
// Note: Count usage, [๐ง ] Maybe put to separate function executionReportJsonToUsage + DRY [๐คนโโ๏ธ]
|