@promptbook/remote-server 0.89.0-7 → 0.89.0-9

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.
Files changed (25) hide show
  1. package/esm/index.es.js +45 -9
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +4 -0
  4. package/esm/typings/src/_packages/remote-client.index.d.ts +6 -6
  5. package/esm/typings/src/_packages/remote-server.index.d.ts +6 -6
  6. package/esm/typings/src/_packages/types.index.d.ts +10 -16
  7. package/esm/typings/src/errors/0-index.d.ts +3 -0
  8. package/esm/typings/src/errors/PromptbookFetchError.d.ts +9 -0
  9. package/esm/typings/src/llm-providers/_common/register/$provideEnvFilepath.d.ts +12 -0
  10. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +2 -8
  11. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -0
  12. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +5 -3
  13. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -0
  14. package/esm/typings/src/remote-server/socket-types/_subtypes/{PromptbookServer_Identification.d.ts → Identification.d.ts} +3 -3
  15. package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +2 -2
  16. package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Request.d.ts +2 -2
  17. package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts +2 -2
  18. package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +2 -2
  19. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +63 -21
  20. package/esm/typings/src/scrapers/_common/utils/{scraperFetch.d.ts → promptbookFetch.d.ts} +2 -2
  21. package/package.json +2 -2
  22. package/umd/index.umd.js +45 -9
  23. package/umd/index.umd.js.map +1 -1
  24. package/esm/typings/src/playground/BrjappConnector.d.ts +0 -67
  25. package/esm/typings/src/playground/brjapp-api-schema.d.ts +0 -12879
package/esm/index.es.js CHANGED
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
33
33
  * @generated
34
34
  * @see https://github.com/webgptorg/promptbook
35
35
  */
36
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-7';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-9';
37
37
  /**
38
38
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
39
39
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -454,6 +454,19 @@ class PipelineUrlError extends Error {
454
454
  }
455
455
  }
456
456
 
457
+ /**
458
+ * Error thrown when a fetch request fails
459
+ *
460
+ * @public exported from `@promptbook/core`
461
+ */
462
+ class PromptbookFetchError extends Error {
463
+ constructor(message) {
464
+ super(message);
465
+ this.name = 'PromptbookFetchError';
466
+ Object.setPrototypeOf(this, PromptbookFetchError.prototype);
467
+ }
468
+ }
469
+
457
470
  /**
458
471
  * Make error report URL for the given error
459
472
  *
@@ -560,6 +573,7 @@ const COMMON_JAVASCRIPT_ERRORS = {
560
573
  URIError,
561
574
  AggregateError,
562
575
  AuthenticationError,
576
+ PromptbookFetchError,
563
577
  /*
564
578
  Note: Not widely supported
565
579
  > InternalError,
@@ -3567,17 +3581,24 @@ function titleToName(value) {
3567
3581
  /**
3568
3582
  * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
3569
3583
  *
3570
- * @private as default `fetch` function used in Promptbook scrapers
3584
+ * @public exported from `@promptbook/core`
3571
3585
  */
3572
- const scraperFetch = async (url, init) => {
3586
+ const promptbookFetch = async (urlOrRequest, init) => {
3573
3587
  try {
3574
- return await fetch(url, init);
3588
+ return await fetch(urlOrRequest, init);
3575
3589
  }
3576
3590
  catch (error) {
3577
3591
  if (!(error instanceof Error)) {
3578
3592
  throw error;
3579
3593
  }
3580
- throw new KnowledgeScrapeError(spaceTrim$1((block) => `
3594
+ let url;
3595
+ if (typeof urlOrRequest === 'string') {
3596
+ url = urlOrRequest;
3597
+ }
3598
+ else if (urlOrRequest instanceof Request) {
3599
+ url = urlOrRequest.url;
3600
+ }
3601
+ throw new PromptbookFetchError(spaceTrim$1((block) => `
3581
3602
  Can not fetch "${url}"
3582
3603
 
3583
3604
  Fetch error:
@@ -3598,7 +3619,7 @@ const scraperFetch = async (url, init) => {
3598
3619
  async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
3599
3620
  // console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
3600
3621
  var _a;
3601
- const { fetch = scraperFetch } = tools;
3622
+ const { fetch = promptbookFetch } = tools;
3602
3623
  const { knowledgeSourceContent } = knowledgeSource;
3603
3624
  let { name } = knowledgeSource;
3604
3625
  const { rootDirname = null,
@@ -6935,8 +6956,19 @@ function startRemoteServer(options) {
6935
6956
  const username = request.body.username;
6936
6957
  const password = request.body.password;
6937
6958
  const appId = request.body.appId;
6938
- const identification = await login({ username, password, appId });
6939
- response.status(201).send({ identification });
6959
+ const { isSuccess, error, message, identification } = await login({
6960
+ username,
6961
+ password,
6962
+ appId,
6963
+ rawRequest: request,
6964
+ rawResponse: response,
6965
+ });
6966
+ response.status(201).send({
6967
+ isSuccess,
6968
+ message,
6969
+ error: error ? serializeError(error) : undefined,
6970
+ identification,
6971
+ });
6940
6972
  return;
6941
6973
  }
6942
6974
  catch (error) {
@@ -6944,7 +6976,11 @@ function startRemoteServer(options) {
6944
6976
  throw error;
6945
6977
  }
6946
6978
  if (error instanceof AuthenticationError) {
6947
- response.status(401).send({ error: serializeError(error) });
6979
+ response.status(401).send({
6980
+ isSuccess: false,
6981
+ message: error.message,
6982
+ error: serializeError(error),
6983
+ });
6948
6984
  }
6949
6985
  console.warn(`Login function thrown different error than AuthenticationError`, {
6950
6986
  error,