@promptbook/remote-server 0.102.0-0 → 0.102.0-2

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/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('express-openapi-validator'), require('http'), require('socket.io'), require('spacetrim'), require('swagger-ui-express'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), 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', 'express-openapi-validator', 'http', 'socket.io', 'spacetrim', 'swagger-ui-express', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', '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.OpenApiValidator, global.http, global.socket_io, global.spaceTrim, global.swaggerUi, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse));
5
- })(this, (function (exports, colors, express, OpenApiValidator, http, socket_io, spaceTrim, swaggerUi, waitasecond, crypto, child_process, promises, path, rxjs, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('spacetrim'), require('swagger-ui-express'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse'), require('react'), require('react-dom/server')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'express-openapi-validator', 'http', 'socket.io', 'spacetrim', 'swagger-ui-express', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse', 'react', 'react-dom/server'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.OpenApiValidator, global.http, global.socket_io, global.spaceTrim, global.swaggerUi, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse, global.react, global.server));
5
+ })(this, (function (exports, colors, express, OpenApiValidator, http, socket_io, spaceTrim, swaggerUi, waitasecond, crypto, child_process, promises, path, rxjs, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse, react, server) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -47,7 +47,7 @@
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.102.0-0';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.102.0-2';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -8106,6 +8106,44 @@
8106
8106
  * Note: [💞] Ignore a discrepancy between file name and entity name
8107
8107
  */
8108
8108
 
8109
+ const h = react.createElement;
8110
+ function KeyVal(props) {
8111
+ return h('div', { className: 'flex items-start gap-2' }, h('div', { className: 'font-semibold min-w-[14rem]' }, props.label), h('div', { className: 'text-gray-800' }, props.value));
8112
+ }
8113
+ function List(props) {
8114
+ var _a;
8115
+ if (!((_a = props.items) === null || _a === void 0 ? void 0 : _a.length))
8116
+ return h('span', { className: 'text-gray-500' }, 'none');
8117
+ return h('ul', { className: 'list-disc ml-6' }, ...props.items.map((item, i) => h('li', { key: String(i), className: 'break-all' }, item)));
8118
+ }
8119
+ function Section(props) {
8120
+ return h('section', { className: 'mt-8' }, h('h2', { className: 'text-xl font-semibold mb-2' }, props.title), props.children);
8121
+ }
8122
+ function ServerBody({ info }) {
8123
+ var _a;
8124
+ return h('div', { className: 'max-w-4xl mx-auto p-6' }, h('h1', { className: 'text-3xl font-bold mb-4' }, 'Promptbook Server'), h('div', { className: 'space-y-2' }, h(KeyVal, { label: 'Book language version:', value: info.bookLanguageVersion }), h(KeyVal, { label: 'Promptbook engine version:', value: info.promptbookEngineVersion }), h(KeyVal, { label: 'Node.js version:', value: info.nodeVersion }), h(KeyVal, { label: 'Server port:', value: String((_a = info.port) !== null && _a !== void 0 ? _a : '') }), h(KeyVal, { label: 'Startup date:', value: info.startupDate }), h(KeyVal, {
8125
+ label: 'Anonymous mode:',
8126
+ value: info.isAnonymousModeAllowed ? 'enabled' : 'disabled',
8127
+ }), h(KeyVal, {
8128
+ label: 'Application mode:',
8129
+ value: info.isApplicationModeAllowed ? 'enabled' : 'disabled',
8130
+ }), h(KeyVal, { label: 'Running executions:', value: String(info.runningExecutions) })), h(Section, { title: 'Pipelines in collection' }, h(List, { items: info.pipelines })), h(Section, { title: 'Paths' }, h(List, { items: info.paths })), h(Section, { title: 'Instructions' }, h('ol', { className: 'list-decimal ml-6 space-y-1' }, h('li', null, 'The client ', h('a', { href: 'https://www.npmjs.com/package/@promptbook/remote-client', className: 'text-blue-600 underline' }, 'https://www.npmjs.com/package/@promptbook/remote-client')), h('li', null, 'OpenAI compatible client ', h('span', { className: 'text-gray-500' }, '(Not working yet)')), h('li', null, 'REST API')), h('p', { className: 'mt-2' }, 'For more information look at: ', h('a', { href: 'https://github.com/webgptorg/promptbook', className: 'text-blue-600 underline' }, 'https://github.com/webgptorg/promptbook'))));
8131
+ }
8132
+ function HtmlDoc({ info }) {
8133
+ return h('html', { lang: 'en' }, h('head', null, h('meta', { charSet: 'UTF-8' }), h('meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0' }), h('title', null, 'Promptbook Server'), h('link', {
8134
+ href: 'https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css',
8135
+ rel: 'stylesheet',
8136
+ })), h('body', { className: 'bg-gray-50 text-gray-900' }, h('div', { id: 'root' }, h(ServerBody, { info }))));
8137
+ }
8138
+ /**
8139
+ * Render full HTML for the server index using React SSR without requiring TSX/JSX compiler flags.
8140
+ *
8141
+ * @private internal utility of Remote Server
8142
+ */
8143
+ function renderServerIndexHtml(info) {
8144
+ return '<!DOCTYPE html>' + server.renderToStaticMarkup(h(HtmlDoc, { info }));
8145
+ }
8146
+
8109
8147
  /**
8110
8148
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
8111
8149
  *
@@ -8262,57 +8300,82 @@
8262
8300
  if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.includes('socket.io')) {
8263
8301
  return;
8264
8302
  }
8265
- response.type('text/markdown').send(await spaceTrim.spaceTrim(async (block) => `
8266
- # Promptbook
8303
+ if (options.isRichUi !== false) {
8304
+ // Serve rich React + Tailwind UI with server info injected
8305
+ const serverInfo = {
8306
+ bookLanguageVersion: BOOK_LANGUAGE_VERSION,
8307
+ promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
8308
+ nodeVersion: process.version,
8309
+ port,
8310
+ startupDate: startupDate.toISOString(),
8311
+ isAnonymousModeAllowed,
8312
+ isApplicationModeAllowed,
8313
+ pipelines: !isApplicationModeAllowed || collection === null
8314
+ ? []
8315
+ : await collection.listPipelines(),
8316
+ runningExecutions: runningExecutionTasks.length,
8317
+ paths: [
8318
+ ...app._router.stack
8319
+ .map(({ route }) => (route === null || route === void 0 ? void 0 : route.path) || null)
8320
+ .filter((path) => path !== null),
8321
+ '/api-docs',
8322
+ ],
8323
+ };
8324
+ response.type('text/html').send(renderServerIndexHtml(serverInfo));
8325
+ }
8326
+ else {
8327
+ response.type('text/markdown').send(await spaceTrim.spaceTrim(async (block) => `
8328
+ # Promptbook
8267
8329
 
8268
- > ${block(CLAIM)}
8330
+ > ${block(CLAIM)}
8269
8331
 
8270
- **Book language version:** ${BOOK_LANGUAGE_VERSION}
8271
- **Promptbook engine version:** ${PROMPTBOOK_ENGINE_VERSION}
8272
- **Node.js version:** ${process.version /* <- TODO: [🧠] Is it secure to expose this */}
8332
+ **Book language version:** ${BOOK_LANGUAGE_VERSION}
8333
+ **Promptbook engine version:** ${PROMPTBOOK_ENGINE_VERSION}
8334
+ **Node.js version:** ${process.version /* <- TODO: [🧠] Is it secure to expose this */}
8273
8335
 
8274
- ---
8336
+ ---
8275
8337
 
8276
- ## Details
8338
+ ## Details
8277
8339
 
8278
- **Server port:** ${port}
8279
- **Startup date:** ${startupDate.toISOString()}
8280
- **Anonymous mode:** ${isAnonymousModeAllowed ? 'enabled' : 'disabled'}
8281
- **Application mode:** ${isApplicationModeAllowed ? 'enabled' : 'disabled'}
8282
- ${block(!isApplicationModeAllowed || collection === null
8283
- ? ''
8284
- : '**Pipelines in collection:**\n' +
8285
- (await collection.listPipelines())
8286
- .map((pipelineUrl) => `- ${pipelineUrl}`)
8287
- .join('\n'))}
8288
- **Running executions:** ${runningExecutionTasks.length}
8340
+ **Server port:** ${port}
8341
+ **Startup date:** ${startupDate.toISOString()}
8342
+ **Anonymous mode:** ${isAnonymousModeAllowed ? 'enabled' : 'disabled'}
8343
+ **Application mode:** ${isApplicationModeAllowed ? 'enabled' : 'disabled'}
8344
+ ${block(!isApplicationModeAllowed || collection === null
8345
+ ? ''
8346
+ : '**Pipelines in collection:**\n' +
8347
+ (await collection.listPipelines())
8348
+ .map((pipelineUrl) => `- ${pipelineUrl}`)
8349
+ .join('\n'))}
8350
+ **Running executions:** ${runningExecutionTasks.length}
8289
8351
 
8290
- ---
8352
+ ---
8291
8353
 
8292
- ## Paths
8354
+ ## Paths
8293
8355
 
8294
- ${block([
8295
- ...app._router.stack
8296
- .map(({ route }) => (route === null || route === void 0 ? void 0 : route.path) || null)
8297
- .filter((path) => path !== null),
8298
- '/api-docs',
8299
- ]
8300
- .map((path) => `- ${path}`)
8301
- .join('\n'))}
8356
+ ${block([
8357
+ ...app._router.stack
8358
+ .map(({ route }) => (route === null || route === void 0 ? void 0 : route.path) || null)
8359
+ .filter((path) => path !== null),
8360
+ '/api-docs',
8361
+ ]
8362
+ .map((path) => `- ${path}`)
8363
+ .join('\n'))}
8302
8364
 
8303
- ---
8365
+ ---
8304
8366
 
8305
- ## Instructions
8367
+ ## Instructions
8306
8368
 
8307
- To connect to this server use:
8369
+ To connect to this server use:
8308
8370
 
8309
- 1) The client https://www.npmjs.com/package/@promptbook/remote-client
8310
- 2) OpenAI compatible client *(Not working yet)*
8311
- 3) REST API
8371
+ 1) The client https://www.npmjs.com/package/@promptbook/remote-client
8372
+ 2) OpenAI compatible client *(Not working yet)*
8373
+ 3) REST API
8312
8374
 
8313
- For more information look at:
8314
- https://github.com/webgptorg/promptbook
8315
- `));
8375
+ For more information look at:
8376
+ https://github.com/webgptorg/promptbook
8377
+ `));
8378
+ }
8316
8379
  });
8317
8380
  app.post(`/login`, async (request, response) => {
8318
8381
  if (!isApplicationModeAllowed || login === null) {