@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 CHANGED
@@ -22,6 +22,8 @@ import moment from 'moment';
22
22
  import express from 'express';
23
23
  import http from 'http';
24
24
  import { Server } from 'socket.io';
25
+ import swaggerJsdoc from 'swagger-jsdoc';
26
+ import swaggerUi from 'swagger-ui-express';
25
27
  import { io } from 'socket.io-client';
26
28
  import Anthropic from '@anthropic-ai/sdk';
27
29
  import { OpenAIClient, AzureKeyCredential } from '@azure/openai';
@@ -44,7 +46,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
44
46
  * @generated
45
47
  * @see https://github.com/webgptorg/promptbook
46
48
  */
47
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-4';
49
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-6';
48
50
  /**
49
51
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
50
52
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -12614,9 +12616,37 @@ function startRemoteServer(options) {
12614
12616
  response.setHeader('X-Powered-By', 'Promptbook engine');
12615
12617
  next();
12616
12618
  });
12619
+ const swaggerOptions = {
12620
+ definition: {
12621
+ openapi: '3.0.0',
12622
+ info: {
12623
+ title: 'Promptbook Remote Server API',
12624
+ version: '1.0.0',
12625
+ description: 'API documentation for the Promptbook Remote Server',
12626
+ },
12627
+ servers: [
12628
+ {
12629
+ url: `http://localhost:${port}${rootPath}`,
12630
+ },
12631
+ ],
12632
+ },
12633
+ apis: ['./src/remote-server/**/*.ts'], // Adjust path as needed
12634
+ };
12635
+ const swaggerSpec = swaggerJsdoc(swaggerOptions);
12636
+ app.use(`${rootPath}/api-docs`, swaggerUi.serve, swaggerUi.setup(swaggerSpec));
12617
12637
  const runningExecutionTasks = [];
12618
12638
  // <- TODO: [🤬] Identify the users
12619
12639
  // TODO: [🧠] Do here some garbage collection of finished tasks
12640
+ /**
12641
+ * @swagger
12642
+ * /:
12643
+ * get:
12644
+ * summary: Get server details
12645
+ * description: Returns details about the Promptbook server.
12646
+ * responses:
12647
+ * 200:
12648
+ * description: Server details in markdown format.
12649
+ */
12620
12650
  app.get(['/', rootPath], async (request, response) => {
12621
12651
  var _a;
12622
12652
  if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.includes('socket.io')) {
@@ -12674,6 +12704,22 @@ function startRemoteServer(options) {
12674
12704
  `));
12675
12705
  });
12676
12706
  // TODO: !!!!!! Add login route
12707
+ /**
12708
+ * @swagger
12709
+ * /books:
12710
+ * get:
12711
+ * summary: List all books
12712
+ * description: Returns a list of all available books in the collection.
12713
+ * responses:
12714
+ * 200:
12715
+ * description: A list of books.
12716
+ * content:
12717
+ * application/json:
12718
+ * schema:
12719
+ * type: array
12720
+ * items:
12721
+ * type: string
12722
+ */
12677
12723
  app.get(`${rootPath}/books`, async (request, response) => {
12678
12724
  if (collection === null) {
12679
12725
  response.status(500).send('No collection available');
@@ -12684,6 +12730,29 @@ function startRemoteServer(options) {
12684
12730
  response.send(pipelines);
12685
12731
  });
12686
12732
  // TODO: [🧠] Is it secure / good idea to expose source codes of hosted books
12733
+ /**
12734
+ * @swagger
12735
+ * /books/{bookId}:
12736
+ * get:
12737
+ * summary: Get book content
12738
+ * description: Returns the content of a specific book.
12739
+ * parameters:
12740
+ * - in: path
12741
+ * name: bookId
12742
+ * required: true
12743
+ * schema:
12744
+ * type: string
12745
+ * description: The ID of the book to retrieve.
12746
+ * responses:
12747
+ * 200:
12748
+ * description: The content of the book.
12749
+ * content:
12750
+ * text/markdown:
12751
+ * schema:
12752
+ * type: string
12753
+ * 404:
12754
+ * description: Book not found.
12755
+ */
12687
12756
  app.get(`${rootPath}/books/*`, async (request, response) => {
12688
12757
  try {
12689
12758
  if (collection === null) {
@@ -12738,6 +12807,22 @@ function startRemoteServer(options) {
12738
12807
  };
12739
12808
  }
12740
12809
  }
12810
+ /**
12811
+ * @swagger
12812
+ * /executions:
12813
+ * get:
12814
+ * summary: List all executions
12815
+ * description: Returns a list of all running execution tasks.
12816
+ * responses:
12817
+ * 200:
12818
+ * description: A list of execution tasks.
12819
+ * content:
12820
+ * application/json:
12821
+ * schema:
12822
+ * type: array
12823
+ * items:
12824
+ * type: object
12825
+ */
12741
12826
  app.get(`${rootPath}/executions`, async (request, response) => {
12742
12827
  response.send(runningExecutionTasks.map((runningExecutionTask) => exportExecutionTask(runningExecutionTask, false)));
12743
12828
  });
@@ -12762,6 +12847,35 @@ function startRemoteServer(options) {
12762
12847
  }
12763
12848
  response.send(exportExecutionTask(executionTask, true));
12764
12849
  });
12850
+ /**
12851
+ * @swagger
12852
+ * /executions/new:
12853
+ * post:
12854
+ * summary: Start a new execution
12855
+ * description: Starts a new execution task for a given pipeline.
12856
+ * requestBody:
12857
+ * required: true
12858
+ * content:
12859
+ * application/json:
12860
+ * schema:
12861
+ * type: object
12862
+ * properties:
12863
+ * pipelineUrl:
12864
+ * type: string
12865
+ * inputParameters:
12866
+ * type: object
12867
+ * identification:
12868
+ * type: object
12869
+ * responses:
12870
+ * 200:
12871
+ * description: The newly created execution task.
12872
+ * content:
12873
+ * application/json:
12874
+ * schema:
12875
+ * type: object
12876
+ * 400:
12877
+ * description: Invalid input.
12878
+ */
12765
12879
  app.post(`${rootPath}/executions/new`, async (request, response) => {
12766
12880
  try {
12767
12881
  const { inputParameters, identification /* <- [🤬] */ } = request.body;
@@ -12939,6 +13053,15 @@ function startRemoteServer(options) {
12939
13053
  }
12940
13054
  let isDestroyed = false;
12941
13055
  return {
13056
+ get httpServer() {
13057
+ return httpServer;
13058
+ },
13059
+ get expressApp() {
13060
+ return app;
13061
+ },
13062
+ get socketIoServer() {
13063
+ return server;
13064
+ },
12942
13065
  get isDestroyed() {
12943
13066
  return isDestroyed;
12944
13067
  },