@promptbook/pdf 0.89.0-9 โ 0.92.0-3
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/README.md +9 -7
- package/esm/index.es.js +131 -39
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +40 -0
- package/esm/typings/src/_packages/core.index.d.ts +10 -4
- package/esm/typings/src/_packages/types.index.d.ts +18 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/login.d.ts +0 -1
- package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +16 -3
- 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 +10 -19
- package/esm/typings/src/errors/0-index.d.ts +7 -4
- package/esm/typings/src/errors/PipelineExecutionError.d.ts +1 -1
- package/esm/typings/src/errors/WrappedError.d.ts +10 -0
- package/esm/typings/src/errors/assertsError.d.ts +11 -0
- package/esm/typings/src/execution/PromptbookFetch.d.ts +1 -1
- package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +9 -0
- package/esm/typings/src/formats/csv/utils/isValidCsvString.test.d.ts +1 -0
- package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +3 -0
- package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +9 -0
- package/esm/typings/src/formats/xml/utils/isValidXmlString.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/_common/filterModels.d.ts +15 -0
- package/esm/typings/src/llm-providers/_common/register/{$provideEnvFilepath.d.ts โ $provideEnvFilename.d.ts} +2 -2
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +11 -2
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
- package/esm/typings/src/remote-server/openapi-types.d.ts +284 -0
- package/esm/typings/src/remote-server/openapi.d.ts +187 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/Identification.d.ts +7 -1
- package/esm/typings/src/remote-server/socket-types/_subtypes/identificationToPromptbookToken.d.ts +11 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/promptbookTokenToIdentification.d.ts +10 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -2
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +15 -9
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +40 -0
- package/esm/typings/src/types/typeAliases.d.ts +26 -0
- package/package.json +9 -5
- package/umd/index.umd.js +131 -39
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/cli/test/ptbk2.d.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/pdf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.92.0-3",
|
|
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,
|
|
@@ -43,19 +43,23 @@
|
|
|
43
43
|
"url": "https://github.com/webgptorg/promptbook/issues"
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://ptbk.io/",
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=16.0.0",
|
|
48
|
+
"npm": ">=8.0.0"
|
|
49
|
+
},
|
|
46
50
|
"main": "./umd/index.umd.js",
|
|
47
51
|
"module": "./esm/index.es.js",
|
|
48
52
|
"typings": "./esm/typings/src/_packages/pdf.index.d.ts",
|
|
49
53
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.
|
|
54
|
+
"@promptbook/core": "0.92.0-3"
|
|
51
55
|
},
|
|
52
56
|
"dependencies": {
|
|
53
|
-
"crypto": "
|
|
57
|
+
"crypto": "1.0.1",
|
|
54
58
|
"crypto-js": "4.2.0",
|
|
55
|
-
"markitdown-ts": "
|
|
59
|
+
"markitdown-ts": "0.0.4",
|
|
56
60
|
"papaparse": "5.4.1",
|
|
57
61
|
"prettier": "2.8.1",
|
|
58
|
-
"rxjs": "
|
|
62
|
+
"rxjs": "7.8.1",
|
|
59
63
|
"spacetrim": "0.11.59",
|
|
60
64
|
"waitasecond": "1.11.83"
|
|
61
65
|
}
|
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-3';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
* @public exported from `@promptbook/core`
|
|
89
89
|
*/
|
|
90
90
|
const ADMIN_GITHUB_NAME = 'hejny';
|
|
91
|
+
// <- TODO: [๐] Pick the best claim
|
|
91
92
|
/**
|
|
92
93
|
* When the title is not provided, the default title is used
|
|
93
94
|
*
|
|
@@ -120,6 +121,7 @@
|
|
|
120
121
|
infinity: '(infinity; โ)',
|
|
121
122
|
negativeInfinity: '(negative infinity; -โ)',
|
|
122
123
|
unserializable: '(unserializable value)',
|
|
124
|
+
circular: '(circular JSON)',
|
|
123
125
|
};
|
|
124
126
|
/**
|
|
125
127
|
* Small number limit
|
|
@@ -159,7 +161,7 @@
|
|
|
159
161
|
*/
|
|
160
162
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐คนโโ๏ธ]
|
|
161
163
|
// <- TODO: [๐] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
162
|
-
// TODO:
|
|
164
|
+
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
163
165
|
/**
|
|
164
166
|
* Where to store the temporary downloads
|
|
165
167
|
*
|
|
@@ -890,9 +892,60 @@
|
|
|
890
892
|
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
891
893
|
*/
|
|
892
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.spaceTrim(`
|
|
905
|
+
Non-Error object was thrown
|
|
906
|
+
|
|
907
|
+
Note: Look for ${tag} in the console for more details
|
|
908
|
+
Please report issue on ${ADMIN_EMAIL}
|
|
909
|
+
`));
|
|
910
|
+
this.name = 'WrappedError';
|
|
911
|
+
Object.setPrototypeOf(this, WrappedError.prototype);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Helper used in catch blocks to assert that the error is an instance of `Error`
|
|
917
|
+
*
|
|
918
|
+
* @param whatWasThrown Any object that was thrown
|
|
919
|
+
* @returns Nothing if the error is an instance of `Error`
|
|
920
|
+
* @throws `WrappedError` or `UnexpectedError` if the error is not standard
|
|
921
|
+
*
|
|
922
|
+
* @private within the repository
|
|
923
|
+
*/
|
|
924
|
+
function assertsError(whatWasThrown) {
|
|
925
|
+
// Case 1: Handle error which was rethrown as `WrappedError`
|
|
926
|
+
if (whatWasThrown instanceof WrappedError) {
|
|
927
|
+
const wrappedError = whatWasThrown;
|
|
928
|
+
throw wrappedError;
|
|
929
|
+
}
|
|
930
|
+
// Case 2: Handle unexpected errors
|
|
931
|
+
if (whatWasThrown instanceof UnexpectedError) {
|
|
932
|
+
const unexpectedError = whatWasThrown;
|
|
933
|
+
throw unexpectedError;
|
|
934
|
+
}
|
|
935
|
+
// Case 3: Handle standard errors - keep them up to consumer
|
|
936
|
+
if (whatWasThrown instanceof Error) {
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
// Case 4: Handle non-standard errors - wrap them into `WrappedError` and throw
|
|
940
|
+
throw new WrappedError(whatWasThrown);
|
|
941
|
+
}
|
|
942
|
+
|
|
893
943
|
/**
|
|
894
944
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
895
945
|
*
|
|
946
|
+
* @param value The string to check
|
|
947
|
+
* @returns True if the string is a valid JSON string, false otherwise
|
|
948
|
+
*
|
|
896
949
|
* @public exported from `@promptbook/utils`
|
|
897
950
|
*/
|
|
898
951
|
function isValidJsonString(value /* <- [๐จโโ๏ธ] */) {
|
|
@@ -901,9 +954,7 @@
|
|
|
901
954
|
return true;
|
|
902
955
|
}
|
|
903
956
|
catch (error) {
|
|
904
|
-
|
|
905
|
-
throw error;
|
|
906
|
-
}
|
|
957
|
+
assertsError(error);
|
|
907
958
|
if (error.message.includes('Unexpected token')) {
|
|
908
959
|
return false;
|
|
909
960
|
}
|
|
@@ -1256,9 +1307,7 @@
|
|
|
1256
1307
|
JSON.stringify(value); // <- TODO: [0]
|
|
1257
1308
|
}
|
|
1258
1309
|
catch (error) {
|
|
1259
|
-
|
|
1260
|
-
throw error;
|
|
1261
|
-
}
|
|
1310
|
+
assertsError(error);
|
|
1262
1311
|
throw new UnexpectedError(spaceTrim__default["default"]((block) => `
|
|
1263
1312
|
\`${name}\` is not serializable
|
|
1264
1313
|
|
|
@@ -2047,7 +2096,7 @@
|
|
|
2047
2096
|
}
|
|
2048
2097
|
}
|
|
2049
2098
|
/**
|
|
2050
|
-
* TODO:
|
|
2099
|
+
* TODO: [๐ง ][๐] Add id to all errors
|
|
2051
2100
|
*/
|
|
2052
2101
|
|
|
2053
2102
|
/**
|
|
@@ -2258,7 +2307,10 @@
|
|
|
2258
2307
|
PipelineExecutionError,
|
|
2259
2308
|
PipelineLogicError,
|
|
2260
2309
|
PipelineUrlError,
|
|
2310
|
+
AuthenticationError,
|
|
2311
|
+
PromptbookFetchError,
|
|
2261
2312
|
UnexpectedError,
|
|
2313
|
+
WrappedError,
|
|
2262
2314
|
// TODO: [๐ช]> VersionMismatchError,
|
|
2263
2315
|
};
|
|
2264
2316
|
/**
|
|
@@ -2275,8 +2327,6 @@
|
|
|
2275
2327
|
TypeError,
|
|
2276
2328
|
URIError,
|
|
2277
2329
|
AggregateError,
|
|
2278
|
-
AuthenticationError,
|
|
2279
|
-
PromptbookFetchError,
|
|
2280
2330
|
/*
|
|
2281
2331
|
Note: Not widely supported
|
|
2282
2332
|
> InternalError,
|
|
@@ -2399,8 +2449,8 @@
|
|
|
2399
2449
|
updatedAt = new Date();
|
|
2400
2450
|
errors.push(...executionResult.errors);
|
|
2401
2451
|
warnings.push(...executionResult.warnings);
|
|
2402
|
-
// <- TODO:
|
|
2403
|
-
// TODO: [๐ง ]
|
|
2452
|
+
// <- TODO: [๐] Only unique errors and warnings should be added (or filtered)
|
|
2453
|
+
// TODO: [๐ง ] !! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
2404
2454
|
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
2405
2455
|
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2406
2456
|
assertsTaskSuccessful(executionResult);
|
|
@@ -2410,6 +2460,7 @@
|
|
|
2410
2460
|
partialResultSubject.next(executionResult);
|
|
2411
2461
|
}
|
|
2412
2462
|
catch (error) {
|
|
2463
|
+
assertsError(error);
|
|
2413
2464
|
status = 'ERROR';
|
|
2414
2465
|
errors.push(error);
|
|
2415
2466
|
partialResultSubject.error(error);
|
|
@@ -2801,14 +2852,15 @@
|
|
|
2801
2852
|
}
|
|
2802
2853
|
}
|
|
2803
2854
|
catch (error) {
|
|
2804
|
-
|
|
2855
|
+
assertsError(error);
|
|
2856
|
+
if (error instanceof UnexpectedError) {
|
|
2805
2857
|
throw error;
|
|
2806
2858
|
}
|
|
2807
2859
|
errors.push({ llmExecutionTools, error });
|
|
2808
2860
|
}
|
|
2809
2861
|
}
|
|
2810
2862
|
if (errors.length === 1) {
|
|
2811
|
-
throw errors[0];
|
|
2863
|
+
throw errors[0].error;
|
|
2812
2864
|
}
|
|
2813
2865
|
else if (errors.length > 1) {
|
|
2814
2866
|
throw new PipelineExecutionError(
|
|
@@ -3263,9 +3315,7 @@
|
|
|
3263
3315
|
return await fetch(urlOrRequest, init);
|
|
3264
3316
|
}
|
|
3265
3317
|
catch (error) {
|
|
3266
|
-
|
|
3267
|
-
throw error;
|
|
3268
|
-
}
|
|
3318
|
+
assertsError(error);
|
|
3269
3319
|
let url;
|
|
3270
3320
|
if (typeof urlOrRequest === 'string') {
|
|
3271
3321
|
url = urlOrRequest;
|
|
@@ -3496,9 +3546,7 @@
|
|
|
3496
3546
|
knowledgePreparedUnflatten[index] = pieces;
|
|
3497
3547
|
}
|
|
3498
3548
|
catch (error) {
|
|
3499
|
-
|
|
3500
|
-
throw error;
|
|
3501
|
-
}
|
|
3549
|
+
assertsError(error);
|
|
3502
3550
|
console.warn(error);
|
|
3503
3551
|
// <- TODO: [๐ฎ] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3504
3552
|
}
|
|
@@ -3790,13 +3838,19 @@
|
|
|
3790
3838
|
return value.toISOString();
|
|
3791
3839
|
}
|
|
3792
3840
|
else {
|
|
3793
|
-
|
|
3841
|
+
try {
|
|
3842
|
+
return JSON.stringify(value);
|
|
3843
|
+
}
|
|
3844
|
+
catch (error) {
|
|
3845
|
+
if (error instanceof TypeError && error.message.includes('circular structure')) {
|
|
3846
|
+
return VALUE_STRINGS.circular;
|
|
3847
|
+
}
|
|
3848
|
+
throw error;
|
|
3849
|
+
}
|
|
3794
3850
|
}
|
|
3795
3851
|
}
|
|
3796
3852
|
catch (error) {
|
|
3797
|
-
|
|
3798
|
-
throw error;
|
|
3799
|
-
}
|
|
3853
|
+
assertsError(error);
|
|
3800
3854
|
console.error(error);
|
|
3801
3855
|
return VALUE_STRINGS.unserializable;
|
|
3802
3856
|
}
|
|
@@ -3853,9 +3907,7 @@
|
|
|
3853
3907
|
}
|
|
3854
3908
|
}
|
|
3855
3909
|
catch (error) {
|
|
3856
|
-
|
|
3857
|
-
throw error;
|
|
3858
|
-
}
|
|
3910
|
+
assertsError(error);
|
|
3859
3911
|
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
3860
3912
|
Can not extract variables from the script
|
|
3861
3913
|
${block(error.stack || error.message)}
|
|
@@ -3974,6 +4026,28 @@
|
|
|
3974
4026
|
// encoding: 'utf-8',
|
|
3975
4027
|
});
|
|
3976
4028
|
|
|
4029
|
+
/**
|
|
4030
|
+
* Function to check if a string is valid CSV
|
|
4031
|
+
*
|
|
4032
|
+
* @param value The string to check
|
|
4033
|
+
* @returns True if the string is a valid CSV string, false otherwise
|
|
4034
|
+
*
|
|
4035
|
+
* @public exported from `@promptbook/utils`
|
|
4036
|
+
*/
|
|
4037
|
+
function isValidCsvString(value) {
|
|
4038
|
+
try {
|
|
4039
|
+
// A simple check for CSV format: at least one comma and no invalid characters
|
|
4040
|
+
if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
|
|
4041
|
+
return true;
|
|
4042
|
+
}
|
|
4043
|
+
return false;
|
|
4044
|
+
}
|
|
4045
|
+
catch (error) {
|
|
4046
|
+
assertsError(error);
|
|
4047
|
+
return false;
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4050
|
+
|
|
3977
4051
|
/**
|
|
3978
4052
|
* Definition for CSV spreadsheet
|
|
3979
4053
|
*
|
|
@@ -3984,7 +4058,7 @@
|
|
|
3984
4058
|
formatName: 'CSV',
|
|
3985
4059
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
3986
4060
|
isValid(value, settings, schema) {
|
|
3987
|
-
return
|
|
4061
|
+
return isValidCsvString(value);
|
|
3988
4062
|
},
|
|
3989
4063
|
canBeValid(partialValue, settings, schema) {
|
|
3990
4064
|
return true;
|
|
@@ -4138,6 +4212,30 @@
|
|
|
4138
4212
|
* TODO: [๐ข] Allow to expect something inside each item of list and other formats
|
|
4139
4213
|
*/
|
|
4140
4214
|
|
|
4215
|
+
/**
|
|
4216
|
+
* Function to check if a string is valid XML
|
|
4217
|
+
*
|
|
4218
|
+
* @param value
|
|
4219
|
+
* @returns True if the string is a valid XML string, false otherwise
|
|
4220
|
+
*
|
|
4221
|
+
* @public exported from `@promptbook/utils`
|
|
4222
|
+
*/
|
|
4223
|
+
function isValidXmlString(value) {
|
|
4224
|
+
try {
|
|
4225
|
+
const parser = new DOMParser();
|
|
4226
|
+
const parsedDocument = parser.parseFromString(value, 'application/xml');
|
|
4227
|
+
const parserError = parsedDocument.getElementsByTagName('parsererror');
|
|
4228
|
+
if (parserError.length > 0) {
|
|
4229
|
+
return false;
|
|
4230
|
+
}
|
|
4231
|
+
return true;
|
|
4232
|
+
}
|
|
4233
|
+
catch (error) {
|
|
4234
|
+
assertsError(error);
|
|
4235
|
+
return false;
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
|
|
4141
4239
|
/**
|
|
4142
4240
|
* Definition for XML format
|
|
4143
4241
|
*
|
|
@@ -4147,7 +4245,7 @@
|
|
|
4147
4245
|
formatName: 'XML',
|
|
4148
4246
|
mimeType: 'application/xml',
|
|
4149
4247
|
isValid(value, settings, schema) {
|
|
4150
|
-
return
|
|
4248
|
+
return isValidXmlString(value);
|
|
4151
4249
|
},
|
|
4152
4250
|
canBeValid(partialValue, settings, schema) {
|
|
4153
4251
|
return true;
|
|
@@ -4720,9 +4818,7 @@
|
|
|
4720
4818
|
break scripts;
|
|
4721
4819
|
}
|
|
4722
4820
|
catch (error) {
|
|
4723
|
-
|
|
4724
|
-
throw error;
|
|
4725
|
-
}
|
|
4821
|
+
assertsError(error);
|
|
4726
4822
|
if (error instanceof UnexpectedError) {
|
|
4727
4823
|
throw error;
|
|
4728
4824
|
}
|
|
@@ -4792,9 +4888,7 @@
|
|
|
4792
4888
|
break scripts;
|
|
4793
4889
|
}
|
|
4794
4890
|
catch (error) {
|
|
4795
|
-
|
|
4796
|
-
throw error;
|
|
4797
|
-
}
|
|
4891
|
+
assertsError(error);
|
|
4798
4892
|
if (error instanceof UnexpectedError) {
|
|
4799
4893
|
throw error;
|
|
4800
4894
|
}
|
|
@@ -5415,9 +5509,7 @@
|
|
|
5415
5509
|
await Promise.all(resolving);
|
|
5416
5510
|
}
|
|
5417
5511
|
catch (error /* <- Note: [3] */) {
|
|
5418
|
-
|
|
5419
|
-
throw error;
|
|
5420
|
-
}
|
|
5512
|
+
assertsError(error);
|
|
5421
5513
|
// Note: No need to rethrow UnexpectedError
|
|
5422
5514
|
// if (error instanceof UnexpectedError) {
|
|
5423
5515
|
// Note: Count usage, [๐ง ] Maybe put to separate function executionReportJsonToUsage + DRY [๐คนโโ๏ธ]
|