@promptbook/remote-server 0.89.0-4 → 0.89.0-6
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 +124 -1
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/remote-server/RemoteServer.d.ts +23 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +2 -2
- package/esm/typings/src/utils/organization/TODO_narrow.d.ts +6 -0
- package/package.json +4 -2
- package/umd/index.umd.js +128 -5
- package/umd/index.umd.js.map +1 -1
|
@@ -112,6 +112,7 @@ import type { components } from '../playground/brjapp-api-schema';
|
|
|
112
112
|
import type { $defs } from '../playground/brjapp-api-schema';
|
|
113
113
|
import type { operations } from '../playground/brjapp-api-schema';
|
|
114
114
|
import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
|
|
115
|
+
import type { RemoteServer } from '../remote-server/RemoteServer';
|
|
115
116
|
import type { PromptbookServer_Identification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
116
117
|
import type { PromptbookServer_ApplicationIdentification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
117
118
|
import type { PromptbookServer_AnonymousIdentification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
@@ -401,6 +402,7 @@ export type { components };
|
|
|
401
402
|
export type { $defs };
|
|
402
403
|
export type { operations };
|
|
403
404
|
export type { PrepareAndScrapeOptions };
|
|
405
|
+
export type { RemoteServer };
|
|
404
406
|
export type { PromptbookServer_Identification };
|
|
405
407
|
export type { PromptbookServer_ApplicationIdentification };
|
|
406
408
|
export type { PromptbookServer_AnonymousIdentification };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { IDestroyable } from 'destroyable';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import http from 'http';
|
|
5
|
+
import { DefaultEventsMap, Server } from 'socket.io';
|
|
6
|
+
import type { TODO_any } from '../utils/organization/TODO_any';
|
|
7
|
+
import type { TODO_narrow } from '../utils/organization/TODO_narrow';
|
|
8
|
+
export type RemoteServer = IDestroyable & {
|
|
9
|
+
/**
|
|
10
|
+
* HTTP server instance
|
|
11
|
+
*/
|
|
12
|
+
readonly httpServer: http.Server<TODO_any>;
|
|
13
|
+
/**
|
|
14
|
+
* Express application instance
|
|
15
|
+
*
|
|
16
|
+
* Note: This is useful for adding custom routes
|
|
17
|
+
*/
|
|
18
|
+
readonly expressApp: express.Express;
|
|
19
|
+
/**
|
|
20
|
+
* Socket.io server instance
|
|
21
|
+
*/
|
|
22
|
+
readonly socketIoServer: Server<TODO_narrow<DefaultEventsMap>, TODO_narrow<DefaultEventsMap>, TODO_narrow<DefaultEventsMap>, TODO_any>;
|
|
23
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RemoteServer } from './RemoteServer';
|
|
2
2
|
import type { RemoteServerOptions } from './types/RemoteServerOptions';
|
|
3
3
|
/**
|
|
4
4
|
* Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
|
|
@@ -9,7 +9,7 @@ import type { RemoteServerOptions } from './types/RemoteServerOptions';
|
|
|
9
9
|
* @see https://github.com/webgptorg/promptbook#remote-server
|
|
10
10
|
* @public exported from `@promptbook/remote-server`
|
|
11
11
|
*/
|
|
12
|
-
export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>):
|
|
12
|
+
export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): RemoteServer;
|
|
13
13
|
/**
|
|
14
14
|
* TODO: !! Add CORS and security - probbably via `helmet`
|
|
15
15
|
* TODO: [👩🏾🤝🧑🏾] Allow to pass custom fetch function here - PromptbookFetch
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-server",
|
|
3
|
-
"version": "0.89.0-
|
|
3
|
+
"version": "0.89.0-6",
|
|
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,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.89.0-
|
|
50
|
+
"@promptbook/core": "0.89.0-6"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
|
@@ -59,6 +59,8 @@
|
|
|
59
59
|
"rxjs": "^7.8.1",
|
|
60
60
|
"socket.io": "4.8.1",
|
|
61
61
|
"spacetrim": "0.11.59",
|
|
62
|
+
"swagger-jsdoc": "^6.2.8",
|
|
63
|
+
"swagger-ui-express": "^5.0.1",
|
|
62
64
|
"userhome": "1.0.1",
|
|
63
65
|
"waitasecond": "1.11.83"
|
|
64
66
|
}
|
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-6';
|
|
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
|
|
@@ -6779,9 +6781,37 @@
|
|
|
6779
6781
|
response.setHeader('X-Powered-By', 'Promptbook engine');
|
|
6780
6782
|
next();
|
|
6781
6783
|
});
|
|
6784
|
+
const swaggerOptions = {
|
|
6785
|
+
definition: {
|
|
6786
|
+
openapi: '3.0.0',
|
|
6787
|
+
info: {
|
|
6788
|
+
title: 'Promptbook Remote Server API',
|
|
6789
|
+
version: '1.0.0',
|
|
6790
|
+
description: 'API documentation for the Promptbook Remote Server',
|
|
6791
|
+
},
|
|
6792
|
+
servers: [
|
|
6793
|
+
{
|
|
6794
|
+
url: `http://localhost:${port}${rootPath}`,
|
|
6795
|
+
},
|
|
6796
|
+
],
|
|
6797
|
+
},
|
|
6798
|
+
apis: ['./src/remote-server/**/*.ts'], // Adjust path as needed
|
|
6799
|
+
};
|
|
6800
|
+
const swaggerSpec = swaggerJsdoc__default["default"](swaggerOptions);
|
|
6801
|
+
app.use(`${rootPath}/api-docs`, swaggerUi__default["default"].serve, swaggerUi__default["default"].setup(swaggerSpec));
|
|
6782
6802
|
const runningExecutionTasks = [];
|
|
6783
6803
|
// <- TODO: [🤬] Identify the users
|
|
6784
6804
|
// TODO: [🧠] Do here some garbage collection of finished tasks
|
|
6805
|
+
/**
|
|
6806
|
+
* @swagger
|
|
6807
|
+
* /:
|
|
6808
|
+
* get:
|
|
6809
|
+
* summary: Get server details
|
|
6810
|
+
* description: Returns details about the Promptbook server.
|
|
6811
|
+
* responses:
|
|
6812
|
+
* 200:
|
|
6813
|
+
* description: Server details in markdown format.
|
|
6814
|
+
*/
|
|
6785
6815
|
app.get(['/', rootPath], async (request, response) => {
|
|
6786
6816
|
var _a;
|
|
6787
6817
|
if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.includes('socket.io')) {
|
|
@@ -6839,6 +6869,22 @@
|
|
|
6839
6869
|
`));
|
|
6840
6870
|
});
|
|
6841
6871
|
// TODO: !!!!!! Add login route
|
|
6872
|
+
/**
|
|
6873
|
+
* @swagger
|
|
6874
|
+
* /books:
|
|
6875
|
+
* get:
|
|
6876
|
+
* summary: List all books
|
|
6877
|
+
* description: Returns a list of all available books in the collection.
|
|
6878
|
+
* responses:
|
|
6879
|
+
* 200:
|
|
6880
|
+
* description: A list of books.
|
|
6881
|
+
* content:
|
|
6882
|
+
* application/json:
|
|
6883
|
+
* schema:
|
|
6884
|
+
* type: array
|
|
6885
|
+
* items:
|
|
6886
|
+
* type: string
|
|
6887
|
+
*/
|
|
6842
6888
|
app.get(`${rootPath}/books`, async (request, response) => {
|
|
6843
6889
|
if (collection === null) {
|
|
6844
6890
|
response.status(500).send('No collection available');
|
|
@@ -6849,6 +6895,29 @@
|
|
|
6849
6895
|
response.send(pipelines);
|
|
6850
6896
|
});
|
|
6851
6897
|
// TODO: [🧠] Is it secure / good idea to expose source codes of hosted books
|
|
6898
|
+
/**
|
|
6899
|
+
* @swagger
|
|
6900
|
+
* /books/{bookId}:
|
|
6901
|
+
* get:
|
|
6902
|
+
* summary: Get book content
|
|
6903
|
+
* description: Returns the content of a specific book.
|
|
6904
|
+
* parameters:
|
|
6905
|
+
* - in: path
|
|
6906
|
+
* name: bookId
|
|
6907
|
+
* required: true
|
|
6908
|
+
* schema:
|
|
6909
|
+
* type: string
|
|
6910
|
+
* description: The ID of the book to retrieve.
|
|
6911
|
+
* responses:
|
|
6912
|
+
* 200:
|
|
6913
|
+
* description: The content of the book.
|
|
6914
|
+
* content:
|
|
6915
|
+
* text/markdown:
|
|
6916
|
+
* schema:
|
|
6917
|
+
* type: string
|
|
6918
|
+
* 404:
|
|
6919
|
+
* description: Book not found.
|
|
6920
|
+
*/
|
|
6852
6921
|
app.get(`${rootPath}/books/*`, async (request, response) => {
|
|
6853
6922
|
try {
|
|
6854
6923
|
if (collection === null) {
|
|
@@ -6903,6 +6972,22 @@
|
|
|
6903
6972
|
};
|
|
6904
6973
|
}
|
|
6905
6974
|
}
|
|
6975
|
+
/**
|
|
6976
|
+
* @swagger
|
|
6977
|
+
* /executions:
|
|
6978
|
+
* get:
|
|
6979
|
+
* summary: List all executions
|
|
6980
|
+
* description: Returns a list of all running execution tasks.
|
|
6981
|
+
* responses:
|
|
6982
|
+
* 200:
|
|
6983
|
+
* description: A list of execution tasks.
|
|
6984
|
+
* content:
|
|
6985
|
+
* application/json:
|
|
6986
|
+
* schema:
|
|
6987
|
+
* type: array
|
|
6988
|
+
* items:
|
|
6989
|
+
* type: object
|
|
6990
|
+
*/
|
|
6906
6991
|
app.get(`${rootPath}/executions`, async (request, response) => {
|
|
6907
6992
|
response.send(runningExecutionTasks.map((runningExecutionTask) => exportExecutionTask(runningExecutionTask, false)));
|
|
6908
6993
|
});
|
|
@@ -6927,6 +7012,35 @@
|
|
|
6927
7012
|
}
|
|
6928
7013
|
response.send(exportExecutionTask(executionTask, true));
|
|
6929
7014
|
});
|
|
7015
|
+
/**
|
|
7016
|
+
* @swagger
|
|
7017
|
+
* /executions/new:
|
|
7018
|
+
* post:
|
|
7019
|
+
* summary: Start a new execution
|
|
7020
|
+
* description: Starts a new execution task for a given pipeline.
|
|
7021
|
+
* requestBody:
|
|
7022
|
+
* required: true
|
|
7023
|
+
* content:
|
|
7024
|
+
* application/json:
|
|
7025
|
+
* schema:
|
|
7026
|
+
* type: object
|
|
7027
|
+
* properties:
|
|
7028
|
+
* pipelineUrl:
|
|
7029
|
+
* type: string
|
|
7030
|
+
* inputParameters:
|
|
7031
|
+
* type: object
|
|
7032
|
+
* identification:
|
|
7033
|
+
* type: object
|
|
7034
|
+
* responses:
|
|
7035
|
+
* 200:
|
|
7036
|
+
* description: The newly created execution task.
|
|
7037
|
+
* content:
|
|
7038
|
+
* application/json:
|
|
7039
|
+
* schema:
|
|
7040
|
+
* type: object
|
|
7041
|
+
* 400:
|
|
7042
|
+
* description: Invalid input.
|
|
7043
|
+
*/
|
|
6930
7044
|
app.post(`${rootPath}/executions/new`, async (request, response) => {
|
|
6931
7045
|
try {
|
|
6932
7046
|
const { inputParameters, identification /* <- [🤬] */ } = request.body;
|
|
@@ -7104,6 +7218,15 @@
|
|
|
7104
7218
|
}
|
|
7105
7219
|
let isDestroyed = false;
|
|
7106
7220
|
return {
|
|
7221
|
+
get httpServer() {
|
|
7222
|
+
return httpServer;
|
|
7223
|
+
},
|
|
7224
|
+
get expressApp() {
|
|
7225
|
+
return app;
|
|
7226
|
+
},
|
|
7227
|
+
get socketIoServer() {
|
|
7228
|
+
return server;
|
|
7229
|
+
},
|
|
7107
7230
|
get isDestroyed() {
|
|
7108
7231
|
return isDestroyed;
|
|
7109
7232
|
},
|