@promptbook/remote-server 0.112.0-115 → 0.112.0-117

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
@@ -9,19 +9,18 @@ import { Server } from 'socket.io';
9
9
  import { stat, access, constants, readFile, writeFile, readdir, mkdir, watch, rm } from 'fs/promises';
10
10
  import { Readability } from '@mozilla/readability';
11
11
  import { JSDOM } from 'jsdom';
12
- import { SHA256 } from 'crypto-js';
12
+ import CryptoJS from 'crypto-js';
13
13
  import hexEncoder from 'crypto-js/enc-hex';
14
- import { Converter } from 'showdown';
14
+ import showdown from 'showdown';
15
15
  import * as OpenApiValidator from 'express-openapi-validator';
16
16
  import swaggerUi from 'swagger-ui-express';
17
17
  import { createElement } from 'react';
18
18
  import { renderToStaticMarkup } from 'react-dom/server';
19
19
  import { Subject, BehaviorSubject } from 'rxjs';
20
- import { randomBytes } from 'crypto';
21
20
  import moment from 'moment';
22
21
  import { lookup, extension } from 'mime-types';
23
22
  import sha256 from 'crypto-js/sha256';
24
- import { parse, unparse } from 'papaparse';
23
+ import papaparse from 'papaparse';
25
24
  import { fileSearchTool, tool, Agent as Agent$1, webSearchTool, run, setDefaultOpenAIClient, setDefaultOpenAIKey } from '@openai/agents';
26
25
  import Bottleneck from 'bottleneck';
27
26
  import OpenAI from 'openai';
@@ -40,7 +39,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
40
39
  * @generated
41
40
  * @see https://github.com/webgptorg/promptbook
42
41
  */
43
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-115';
42
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-117';
44
43
  /**
45
44
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
46
45
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1948,7 +1947,7 @@ class ParseError extends Error {
1948
1947
  * @private internal helper function
1949
1948
  */
1950
1949
  function $randomToken(randomness) {
1951
- return randomBytes(randomness).toString('hex');
1950
+ return CryptoJS.lib.WordArray.random(randomness).toString(CryptoJS.enc.Hex);
1952
1951
  }
1953
1952
  // TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
1954
1953
  // TODO: Maybe use nanoid instead https://github.com/ai/nanoid
@@ -5492,7 +5491,7 @@ function normalizeToKebabCase(text) {
5492
5491
  * @public exported from `@promptbook/editable`
5493
5492
  */
5494
5493
  function knowledgeSourceContentToName(knowledgeSourceContent) {
5495
- const hash = SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
5494
+ const hash = CryptoJS.SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
5496
5495
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
5497
5496
  .toString( /* hex */)
5498
5497
  .substring(0, 20);
@@ -6486,7 +6485,7 @@ function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO:
6486
6485
  console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
6487
6486
  value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
6488
6487
  }
6489
- const csv = parse(value, settings);
6488
+ const csv = papaparse.parse(value, settings);
6490
6489
  return csv;
6491
6490
  }
6492
6491
 
@@ -6571,10 +6570,10 @@ const CsvFormatParser = {
6571
6570
  i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
6572
6571
  );
6573
6572
  */
6574
- await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
6573
+ await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
6575
6574
  }
6576
6575
  }
6577
- return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
6576
+ return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
6578
6577
  },
6579
6578
  },
6580
6579
  {
@@ -6602,7 +6601,7 @@ const CsvFormatParser = {
6602
6601
  return /* not await */ mapCallback({ [key]: value }, index, array.length);
6603
6602
  }));
6604
6603
  }));
6605
- return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
6604
+ return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
6606
6605
  },
6607
6606
  },
6608
6607
  ],
@@ -9531,7 +9530,7 @@ async function getScraperIntermediateSource(source, options) {
9531
9530
  const { filename: sourceFilename, url } = source;
9532
9531
  const { rootDirname, cacheDirname, intermediateFilesStrategy, extension, isVerbose } = options;
9533
9532
  // TODO: [👬] DRY
9534
- const hash = SHA256(
9533
+ const hash = CryptoJS.SHA256(
9535
9534
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
9536
9535
  hexEncoder.parse(sourceFilename || url || 'untitled'))
9537
9536
  .toString( /* hex */)
@@ -9622,7 +9621,7 @@ $scrapersMetadataRegister.register(websiteScraperMetadata);
9622
9621
  * @private utility of `WebsiteScraper`
9623
9622
  */
9624
9623
  function createShowdownConverter() {
9625
- return new Converter({
9624
+ return new showdown.Converter({
9626
9625
  flavor: 'github',
9627
9626
  /*
9628
9627
  > import showdownHighlight from 'showdown-highlight';
@@ -10814,7 +10813,7 @@ function normalizeWhitespaces(sentence) {
10814
10813
  * @public exported from `@promptbook/utils`
10815
10814
  */
10816
10815
  function computeHash(value) {
10817
- return SHA256(hexEncoder.parse(spaceTrim$1(valueToString(value)))).toString( /* hex */);
10816
+ return CryptoJS.SHA256(hexEncoder.parse(spaceTrim$1(valueToString(value)))).toString( /* hex */);
10818
10817
  }
10819
10818
  // TODO: [🥬][🥬] Use this ACRY
10820
10819
 
@@ -39669,7 +39668,7 @@ function emitAgentLlmExecutionToolsAssistantPreparationProgress(options) {
39669
39668
  * Computes one stable hash from a JSON-serializable value.
39670
39669
  */
39671
39670
  function computeJsonHash$1(value) {
39672
- return SHA256(JSON.stringify(value)).toString();
39671
+ return CryptoJS.SHA256(JSON.stringify(value)).toString();
39673
39672
  }
39674
39673
  /**
39675
39674
  * Handles OpenAI AgentKit-backed executions for `AgentLlmExecutionTools`.
@@ -39827,7 +39826,7 @@ AgentLlmExecutionToolsAgentKitRunner.vectorStoreCache = new Map();
39827
39826
  * Computes one stable hash from a JSON-serializable value.
39828
39827
  */
39829
39828
  function computeJsonHash(value) {
39830
- return SHA256(JSON.stringify(value)).toString();
39829
+ return CryptoJS.SHA256(JSON.stringify(value)).toString();
39831
39830
  }
39832
39831
  /**
39833
39832
  * Removes assistant-managed requirements before the prompt is executed via OpenAI Assistants.
@@ -40629,7 +40628,7 @@ class AgentLlmExecutionTools {
40629
40628
  * Returns a virtual model name representing the agent behavior.
40630
40629
  */
40631
40630
  get modelName() {
40632
- const hash = SHA256(hexEncoder.parse(this.options.agentSource)).toString( /* hex */);
40631
+ const hash = CryptoJS.SHA256(hexEncoder.parse(this.options.agentSource)).toString( /* hex */);
40633
40632
  const agentId = hash.substring(0, 10);
40634
40633
  return (normalizeToKebabCase(this.title) + '-' + agentId);
40635
40634
  }