@promptbook/remote-server 0.89.0-6 โ 0.89.0-7
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 +95 -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/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 +30 -2
- package/package.json +2 -2
- package/umd/index.umd.js +95 -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-7';
|
|
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,64 @@ 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 identification = await login({ username, password, appId });
|
|
6939
|
+
response.status(201).send({ identification });
|
|
6940
|
+
return;
|
|
6941
|
+
}
|
|
6942
|
+
catch (error) {
|
|
6943
|
+
if (!(error instanceof Error)) {
|
|
6944
|
+
throw error;
|
|
6945
|
+
}
|
|
6946
|
+
if (error instanceof AuthenticationError) {
|
|
6947
|
+
response.status(401).send({ error: serializeError(error) });
|
|
6948
|
+
}
|
|
6949
|
+
console.warn(`Login function thrown different error than AuthenticationError`, {
|
|
6950
|
+
error,
|
|
6951
|
+
serializedError: serializeError(error),
|
|
6952
|
+
});
|
|
6953
|
+
response.status(400).send({ error: serializeError(error) });
|
|
6954
|
+
}
|
|
6955
|
+
});
|
|
6875
6956
|
/**
|
|
6876
6957
|
* @swagger
|
|
6877
6958
|
* /books:
|
|
@@ -6888,7 +6969,7 @@ function startRemoteServer(options) {
|
|
|
6888
6969
|
* items:
|
|
6889
6970
|
* type: string
|
|
6890
6971
|
*/
|
|
6891
|
-
app.get(`${rootPath}/books
|
|
6972
|
+
app.get([`/books`, `${rootPath}/books`], async (request, response) => {
|
|
6892
6973
|
if (collection === null) {
|
|
6893
6974
|
response.status(500).send('No collection available');
|
|
6894
6975
|
return;
|
|
@@ -6921,7 +7002,7 @@ function startRemoteServer(options) {
|
|
|
6921
7002
|
* 404:
|
|
6922
7003
|
* description: Book not found.
|
|
6923
7004
|
*/
|
|
6924
|
-
app.get(`${rootPath}/books
|
|
7005
|
+
app.get([`/books/*`, `${rootPath}/books/*`], async (request, response) => {
|
|
6925
7006
|
try {
|
|
6926
7007
|
if (collection === null) {
|
|
6927
7008
|
response.status(500).send('No collection nor books available');
|
|
@@ -6991,10 +7072,10 @@ function startRemoteServer(options) {
|
|
|
6991
7072
|
* items:
|
|
6992
7073
|
* type: object
|
|
6993
7074
|
*/
|
|
6994
|
-
app.get(`${rootPath}/executions
|
|
7075
|
+
app.get([`/executions`, `${rootPath}/executions`], async (request, response) => {
|
|
6995
7076
|
response.send(runningExecutionTasks.map((runningExecutionTask) => exportExecutionTask(runningExecutionTask, false)));
|
|
6996
7077
|
});
|
|
6997
|
-
app.get(`${rootPath}/executions/last
|
|
7078
|
+
app.get([`/executions/last`, `${rootPath}/executions/last`], async (request, response) => {
|
|
6998
7079
|
// TODO: [๐คฌ] Filter only for user
|
|
6999
7080
|
if (runningExecutionTasks.length === 0) {
|
|
7000
7081
|
response.status(404).send('No execution tasks found');
|
|
@@ -7003,7 +7084,7 @@ function startRemoteServer(options) {
|
|
|
7003
7084
|
const lastExecutionTask = runningExecutionTasks[runningExecutionTasks.length - 1];
|
|
7004
7085
|
response.send(exportExecutionTask(lastExecutionTask, true));
|
|
7005
7086
|
});
|
|
7006
|
-
app.get(`${rootPath}/executions/:taskId
|
|
7087
|
+
app.get([`/executions/:taskId`, `${rootPath}/executions/:taskId`], async (request, response) => {
|
|
7007
7088
|
const { taskId } = request.params;
|
|
7008
7089
|
// TODO: [๐คฌ] Filter only for user
|
|
7009
7090
|
const executionTask = runningExecutionTasks.find((executionTask) => executionTask.taskId === taskId);
|
|
@@ -7044,7 +7125,7 @@ function startRemoteServer(options) {
|
|
|
7044
7125
|
* 400:
|
|
7045
7126
|
* description: Invalid input.
|
|
7046
7127
|
*/
|
|
7047
|
-
app.post(`${rootPath}/executions/new
|
|
7128
|
+
app.post([`/executions/new`, `${rootPath}/executions/new`], async (request, response) => {
|
|
7048
7129
|
try {
|
|
7049
7130
|
const { inputParameters, identification /* <- [๐คฌ] */ } = request.body;
|
|
7050
7131
|
const pipelineUrl = request.body.pipelineUrl || request.body.book;
|