@promptbook/cli 0.89.0-21 β†’ 0.89.0-27

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 CHANGED
@@ -46,7 +46,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
46
46
  * @generated
47
47
  * @see https://github.com/webgptorg/promptbook
48
48
  */
49
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-21';
49
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-27';
50
50
  /**
51
51
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
52
52
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -64,10 +64,12 @@ const REMOTE_SERVER_URLS = [
64
64
  owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
65
65
  isAnonymousModeAllowed: true,
66
66
  urls: [
67
- 'https://s5.ptbk.io/promptbook',
67
+ 'https://promptbook.s5.ptbk.io/',
68
68
  // Note: Servers 1-4 are not running
69
69
  ],
70
70
  },
71
+ /*
72
+ Note: Working on older version of Promptbook and not supported anymore
71
73
  {
72
74
  title: 'Pavol Promptbook Server',
73
75
  description: `Personal server of Pavol HejnΓ½ with simple testing server, DO NOT USE IT FOR PRODUCTION`,
@@ -75,6 +77,7 @@ const REMOTE_SERVER_URLS = [
75
77
  isAnonymousModeAllowed: true,
76
78
  urls: ['https://api.pavolhejny.com/promptbook'],
77
79
  },
80
+ */
78
81
  ];
79
82
  /**
80
83
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -2429,11 +2432,25 @@ function deserializeError(error) {
2429
2432
  */
2430
2433
  async function createRemoteClient(options) {
2431
2434
  const { remoteServerUrl } = options;
2432
- console.log('!!! Connecting to socket.io server', remoteServerUrl, {
2433
- retries: CONNECTION_RETRIES_LIMIT,
2434
- timeout: CONNECTION_TIMEOUT_MS,
2435
- path: '/socket.io',
2436
- });
2435
+ if (!isValidUrl(remoteServerUrl)) {
2436
+ throw new Error(`Invalid \`remoteServerUrl\`: "${remoteServerUrl}"`);
2437
+ }
2438
+ const remoteServerUrlParsed = new URL(remoteServerUrl);
2439
+ if (remoteServerUrlParsed.pathname !== '/' && remoteServerUrlParsed.pathname !== '') {
2440
+ remoteServerUrlParsed.pathname = '/';
2441
+ throw new Error(spaceTrim((block) => `
2442
+ Remote server requires root url \`/\`
2443
+
2444
+ You have provided \`remoteServerUrl\`:
2445
+ ${block(remoteServerUrl)}
2446
+
2447
+ But something like this is expected:
2448
+ ${block(remoteServerUrlParsed.href)}
2449
+
2450
+ Note: If you need to run multiple services on the same server, use 3rd or 4th degree subdomain
2451
+
2452
+ `));
2453
+ }
2437
2454
  return new Promise((resolve, reject) => {
2438
2455
  const socket = io(remoteServerUrl, {
2439
2456
  retries: CONNECTION_RETRIES_LIMIT,
@@ -13186,8 +13203,7 @@ function startRemoteServer(options) {
13186
13203
  apis: ['./src/remote-server/**/*.ts'], // Adjust path as needed
13187
13204
  };
13188
13205
  const swaggerSpec = swaggerJsdoc(swaggerOptions);
13189
- const rootPath = ''; // <- TODO: !!!! Remove after merging into feature/elysia+openai+swagger-2
13190
- app.use([`/api-docs`, `${rootPath}/api-docs`], swaggerUi.serve, swaggerUi.setup(swaggerSpec));
13206
+ app.use(`/api-docs`, swaggerUi.serve, swaggerUi.setup(swaggerSpec));
13191
13207
  const runningExecutionTasks = [];
13192
13208
  // <- TODO: [🀬] Identify the users
13193
13209
  // TODO: [🧠] Do here some garbage collection of finished tasks
@@ -13201,7 +13217,7 @@ function startRemoteServer(options) {
13201
13217
  * 200:
13202
13218
  * description: Server details in markdown format.
13203
13219
  */
13204
- app.get(['/', rootPath], async (request, response) => {
13220
+ app.get('/', async (request, response) => {
13205
13221
  var _a;
13206
13222
  if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.includes('socket.io')) {
13207
13223
  return;
@@ -13220,7 +13236,6 @@ function startRemoteServer(options) {
13220
13236
  ## Details
13221
13237
 
13222
13238
  **Server port:** ${port}
13223
- **Server root path:** ${rootPath}
13224
13239
  **Startup date:** ${startupDate.toISOString()}
13225
13240
  **Anonymouse mode:** ${isAnonymousModeAllowed ? 'enabled' : 'disabled'}
13226
13241
  **Application mode:** ${isApplicationModeAllowed ? 'enabled' : 'disabled'}
@@ -13290,7 +13305,7 @@ function startRemoteServer(options) {
13290
13305
  * identification:
13291
13306
  * type: object
13292
13307
  */
13293
- app.post([`/login`, `${rootPath}/login`], async (request, response) => {
13308
+ app.post(`/login`, async (request, response) => {
13294
13309
  if (!isApplicationModeAllowed || login === null) {
13295
13310
  response.status(400).send('Application mode is not allowed');
13296
13311
  return;
@@ -13346,7 +13361,7 @@ function startRemoteServer(options) {
13346
13361
  * items:
13347
13362
  * type: string
13348
13363
  */
13349
- app.get([`/books`, `${rootPath}/books`], async (request, response) => {
13364
+ app.get(`/books`, async (request, response) => {
13350
13365
  if (collection === null) {
13351
13366
  response.status(500).send('No collection available');
13352
13367
  return;
@@ -13379,7 +13394,7 @@ function startRemoteServer(options) {
13379
13394
  * 404:
13380
13395
  * description: Book not found.
13381
13396
  */
13382
- app.get([`/books/*`, `${rootPath}/books/*`], async (request, response) => {
13397
+ app.get(`/books/*`, async (request, response) => {
13383
13398
  try {
13384
13399
  if (collection === null) {
13385
13400
  response.status(500).send('No collection nor books available');
@@ -13447,10 +13462,10 @@ function startRemoteServer(options) {
13447
13462
  * items:
13448
13463
  * type: object
13449
13464
  */
13450
- app.get([`/executions`, `${rootPath}/executions`], async (request, response) => {
13465
+ app.get(`/executions`, async (request, response) => {
13451
13466
  response.send(runningExecutionTasks.map((runningExecutionTask) => exportExecutionTask(runningExecutionTask, false)));
13452
13467
  });
13453
- app.get([`/executions/last`, `${rootPath}/executions/last`], async (request, response) => {
13468
+ app.get(`/executions/last`, async (request, response) => {
13454
13469
  // TODO: [🀬] Filter only for user
13455
13470
  if (runningExecutionTasks.length === 0) {
13456
13471
  response.status(404).send('No execution tasks found');
@@ -13459,7 +13474,7 @@ function startRemoteServer(options) {
13459
13474
  const lastExecutionTask = runningExecutionTasks[runningExecutionTasks.length - 1];
13460
13475
  response.send(exportExecutionTask(lastExecutionTask, true));
13461
13476
  });
13462
- app.get([`/executions/:taskId`, `${rootPath}/executions/:taskId`], async (request, response) => {
13477
+ app.get(`/executions/:taskId`, async (request, response) => {
13463
13478
  const { taskId } = request.params;
13464
13479
  // TODO: [🀬] Filter only for user
13465
13480
  const executionTask = runningExecutionTasks.find((executionTask) => executionTask.taskId === taskId);
@@ -13500,7 +13515,7 @@ function startRemoteServer(options) {
13500
13515
  * 400:
13501
13516
  * description: Invalid input.
13502
13517
  */
13503
- app.post([`/executions/new`, `${rootPath}/executions/new`], async (request, response) => {
13518
+ app.post(`/executions/new`, async (request, response) => {
13504
13519
  try {
13505
13520
  const { inputParameters, identification /* <- [🀬] */ } = request.body;
13506
13521
  const pipelineUrl = request.body.pipelineUrl || request.body.book;