@promptbook/remote-server 0.89.0-5 โ 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 +208 -13
- 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 +4 -2
- package/umd/index.umd.js +212 -17
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('express'), require('http'), require('socket.io'), require('spacetrim'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), require('prettier'), require('prettier/parser-html'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'http', 'socket.io', 'spacetrim', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', 'prettier', 'prettier/parser-html', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.http, global.socket_io, global.spaceTrim, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.prettier, global.parserHtml, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
-
})(this, (function (exports, colors, express, http, socket_io, spaceTrim, waitasecond, crypto, child_process, promises, path, rxjs, prettier, parserHtml, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('express'), require('http'), require('socket.io'), require('spacetrim'), require('swagger-jsdoc'), require('swagger-ui-express'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), require('prettier'), require('prettier/parser-html'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'http', 'socket.io', 'spacetrim', 'swagger-jsdoc', 'swagger-ui-express', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', 'prettier', 'prettier/parser-html', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.http, global.socket_io, global.spaceTrim, global.swaggerJsdoc, global.swaggerUi, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.prettier, global.parserHtml, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, colors, express, http, socket_io, spaceTrim, swaggerJsdoc, swaggerUi, waitasecond, crypto, child_process, promises, path, rxjs, prettier, parserHtml, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
11
11
|
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
12
12
|
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
13
|
+
var swaggerJsdoc__default = /*#__PURE__*/_interopDefaultLegacy(swaggerJsdoc);
|
|
14
|
+
var swaggerUi__default = /*#__PURE__*/_interopDefaultLegacy(swaggerUi);
|
|
13
15
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
14
16
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
15
17
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
* @generated
|
|
29
31
|
* @see https://github.com/webgptorg/promptbook
|
|
30
32
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-7';
|
|
32
34
|
/**
|
|
33
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
36
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -153,6 +155,7 @@
|
|
|
153
155
|
*/
|
|
154
156
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐คนโโ๏ธ]
|
|
155
157
|
// <- TODO: [๐] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
158
|
+
// TODO: !!!!!! Just .promptbook dir, hardocode others
|
|
156
159
|
/**
|
|
157
160
|
* Where to store the temporary downloads
|
|
158
161
|
*
|
|
@@ -204,9 +207,22 @@
|
|
|
204
207
|
true);
|
|
205
208
|
/**
|
|
206
209
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
207
|
-
* TODO: [๐ง ][๐งโโ๏ธ] Maybe join
|
|
210
|
+
* TODO: [๐ง ][๐งโโ๏ธ] Maybe join remoteServerUrl and path into single value
|
|
208
211
|
*/
|
|
209
212
|
|
|
213
|
+
/**
|
|
214
|
+
* AuthenticationError is thrown from login function which is dependency of remote server
|
|
215
|
+
*
|
|
216
|
+
* @public exported from `@promptbook/core`
|
|
217
|
+
*/
|
|
218
|
+
class AuthenticationError extends Error {
|
|
219
|
+
constructor(message) {
|
|
220
|
+
super(message);
|
|
221
|
+
this.name = 'AuthenticationError';
|
|
222
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
210
226
|
/**
|
|
211
227
|
* Generates random token
|
|
212
228
|
*
|
|
@@ -540,6 +556,7 @@
|
|
|
540
556
|
TypeError,
|
|
541
557
|
URIError,
|
|
542
558
|
AggregateError,
|
|
559
|
+
AuthenticationError,
|
|
543
560
|
/*
|
|
544
561
|
Note: Not widely supported
|
|
545
562
|
> InternalError,
|
|
@@ -575,6 +592,10 @@
|
|
|
575
592
|
|
|
576
593
|
Cannot serialize error with name "${name}"
|
|
577
594
|
|
|
595
|
+
Authors of Promptbook probably forgot to add this error into the list of errors:
|
|
596
|
+
https://github.com/webgptorg/promptbook/blob/main/src/errors/0-index.ts
|
|
597
|
+
|
|
598
|
+
|
|
578
599
|
${block(stack || message)}
|
|
579
600
|
|
|
580
601
|
`));
|
|
@@ -6708,11 +6729,12 @@
|
|
|
6708
6729
|
* @public exported from `@promptbook/remote-server`
|
|
6709
6730
|
*/
|
|
6710
6731
|
function startRemoteServer(options) {
|
|
6711
|
-
const { port, collection, createLlmExecutionTools, isAnonymousModeAllowed, isApplicationModeAllowed, isVerbose = DEFAULT_IS_VERBOSE, } = {
|
|
6732
|
+
const { port, collection, createLlmExecutionTools, isAnonymousModeAllowed, isApplicationModeAllowed, isVerbose = DEFAULT_IS_VERBOSE, login, } = {
|
|
6712
6733
|
isAnonymousModeAllowed: false,
|
|
6713
6734
|
isApplicationModeAllowed: false,
|
|
6714
6735
|
collection: null,
|
|
6715
6736
|
createLlmExecutionTools: null,
|
|
6737
|
+
login: null,
|
|
6716
6738
|
...options,
|
|
6717
6739
|
};
|
|
6718
6740
|
// <- TODO: [๐ฆช] Some helper type to be able to use discriminant union types with destructuring
|
|
@@ -6779,9 +6801,38 @@
|
|
|
6779
6801
|
response.setHeader('X-Powered-By', 'Promptbook engine');
|
|
6780
6802
|
next();
|
|
6781
6803
|
});
|
|
6804
|
+
const swaggerOptions = {
|
|
6805
|
+
definition: {
|
|
6806
|
+
openapi: '3.0.0',
|
|
6807
|
+
info: {
|
|
6808
|
+
title: 'Promptbook Remote Server API',
|
|
6809
|
+
version: '1.0.0',
|
|
6810
|
+
description: 'API documentation for the Promptbook Remote Server',
|
|
6811
|
+
},
|
|
6812
|
+
servers: [
|
|
6813
|
+
{
|
|
6814
|
+
url: `http://localhost:${port}${rootPath}`,
|
|
6815
|
+
// <- TODO: !!!!! Probbably: Pass `remoteServerUrl` instead of `port` and `rootPath`
|
|
6816
|
+
},
|
|
6817
|
+
],
|
|
6818
|
+
},
|
|
6819
|
+
apis: ['./src/remote-server/**/*.ts'], // Adjust path as needed
|
|
6820
|
+
};
|
|
6821
|
+
const swaggerSpec = swaggerJsdoc__default["default"](swaggerOptions);
|
|
6822
|
+
app.use([`/api-docs`, `${rootPath}/api-docs`], swaggerUi__default["default"].serve, swaggerUi__default["default"].setup(swaggerSpec));
|
|
6782
6823
|
const runningExecutionTasks = [];
|
|
6783
6824
|
// <- TODO: [๐คฌ] Identify the users
|
|
6784
6825
|
// TODO: [๐ง ] Do here some garbage collection of finished tasks
|
|
6826
|
+
/**
|
|
6827
|
+
* @swagger
|
|
6828
|
+
* /:
|
|
6829
|
+
* get:
|
|
6830
|
+
* summary: Get server details
|
|
6831
|
+
* description: Returns details about the Promptbook server.
|
|
6832
|
+
* responses:
|
|
6833
|
+
* 200:
|
|
6834
|
+
* description: Server details in markdown format.
|
|
6835
|
+
*/
|
|
6785
6836
|
app.get(['/', rootPath], async (request, response) => {
|
|
6786
6837
|
var _a;
|
|
6787
6838
|
if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.includes('socket.io')) {
|
|
@@ -6818,9 +6869,12 @@
|
|
|
6818
6869
|
|
|
6819
6870
|
## Paths
|
|
6820
6871
|
|
|
6821
|
-
${block(
|
|
6822
|
-
.
|
|
6823
|
-
|
|
6872
|
+
${block([
|
|
6873
|
+
...app._router.stack
|
|
6874
|
+
.map(({ route }) => (route === null || route === void 0 ? void 0 : route.path) || null)
|
|
6875
|
+
.filter((path) => path !== null),
|
|
6876
|
+
'/api-docs',
|
|
6877
|
+
]
|
|
6824
6878
|
.map((path) => `- ${path}`)
|
|
6825
6879
|
.join('\n'))}
|
|
6826
6880
|
|
|
@@ -6838,8 +6892,81 @@
|
|
|
6838
6892
|
https://github.com/webgptorg/promptbook
|
|
6839
6893
|
`));
|
|
6840
6894
|
});
|
|
6841
|
-
|
|
6842
|
-
|
|
6895
|
+
/**
|
|
6896
|
+
* @swagger
|
|
6897
|
+
*
|
|
6898
|
+
* /login:
|
|
6899
|
+
* post:
|
|
6900
|
+
* summary: Login to the server
|
|
6901
|
+
* description: Login to the server and get identification.
|
|
6902
|
+
* requestBody:
|
|
6903
|
+
* required: true
|
|
6904
|
+
* content:
|
|
6905
|
+
* application/json:
|
|
6906
|
+
* schema:
|
|
6907
|
+
* type: object
|
|
6908
|
+
* properties:
|
|
6909
|
+
* username:
|
|
6910
|
+
* type: string
|
|
6911
|
+
* password:
|
|
6912
|
+
* type: string
|
|
6913
|
+
* appId:
|
|
6914
|
+
* type: string
|
|
6915
|
+
* responses:
|
|
6916
|
+
* 200:
|
|
6917
|
+
* description: Successful login
|
|
6918
|
+
* content:
|
|
6919
|
+
* application/json:
|
|
6920
|
+
* schema:
|
|
6921
|
+
* type: object
|
|
6922
|
+
* properties:
|
|
6923
|
+
* identification:
|
|
6924
|
+
* type: object
|
|
6925
|
+
*/
|
|
6926
|
+
app.post([`/login`, `${rootPath}/login`], async (request, response) => {
|
|
6927
|
+
if (!isApplicationModeAllowed || login === null) {
|
|
6928
|
+
response.status(400).send('Application mode is not allowed');
|
|
6929
|
+
return;
|
|
6930
|
+
}
|
|
6931
|
+
try {
|
|
6932
|
+
const username = request.body.username;
|
|
6933
|
+
const password = request.body.password;
|
|
6934
|
+
const appId = request.body.appId;
|
|
6935
|
+
const identification = await login({ username, password, appId });
|
|
6936
|
+
response.status(201).send({ identification });
|
|
6937
|
+
return;
|
|
6938
|
+
}
|
|
6939
|
+
catch (error) {
|
|
6940
|
+
if (!(error instanceof Error)) {
|
|
6941
|
+
throw error;
|
|
6942
|
+
}
|
|
6943
|
+
if (error instanceof AuthenticationError) {
|
|
6944
|
+
response.status(401).send({ error: serializeError(error) });
|
|
6945
|
+
}
|
|
6946
|
+
console.warn(`Login function thrown different error than AuthenticationError`, {
|
|
6947
|
+
error,
|
|
6948
|
+
serializedError: serializeError(error),
|
|
6949
|
+
});
|
|
6950
|
+
response.status(400).send({ error: serializeError(error) });
|
|
6951
|
+
}
|
|
6952
|
+
});
|
|
6953
|
+
/**
|
|
6954
|
+
* @swagger
|
|
6955
|
+
* /books:
|
|
6956
|
+
* get:
|
|
6957
|
+
* summary: List all books
|
|
6958
|
+
* description: Returns a list of all available books in the collection.
|
|
6959
|
+
* responses:
|
|
6960
|
+
* 200:
|
|
6961
|
+
* description: A list of books.
|
|
6962
|
+
* content:
|
|
6963
|
+
* application/json:
|
|
6964
|
+
* schema:
|
|
6965
|
+
* type: array
|
|
6966
|
+
* items:
|
|
6967
|
+
* type: string
|
|
6968
|
+
*/
|
|
6969
|
+
app.get([`/books`, `${rootPath}/books`], async (request, response) => {
|
|
6843
6970
|
if (collection === null) {
|
|
6844
6971
|
response.status(500).send('No collection available');
|
|
6845
6972
|
return;
|
|
@@ -6849,7 +6976,30 @@
|
|
|
6849
6976
|
response.send(pipelines);
|
|
6850
6977
|
});
|
|
6851
6978
|
// TODO: [๐ง ] Is it secure / good idea to expose source codes of hosted books
|
|
6852
|
-
|
|
6979
|
+
/**
|
|
6980
|
+
* @swagger
|
|
6981
|
+
* /books/{bookId}:
|
|
6982
|
+
* get:
|
|
6983
|
+
* summary: Get book content
|
|
6984
|
+
* description: Returns the content of a specific book.
|
|
6985
|
+
* parameters:
|
|
6986
|
+
* - in: path
|
|
6987
|
+
* name: bookId
|
|
6988
|
+
* required: true
|
|
6989
|
+
* schema:
|
|
6990
|
+
* type: string
|
|
6991
|
+
* description: The ID of the book to retrieve.
|
|
6992
|
+
* responses:
|
|
6993
|
+
* 200:
|
|
6994
|
+
* description: The content of the book.
|
|
6995
|
+
* content:
|
|
6996
|
+
* text/markdown:
|
|
6997
|
+
* schema:
|
|
6998
|
+
* type: string
|
|
6999
|
+
* 404:
|
|
7000
|
+
* description: Book not found.
|
|
7001
|
+
*/
|
|
7002
|
+
app.get([`/books/*`, `${rootPath}/books/*`], async (request, response) => {
|
|
6853
7003
|
try {
|
|
6854
7004
|
if (collection === null) {
|
|
6855
7005
|
response.status(500).send('No collection nor books available');
|
|
@@ -6903,10 +7053,26 @@
|
|
|
6903
7053
|
};
|
|
6904
7054
|
}
|
|
6905
7055
|
}
|
|
6906
|
-
|
|
7056
|
+
/**
|
|
7057
|
+
* @swagger
|
|
7058
|
+
* /executions:
|
|
7059
|
+
* get:
|
|
7060
|
+
* summary: List all executions
|
|
7061
|
+
* description: Returns a list of all running execution tasks.
|
|
7062
|
+
* responses:
|
|
7063
|
+
* 200:
|
|
7064
|
+
* description: A list of execution tasks.
|
|
7065
|
+
* content:
|
|
7066
|
+
* application/json:
|
|
7067
|
+
* schema:
|
|
7068
|
+
* type: array
|
|
7069
|
+
* items:
|
|
7070
|
+
* type: object
|
|
7071
|
+
*/
|
|
7072
|
+
app.get([`/executions`, `${rootPath}/executions`], async (request, response) => {
|
|
6907
7073
|
response.send(runningExecutionTasks.map((runningExecutionTask) => exportExecutionTask(runningExecutionTask, false)));
|
|
6908
7074
|
});
|
|
6909
|
-
app.get(`${rootPath}/executions/last
|
|
7075
|
+
app.get([`/executions/last`, `${rootPath}/executions/last`], async (request, response) => {
|
|
6910
7076
|
// TODO: [๐คฌ] Filter only for user
|
|
6911
7077
|
if (runningExecutionTasks.length === 0) {
|
|
6912
7078
|
response.status(404).send('No execution tasks found');
|
|
@@ -6915,7 +7081,7 @@
|
|
|
6915
7081
|
const lastExecutionTask = runningExecutionTasks[runningExecutionTasks.length - 1];
|
|
6916
7082
|
response.send(exportExecutionTask(lastExecutionTask, true));
|
|
6917
7083
|
});
|
|
6918
|
-
app.get(`${rootPath}/executions/:taskId
|
|
7084
|
+
app.get([`/executions/:taskId`, `${rootPath}/executions/:taskId`], async (request, response) => {
|
|
6919
7085
|
const { taskId } = request.params;
|
|
6920
7086
|
// TODO: [๐คฌ] Filter only for user
|
|
6921
7087
|
const executionTask = runningExecutionTasks.find((executionTask) => executionTask.taskId === taskId);
|
|
@@ -6927,7 +7093,36 @@
|
|
|
6927
7093
|
}
|
|
6928
7094
|
response.send(exportExecutionTask(executionTask, true));
|
|
6929
7095
|
});
|
|
6930
|
-
|
|
7096
|
+
/**
|
|
7097
|
+
* @swagger
|
|
7098
|
+
* /executions/new:
|
|
7099
|
+
* post:
|
|
7100
|
+
* summary: Start a new execution
|
|
7101
|
+
* description: Starts a new execution task for a given pipeline.
|
|
7102
|
+
* requestBody:
|
|
7103
|
+
* required: true
|
|
7104
|
+
* content:
|
|
7105
|
+
* application/json:
|
|
7106
|
+
* schema:
|
|
7107
|
+
* type: object
|
|
7108
|
+
* properties:
|
|
7109
|
+
* pipelineUrl:
|
|
7110
|
+
* type: string
|
|
7111
|
+
* inputParameters:
|
|
7112
|
+
* type: object
|
|
7113
|
+
* identification:
|
|
7114
|
+
* type: object
|
|
7115
|
+
* responses:
|
|
7116
|
+
* 200:
|
|
7117
|
+
* description: The newly created execution task.
|
|
7118
|
+
* content:
|
|
7119
|
+
* application/json:
|
|
7120
|
+
* schema:
|
|
7121
|
+
* type: object
|
|
7122
|
+
* 400:
|
|
7123
|
+
* description: Invalid input.
|
|
7124
|
+
*/
|
|
7125
|
+
app.post([`/executions/new`, `${rootPath}/executions/new`], async (request, response) => {
|
|
6931
7126
|
try {
|
|
6932
7127
|
const { inputParameters, identification /* <- [๐คฌ] */ } = request.body;
|
|
6933
7128
|
const pipelineUrl = request.body.pipelineUrl || request.body.book;
|