@promptbook/cli 0.89.0-7 → 0.89.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
CHANGED
|
@@ -46,7 +46,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
46
46
|
* @generated
|
|
47
47
|
* @see https://github.com/webgptorg/promptbook
|
|
48
48
|
*/
|
|
49
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.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
|
|
@@ -919,50 +919,6 @@ function $sideEffect(...sideEffectSubjects) {
|
|
|
919
919
|
keepUnused(...sideEffectSubjects);
|
|
920
920
|
}
|
|
921
921
|
|
|
922
|
-
/**
|
|
923
|
-
* Checks if value is valid email
|
|
924
|
-
*
|
|
925
|
-
* @public exported from `@promptbook/utils`
|
|
926
|
-
*/
|
|
927
|
-
function isValidEmail(email) {
|
|
928
|
-
if (typeof email !== 'string') {
|
|
929
|
-
return false;
|
|
930
|
-
}
|
|
931
|
-
if (email.split('\n').length > 1) {
|
|
932
|
-
return false;
|
|
933
|
-
}
|
|
934
|
-
return /^.+@.+\..+$/.test(email);
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
/**
|
|
938
|
-
* Tests if given string is valid URL.
|
|
939
|
-
*
|
|
940
|
-
* Note: Dataurl are considered perfectly valid.
|
|
941
|
-
* Note: There are two simmilar functions:
|
|
942
|
-
* - `isValidUrl` which tests any URL
|
|
943
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
944
|
-
*
|
|
945
|
-
* @public exported from `@promptbook/utils`
|
|
946
|
-
*/
|
|
947
|
-
function isValidUrl(url) {
|
|
948
|
-
if (typeof url !== 'string') {
|
|
949
|
-
return false;
|
|
950
|
-
}
|
|
951
|
-
try {
|
|
952
|
-
if (url.startsWith('blob:')) {
|
|
953
|
-
url = url.replace(/^blob:/, '');
|
|
954
|
-
}
|
|
955
|
-
const urlObject = new URL(url /* because fail is handled */);
|
|
956
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
957
|
-
return false;
|
|
958
|
-
}
|
|
959
|
-
return true;
|
|
960
|
-
}
|
|
961
|
-
catch (error) {
|
|
962
|
-
return false;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
|
|
966
922
|
/**
|
|
967
923
|
* Stores data in memory (HEAP)
|
|
968
924
|
*
|
|
@@ -1504,6 +1460,35 @@ function isValidFilePath(filename) {
|
|
|
1504
1460
|
* TODO: [🍏] Implement for MacOs
|
|
1505
1461
|
*/
|
|
1506
1462
|
|
|
1463
|
+
/**
|
|
1464
|
+
* Tests if given string is valid URL.
|
|
1465
|
+
*
|
|
1466
|
+
* Note: Dataurl are considered perfectly valid.
|
|
1467
|
+
* Note: There are two simmilar functions:
|
|
1468
|
+
* - `isValidUrl` which tests any URL
|
|
1469
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
1470
|
+
*
|
|
1471
|
+
* @public exported from `@promptbook/utils`
|
|
1472
|
+
*/
|
|
1473
|
+
function isValidUrl(url) {
|
|
1474
|
+
if (typeof url !== 'string') {
|
|
1475
|
+
return false;
|
|
1476
|
+
}
|
|
1477
|
+
try {
|
|
1478
|
+
if (url.startsWith('blob:')) {
|
|
1479
|
+
url = url.replace(/^blob:/, '');
|
|
1480
|
+
}
|
|
1481
|
+
const urlObject = new URL(url /* because fail is handled */);
|
|
1482
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
1483
|
+
return false;
|
|
1484
|
+
}
|
|
1485
|
+
return true;
|
|
1486
|
+
}
|
|
1487
|
+
catch (error) {
|
|
1488
|
+
return false;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1507
1492
|
const defaultDiacriticsRemovalMap = [
|
|
1508
1493
|
{
|
|
1509
1494
|
base: 'A',
|
|
@@ -3056,6 +3041,21 @@ async function $provideLlmToolsForWizzardOrCli(options) {
|
|
|
3056
3041
|
* TODO: [®] DRY Register logic
|
|
3057
3042
|
*/
|
|
3058
3043
|
|
|
3044
|
+
/**
|
|
3045
|
+
* Checks if value is valid email
|
|
3046
|
+
*
|
|
3047
|
+
* @public exported from `@promptbook/utils`
|
|
3048
|
+
*/
|
|
3049
|
+
function isValidEmail(email) {
|
|
3050
|
+
if (typeof email !== 'string') {
|
|
3051
|
+
return false;
|
|
3052
|
+
}
|
|
3053
|
+
if (email.split('\n').length > 1) {
|
|
3054
|
+
return false;
|
|
3055
|
+
}
|
|
3056
|
+
return /^.+@.+\..+$/.test(email);
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
3059
|
/**
|
|
3060
3060
|
* @private utility of CLI
|
|
3061
3061
|
*/
|
|
@@ -3127,12 +3127,25 @@ function $provideLlmToolsForCli(options) {
|
|
|
3127
3127
|
// type: response.type,
|
|
3128
3128
|
// text: await response.text(),
|
|
3129
3129
|
});
|
|
3130
|
-
const
|
|
3131
|
-
if (
|
|
3132
|
-
|
|
3130
|
+
const { isSuccess, message, error, identification } = (await response.json());
|
|
3131
|
+
if (message) {
|
|
3132
|
+
if (isSuccess) {
|
|
3133
|
+
console.log(colors.green(message));
|
|
3134
|
+
}
|
|
3135
|
+
else {
|
|
3136
|
+
console.log(colors.red(message));
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
if (!isSuccess) {
|
|
3140
|
+
// Note: Login failed
|
|
3133
3141
|
process.exit(1);
|
|
3134
3142
|
}
|
|
3135
|
-
|
|
3143
|
+
if (!identification) {
|
|
3144
|
+
// Note: Do not get identification here, but server signalizes the success so exiting but with code 0
|
|
3145
|
+
// This can mean for example that user needs to verify email
|
|
3146
|
+
process.exit(0);
|
|
3147
|
+
}
|
|
3148
|
+
return identification;
|
|
3136
3149
|
},
|
|
3137
3150
|
});
|
|
3138
3151
|
}
|
|
@@ -13086,8 +13099,19 @@ function startRemoteServer(options) {
|
|
|
13086
13099
|
const username = request.body.username;
|
|
13087
13100
|
const password = request.body.password;
|
|
13088
13101
|
const appId = request.body.appId;
|
|
13089
|
-
const identification = await login({
|
|
13090
|
-
|
|
13102
|
+
const { isSuccess, error, message, identification } = await login({
|
|
13103
|
+
username,
|
|
13104
|
+
password,
|
|
13105
|
+
appId,
|
|
13106
|
+
rawRequest: request,
|
|
13107
|
+
rawResponse: response,
|
|
13108
|
+
});
|
|
13109
|
+
response.status(201).send({
|
|
13110
|
+
isSuccess,
|
|
13111
|
+
message,
|
|
13112
|
+
error: error ? serializeError(error) : undefined,
|
|
13113
|
+
identification,
|
|
13114
|
+
});
|
|
13091
13115
|
return;
|
|
13092
13116
|
}
|
|
13093
13117
|
catch (error) {
|
|
@@ -13095,7 +13119,11 @@ function startRemoteServer(options) {
|
|
|
13095
13119
|
throw error;
|
|
13096
13120
|
}
|
|
13097
13121
|
if (error instanceof AuthenticationError) {
|
|
13098
|
-
response.status(401).send({
|
|
13122
|
+
response.status(401).send({
|
|
13123
|
+
isSuccess: false,
|
|
13124
|
+
message: error.message,
|
|
13125
|
+
error: serializeError(error),
|
|
13126
|
+
});
|
|
13099
13127
|
}
|
|
13100
13128
|
console.warn(`Login function thrown different error than AuthenticationError`, {
|
|
13101
13129
|
error,
|