@promptbook/cli 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 +3 -1
- 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/cli",
|
|
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,
|
|
@@ -69,6 +69,8 @@
|
|
|
69
69
|
"socket.io": "4.8.1",
|
|
70
70
|
"socket.io-client": "4.7.2",
|
|
71
71
|
"spacetrim": "0.11.59",
|
|
72
|
+
"swagger-jsdoc": "^6.2.8",
|
|
73
|
+
"swagger-ui-express": "^5.0.1",
|
|
72
74
|
"type-fest": "4.5.0",
|
|
73
75
|
"userhome": "1.0.1",
|
|
74
76
|
"waitasecond": "1.11.83"
|
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('commander'), require('spacetrim'), require('waitasecond'), require('path'), require('fs/promises'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto'), require('rxjs'), require('dotenv'), require('child_process'), require('jszip'), require('prettier'), require('prettier/parser-html'), require('papaparse'), require('crypto-js'), require('mime-types'), require('glob-promise'), require('prompts'), require('moment'), require('express'), require('http'), require('socket.io'), require('socket.io-client'), require('@anthropic-ai/sdk'), require('@azure/openai'), require('openai'), require('@mozilla/readability'), require('jsdom'), require('showdown')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'waitasecond', 'path', 'fs/promises', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto', 'rxjs', 'dotenv', 'child_process', 'jszip', 'prettier', 'prettier/parser-html', 'papaparse', 'crypto-js', 'mime-types', 'glob-promise', 'prompts', 'moment', 'express', 'http', 'socket.io', 'socket.io-client', '@anthropic-ai/sdk', '@azure/openai', 'openai', '@mozilla/readability', 'jsdom', 'showdown'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim, global.waitasecond, global.path, global.promises, global.hexEncoder, global.sha256, global.crypto, global.rxjs, global.dotenv, global.child_process, global.JSZip, global.prettier, global.parserHtml, global.papaparse, global.cryptoJs, global.mimeTypes, global.glob, global.prompts, global.moment, global.express, global.http, global.socket_io, global.socket_ioClient, global.Anthropic, global.openai, global.OpenAI, global.readability, global.jsdom, global.showdown));
|
|
5
|
-
})(this, (function (exports, colors, commander, spaceTrim, waitasecond, path, promises, hexEncoder, sha256, crypto, rxjs, dotenv, child_process, JSZip, prettier, parserHtml, papaparse, cryptoJs, mimeTypes, glob, prompts, moment, express, http, socket_io, socket_ioClient, Anthropic, openai, OpenAI, readability, jsdom, showdown) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('waitasecond'), require('path'), require('fs/promises'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto'), require('rxjs'), require('dotenv'), require('child_process'), require('jszip'), require('prettier'), require('prettier/parser-html'), require('papaparse'), require('crypto-js'), require('mime-types'), require('glob-promise'), require('prompts'), require('moment'), require('express'), require('http'), require('socket.io'), require('swagger-jsdoc'), require('swagger-ui-express'), require('socket.io-client'), require('@anthropic-ai/sdk'), require('@azure/openai'), require('openai'), require('@mozilla/readability'), require('jsdom'), require('showdown')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'waitasecond', 'path', 'fs/promises', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto', 'rxjs', 'dotenv', 'child_process', 'jszip', 'prettier', 'prettier/parser-html', 'papaparse', 'crypto-js', 'mime-types', 'glob-promise', 'prompts', 'moment', 'express', 'http', 'socket.io', 'swagger-jsdoc', 'swagger-ui-express', 'socket.io-client', '@anthropic-ai/sdk', '@azure/openai', 'openai', '@mozilla/readability', 'jsdom', 'showdown'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim, global.waitasecond, global.path, global.promises, global.hexEncoder, global.sha256, global.crypto, global.rxjs, global.dotenv, global.child_process, global.JSZip, global.prettier, global.parserHtml, global.papaparse, global.cryptoJs, global.mimeTypes, global.glob, global.prompts, global.moment, global.express, global.http, global.socket_io, global.swaggerJsdoc, global.swaggerUi, global.socket_ioClient, global.Anthropic, global.openai, global.OpenAI, global.readability, global.jsdom, global.showdown));
|
|
5
|
+
})(this, (function (exports, colors, commander, spaceTrim, waitasecond, path, promises, hexEncoder, sha256, crypto, rxjs, dotenv, child_process, JSZip, prettier, parserHtml, papaparse, cryptoJs, mimeTypes, glob, prompts, moment, express, http, socket_io, swaggerJsdoc, swaggerUi, socket_ioClient, Anthropic, openai, OpenAI, readability, jsdom, showdown) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
38
38
|
var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
39
39
|
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
40
|
+
var swaggerJsdoc__default = /*#__PURE__*/_interopDefaultLegacy(swaggerJsdoc);
|
|
41
|
+
var swaggerUi__default = /*#__PURE__*/_interopDefaultLegacy(swaggerUi);
|
|
40
42
|
var Anthropic__default = /*#__PURE__*/_interopDefaultLegacy(Anthropic);
|
|
41
43
|
var OpenAI__default = /*#__PURE__*/_interopDefaultLegacy(OpenAI);
|
|
42
44
|
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
* @generated
|
|
55
57
|
* @see https://github.com/webgptorg/promptbook
|
|
56
58
|
*/
|
|
57
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
59
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-6';
|
|
58
60
|
/**
|
|
59
61
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
60
62
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -12624,9 +12626,37 @@
|
|
|
12624
12626
|
response.setHeader('X-Powered-By', 'Promptbook engine');
|
|
12625
12627
|
next();
|
|
12626
12628
|
});
|
|
12629
|
+
const swaggerOptions = {
|
|
12630
|
+
definition: {
|
|
12631
|
+
openapi: '3.0.0',
|
|
12632
|
+
info: {
|
|
12633
|
+
title: 'Promptbook Remote Server API',
|
|
12634
|
+
version: '1.0.0',
|
|
12635
|
+
description: 'API documentation for the Promptbook Remote Server',
|
|
12636
|
+
},
|
|
12637
|
+
servers: [
|
|
12638
|
+
{
|
|
12639
|
+
url: `http://localhost:${port}${rootPath}`,
|
|
12640
|
+
},
|
|
12641
|
+
],
|
|
12642
|
+
},
|
|
12643
|
+
apis: ['./src/remote-server/**/*.ts'], // Adjust path as needed
|
|
12644
|
+
};
|
|
12645
|
+
const swaggerSpec = swaggerJsdoc__default["default"](swaggerOptions);
|
|
12646
|
+
app.use(`${rootPath}/api-docs`, swaggerUi__default["default"].serve, swaggerUi__default["default"].setup(swaggerSpec));
|
|
12627
12647
|
const runningExecutionTasks = [];
|
|
12628
12648
|
// <- TODO: [🤬] Identify the users
|
|
12629
12649
|
// TODO: [🧠] Do here some garbage collection of finished tasks
|
|
12650
|
+
/**
|
|
12651
|
+
* @swagger
|
|
12652
|
+
* /:
|
|
12653
|
+
* get:
|
|
12654
|
+
* summary: Get server details
|
|
12655
|
+
* description: Returns details about the Promptbook server.
|
|
12656
|
+
* responses:
|
|
12657
|
+
* 200:
|
|
12658
|
+
* description: Server details in markdown format.
|
|
12659
|
+
*/
|
|
12630
12660
|
app.get(['/', rootPath], async (request, response) => {
|
|
12631
12661
|
var _a;
|
|
12632
12662
|
if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.includes('socket.io')) {
|
|
@@ -12684,6 +12714,22 @@
|
|
|
12684
12714
|
`));
|
|
12685
12715
|
});
|
|
12686
12716
|
// TODO: !!!!!! Add login route
|
|
12717
|
+
/**
|
|
12718
|
+
* @swagger
|
|
12719
|
+
* /books:
|
|
12720
|
+
* get:
|
|
12721
|
+
* summary: List all books
|
|
12722
|
+
* description: Returns a list of all available books in the collection.
|
|
12723
|
+
* responses:
|
|
12724
|
+
* 200:
|
|
12725
|
+
* description: A list of books.
|
|
12726
|
+
* content:
|
|
12727
|
+
* application/json:
|
|
12728
|
+
* schema:
|
|
12729
|
+
* type: array
|
|
12730
|
+
* items:
|
|
12731
|
+
* type: string
|
|
12732
|
+
*/
|
|
12687
12733
|
app.get(`${rootPath}/books`, async (request, response) => {
|
|
12688
12734
|
if (collection === null) {
|
|
12689
12735
|
response.status(500).send('No collection available');
|
|
@@ -12694,6 +12740,29 @@
|
|
|
12694
12740
|
response.send(pipelines);
|
|
12695
12741
|
});
|
|
12696
12742
|
// TODO: [🧠] Is it secure / good idea to expose source codes of hosted books
|
|
12743
|
+
/**
|
|
12744
|
+
* @swagger
|
|
12745
|
+
* /books/{bookId}:
|
|
12746
|
+
* get:
|
|
12747
|
+
* summary: Get book content
|
|
12748
|
+
* description: Returns the content of a specific book.
|
|
12749
|
+
* parameters:
|
|
12750
|
+
* - in: path
|
|
12751
|
+
* name: bookId
|
|
12752
|
+
* required: true
|
|
12753
|
+
* schema:
|
|
12754
|
+
* type: string
|
|
12755
|
+
* description: The ID of the book to retrieve.
|
|
12756
|
+
* responses:
|
|
12757
|
+
* 200:
|
|
12758
|
+
* description: The content of the book.
|
|
12759
|
+
* content:
|
|
12760
|
+
* text/markdown:
|
|
12761
|
+
* schema:
|
|
12762
|
+
* type: string
|
|
12763
|
+
* 404:
|
|
12764
|
+
* description: Book not found.
|
|
12765
|
+
*/
|
|
12697
12766
|
app.get(`${rootPath}/books/*`, async (request, response) => {
|
|
12698
12767
|
try {
|
|
12699
12768
|
if (collection === null) {
|
|
@@ -12748,6 +12817,22 @@
|
|
|
12748
12817
|
};
|
|
12749
12818
|
}
|
|
12750
12819
|
}
|
|
12820
|
+
/**
|
|
12821
|
+
* @swagger
|
|
12822
|
+
* /executions:
|
|
12823
|
+
* get:
|
|
12824
|
+
* summary: List all executions
|
|
12825
|
+
* description: Returns a list of all running execution tasks.
|
|
12826
|
+
* responses:
|
|
12827
|
+
* 200:
|
|
12828
|
+
* description: A list of execution tasks.
|
|
12829
|
+
* content:
|
|
12830
|
+
* application/json:
|
|
12831
|
+
* schema:
|
|
12832
|
+
* type: array
|
|
12833
|
+
* items:
|
|
12834
|
+
* type: object
|
|
12835
|
+
*/
|
|
12751
12836
|
app.get(`${rootPath}/executions`, async (request, response) => {
|
|
12752
12837
|
response.send(runningExecutionTasks.map((runningExecutionTask) => exportExecutionTask(runningExecutionTask, false)));
|
|
12753
12838
|
});
|
|
@@ -12772,6 +12857,35 @@
|
|
|
12772
12857
|
}
|
|
12773
12858
|
response.send(exportExecutionTask(executionTask, true));
|
|
12774
12859
|
});
|
|
12860
|
+
/**
|
|
12861
|
+
* @swagger
|
|
12862
|
+
* /executions/new:
|
|
12863
|
+
* post:
|
|
12864
|
+
* summary: Start a new execution
|
|
12865
|
+
* description: Starts a new execution task for a given pipeline.
|
|
12866
|
+
* requestBody:
|
|
12867
|
+
* required: true
|
|
12868
|
+
* content:
|
|
12869
|
+
* application/json:
|
|
12870
|
+
* schema:
|
|
12871
|
+
* type: object
|
|
12872
|
+
* properties:
|
|
12873
|
+
* pipelineUrl:
|
|
12874
|
+
* type: string
|
|
12875
|
+
* inputParameters:
|
|
12876
|
+
* type: object
|
|
12877
|
+
* identification:
|
|
12878
|
+
* type: object
|
|
12879
|
+
* responses:
|
|
12880
|
+
* 200:
|
|
12881
|
+
* description: The newly created execution task.
|
|
12882
|
+
* content:
|
|
12883
|
+
* application/json:
|
|
12884
|
+
* schema:
|
|
12885
|
+
* type: object
|
|
12886
|
+
* 400:
|
|
12887
|
+
* description: Invalid input.
|
|
12888
|
+
*/
|
|
12775
12889
|
app.post(`${rootPath}/executions/new`, async (request, response) => {
|
|
12776
12890
|
try {
|
|
12777
12891
|
const { inputParameters, identification /* <- [🤬] */ } = request.body;
|
|
@@ -12949,6 +13063,15 @@
|
|
|
12949
13063
|
}
|
|
12950
13064
|
let isDestroyed = false;
|
|
12951
13065
|
return {
|
|
13066
|
+
get httpServer() {
|
|
13067
|
+
return httpServer;
|
|
13068
|
+
},
|
|
13069
|
+
get expressApp() {
|
|
13070
|
+
return app;
|
|
13071
|
+
},
|
|
13072
|
+
get socketIoServer() {
|
|
13073
|
+
return server;
|
|
13074
|
+
},
|
|
12952
13075
|
get isDestroyed() {
|
|
12953
13076
|
return isDestroyed;
|
|
12954
13077
|
},
|