@promptbook/remote-server 0.89.0-6 โ 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 +110 -14
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +8 -4
- package/esm/typings/src/_packages/remote-client.index.d.ts +0 -2
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +7 -0
- package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +15 -0
- package/esm/typings/src/config.d.ts +15 -8
- package/esm/typings/src/errors/0-index.d.ts +3 -0
- package/esm/typings/src/errors/AuthenticationError.d.ts +9 -0
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +34 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -1
- package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +2 -10
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +60 -3
- package/package.json +2 -2
- package/umd/index.umd.js +110 -14
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
33
33
|
* @generated
|
|
34
34
|
* @see https://github.com/webgptorg/promptbook
|
|
35
35
|
*/
|
|
36
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
36
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-8';
|
|
37
37
|
/**
|
|
38
38
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
39
39
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -158,6 +158,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐คนโโ๏ธ]
|
|
|
158
158
|
*/
|
|
159
159
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐คนโโ๏ธ]
|
|
160
160
|
// <- TODO: [๐] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
161
|
+
// TODO: !!!!!! Just .promptbook dir, hardocode others
|
|
161
162
|
/**
|
|
162
163
|
* Where to store the temporary downloads
|
|
163
164
|
*
|
|
@@ -209,9 +210,22 @@ const IS_PIPELINE_LOGIC_VALIDATED = just(
|
|
|
209
210
|
true);
|
|
210
211
|
/**
|
|
211
212
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
212
|
-
* TODO: [๐ง ][๐งโโ๏ธ] Maybe join
|
|
213
|
+
* TODO: [๐ง ][๐งโโ๏ธ] Maybe join remoteServerUrl and path into single value
|
|
213
214
|
*/
|
|
214
215
|
|
|
216
|
+
/**
|
|
217
|
+
* AuthenticationError is thrown from login function which is dependency of remote server
|
|
218
|
+
*
|
|
219
|
+
* @public exported from `@promptbook/core`
|
|
220
|
+
*/
|
|
221
|
+
class AuthenticationError extends Error {
|
|
222
|
+
constructor(message) {
|
|
223
|
+
super(message);
|
|
224
|
+
this.name = 'AuthenticationError';
|
|
225
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
215
229
|
/**
|
|
216
230
|
* Generates random token
|
|
217
231
|
*
|
|
@@ -545,6 +559,7 @@ const COMMON_JAVASCRIPT_ERRORS = {
|
|
|
545
559
|
TypeError,
|
|
546
560
|
URIError,
|
|
547
561
|
AggregateError,
|
|
562
|
+
AuthenticationError,
|
|
548
563
|
/*
|
|
549
564
|
Note: Not widely supported
|
|
550
565
|
> InternalError,
|
|
@@ -580,6 +595,10 @@ function serializeError(error) {
|
|
|
580
595
|
|
|
581
596
|
Cannot serialize error with name "${name}"
|
|
582
597
|
|
|
598
|
+
Authors of Promptbook probably forgot to add this error into the list of errors:
|
|
599
|
+
https://github.com/webgptorg/promptbook/blob/main/src/errors/0-index.ts
|
|
600
|
+
|
|
601
|
+
|
|
583
602
|
${block(stack || message)}
|
|
584
603
|
|
|
585
604
|
`));
|
|
@@ -6713,11 +6732,12 @@ async function $provideScriptingForNode(options) {
|
|
|
6713
6732
|
* @public exported from `@promptbook/remote-server`
|
|
6714
6733
|
*/
|
|
6715
6734
|
function startRemoteServer(options) {
|
|
6716
|
-
const { port, collection, createLlmExecutionTools, isAnonymousModeAllowed, isApplicationModeAllowed, isVerbose = DEFAULT_IS_VERBOSE, } = {
|
|
6735
|
+
const { port, collection, createLlmExecutionTools, isAnonymousModeAllowed, isApplicationModeAllowed, isVerbose = DEFAULT_IS_VERBOSE, login, } = {
|
|
6717
6736
|
isAnonymousModeAllowed: false,
|
|
6718
6737
|
isApplicationModeAllowed: false,
|
|
6719
6738
|
collection: null,
|
|
6720
6739
|
createLlmExecutionTools: null,
|
|
6740
|
+
login: null,
|
|
6721
6741
|
...options,
|
|
6722
6742
|
};
|
|
6723
6743
|
// <- TODO: [๐ฆช] Some helper type to be able to use discriminant union types with destructuring
|
|
@@ -6795,13 +6815,14 @@ function startRemoteServer(options) {
|
|
|
6795
6815
|
servers: [
|
|
6796
6816
|
{
|
|
6797
6817
|
url: `http://localhost:${port}${rootPath}`,
|
|
6818
|
+
// <- TODO: !!!!! Probbably: Pass `remoteServerUrl` instead of `port` and `rootPath`
|
|
6798
6819
|
},
|
|
6799
6820
|
],
|
|
6800
6821
|
},
|
|
6801
6822
|
apis: ['./src/remote-server/**/*.ts'], // Adjust path as needed
|
|
6802
6823
|
};
|
|
6803
6824
|
const swaggerSpec = swaggerJsdoc(swaggerOptions);
|
|
6804
|
-
app.use(`${rootPath}/api-docs
|
|
6825
|
+
app.use([`/api-docs`, `${rootPath}/api-docs`], swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
|
6805
6826
|
const runningExecutionTasks = [];
|
|
6806
6827
|
// <- TODO: [๐คฌ] Identify the users
|
|
6807
6828
|
// TODO: [๐ง ] Do here some garbage collection of finished tasks
|
|
@@ -6851,9 +6872,12 @@ function startRemoteServer(options) {
|
|
|
6851
6872
|
|
|
6852
6873
|
## Paths
|
|
6853
6874
|
|
|
6854
|
-
${block(
|
|
6855
|
-
.
|
|
6856
|
-
|
|
6875
|
+
${block([
|
|
6876
|
+
...app._router.stack
|
|
6877
|
+
.map(({ route }) => (route === null || route === void 0 ? void 0 : route.path) || null)
|
|
6878
|
+
.filter((path) => path !== null),
|
|
6879
|
+
'/api-docs',
|
|
6880
|
+
]
|
|
6857
6881
|
.map((path) => `- ${path}`)
|
|
6858
6882
|
.join('\n'))}
|
|
6859
6883
|
|
|
@@ -6871,7 +6895,79 @@ function startRemoteServer(options) {
|
|
|
6871
6895
|
https://github.com/webgptorg/promptbook
|
|
6872
6896
|
`));
|
|
6873
6897
|
});
|
|
6874
|
-
|
|
6898
|
+
/**
|
|
6899
|
+
* @swagger
|
|
6900
|
+
*
|
|
6901
|
+
* /login:
|
|
6902
|
+
* post:
|
|
6903
|
+
* summary: Login to the server
|
|
6904
|
+
* description: Login to the server and get identification.
|
|
6905
|
+
* requestBody:
|
|
6906
|
+
* required: true
|
|
6907
|
+
* content:
|
|
6908
|
+
* application/json:
|
|
6909
|
+
* schema:
|
|
6910
|
+
* type: object
|
|
6911
|
+
* properties:
|
|
6912
|
+
* username:
|
|
6913
|
+
* type: string
|
|
6914
|
+
* password:
|
|
6915
|
+
* type: string
|
|
6916
|
+
* appId:
|
|
6917
|
+
* type: string
|
|
6918
|
+
* responses:
|
|
6919
|
+
* 200:
|
|
6920
|
+
* description: Successful login
|
|
6921
|
+
* content:
|
|
6922
|
+
* application/json:
|
|
6923
|
+
* schema:
|
|
6924
|
+
* type: object
|
|
6925
|
+
* properties:
|
|
6926
|
+
* identification:
|
|
6927
|
+
* type: object
|
|
6928
|
+
*/
|
|
6929
|
+
app.post([`/login`, `${rootPath}/login`], async (request, response) => {
|
|
6930
|
+
if (!isApplicationModeAllowed || login === null) {
|
|
6931
|
+
response.status(400).send('Application mode is not allowed');
|
|
6932
|
+
return;
|
|
6933
|
+
}
|
|
6934
|
+
try {
|
|
6935
|
+
const username = request.body.username;
|
|
6936
|
+
const password = request.body.password;
|
|
6937
|
+
const appId = request.body.appId;
|
|
6938
|
+
const { isSuccess, error, message, identification } = await login({
|
|
6939
|
+
username,
|
|
6940
|
+
password,
|
|
6941
|
+
appId,
|
|
6942
|
+
rawRequest: request,
|
|
6943
|
+
rawResponse: response,
|
|
6944
|
+
});
|
|
6945
|
+
response.status(201).send({
|
|
6946
|
+
isSuccess,
|
|
6947
|
+
message,
|
|
6948
|
+
error: error ? serializeError(error) : undefined,
|
|
6949
|
+
identification,
|
|
6950
|
+
});
|
|
6951
|
+
return;
|
|
6952
|
+
}
|
|
6953
|
+
catch (error) {
|
|
6954
|
+
if (!(error instanceof Error)) {
|
|
6955
|
+
throw error;
|
|
6956
|
+
}
|
|
6957
|
+
if (error instanceof AuthenticationError) {
|
|
6958
|
+
response.status(401).send({
|
|
6959
|
+
isSuccess: false,
|
|
6960
|
+
message: error.message,
|
|
6961
|
+
error: serializeError(error),
|
|
6962
|
+
});
|
|
6963
|
+
}
|
|
6964
|
+
console.warn(`Login function thrown different error than AuthenticationError`, {
|
|
6965
|
+
error,
|
|
6966
|
+
serializedError: serializeError(error),
|
|
6967
|
+
});
|
|
6968
|
+
response.status(400).send({ error: serializeError(error) });
|
|
6969
|
+
}
|
|
6970
|
+
});
|
|
6875
6971
|
/**
|
|
6876
6972
|
* @swagger
|
|
6877
6973
|
* /books:
|
|
@@ -6888,7 +6984,7 @@ function startRemoteServer(options) {
|
|
|
6888
6984
|
* items:
|
|
6889
6985
|
* type: string
|
|
6890
6986
|
*/
|
|
6891
|
-
app.get(`${rootPath}/books
|
|
6987
|
+
app.get([`/books`, `${rootPath}/books`], async (request, response) => {
|
|
6892
6988
|
if (collection === null) {
|
|
6893
6989
|
response.status(500).send('No collection available');
|
|
6894
6990
|
return;
|
|
@@ -6921,7 +7017,7 @@ function startRemoteServer(options) {
|
|
|
6921
7017
|
* 404:
|
|
6922
7018
|
* description: Book not found.
|
|
6923
7019
|
*/
|
|
6924
|
-
app.get(`${rootPath}/books
|
|
7020
|
+
app.get([`/books/*`, `${rootPath}/books/*`], async (request, response) => {
|
|
6925
7021
|
try {
|
|
6926
7022
|
if (collection === null) {
|
|
6927
7023
|
response.status(500).send('No collection nor books available');
|
|
@@ -6991,10 +7087,10 @@ function startRemoteServer(options) {
|
|
|
6991
7087
|
* items:
|
|
6992
7088
|
* type: object
|
|
6993
7089
|
*/
|
|
6994
|
-
app.get(`${rootPath}/executions
|
|
7090
|
+
app.get([`/executions`, `${rootPath}/executions`], async (request, response) => {
|
|
6995
7091
|
response.send(runningExecutionTasks.map((runningExecutionTask) => exportExecutionTask(runningExecutionTask, false)));
|
|
6996
7092
|
});
|
|
6997
|
-
app.get(`${rootPath}/executions/last
|
|
7093
|
+
app.get([`/executions/last`, `${rootPath}/executions/last`], async (request, response) => {
|
|
6998
7094
|
// TODO: [๐คฌ] Filter only for user
|
|
6999
7095
|
if (runningExecutionTasks.length === 0) {
|
|
7000
7096
|
response.status(404).send('No execution tasks found');
|
|
@@ -7003,7 +7099,7 @@ function startRemoteServer(options) {
|
|
|
7003
7099
|
const lastExecutionTask = runningExecutionTasks[runningExecutionTasks.length - 1];
|
|
7004
7100
|
response.send(exportExecutionTask(lastExecutionTask, true));
|
|
7005
7101
|
});
|
|
7006
|
-
app.get(`${rootPath}/executions/:taskId
|
|
7102
|
+
app.get([`/executions/:taskId`, `${rootPath}/executions/:taskId`], async (request, response) => {
|
|
7007
7103
|
const { taskId } = request.params;
|
|
7008
7104
|
// TODO: [๐คฌ] Filter only for user
|
|
7009
7105
|
const executionTask = runningExecutionTasks.find((executionTask) => executionTask.taskId === taskId);
|
|
@@ -7044,7 +7140,7 @@ function startRemoteServer(options) {
|
|
|
7044
7140
|
* 400:
|
|
7045
7141
|
* description: Invalid input.
|
|
7046
7142
|
*/
|
|
7047
|
-
app.post(`${rootPath}/executions/new
|
|
7143
|
+
app.post([`/executions/new`, `${rootPath}/executions/new`], async (request, response) => {
|
|
7048
7144
|
try {
|
|
7049
7145
|
const { inputParameters, identification /* <- [๐คฌ] */ } = request.body;
|
|
7050
7146
|
const pipelineUrl = request.body.pipelineUrl || request.body.book;
|