@promptbook/remote-server 0.100.4-0 → 0.101.0-1

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 (81) hide show
  1. package/esm/index.es.js +39 -7
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +4 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +4 -2
  5. package/esm/typings/src/_packages/markdown-utils.index.d.ts +14 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +4 -6
  7. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +21 -0
  8. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/AgentModelRequirements.d.ts +1 -1
  9. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/AgentSourceParseResult.d.ts +3 -1
  10. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createAgentModelRequirements.d.ts +2 -2
  11. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createAgentModelRequirementsWithCommitments.d.ts +3 -3
  12. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createCommitmentRegex.d.ts +2 -2
  13. package/esm/typings/src/book-2.0/agent-source/extractMetaLinks.d.ts +8 -0
  14. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +4 -19
  15. package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +9 -0
  16. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +1 -1
  17. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +1 -1
  18. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +1 -1
  19. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +1 -1
  20. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +1 -1
  21. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +1 -1
  22. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +1 -1
  23. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +1 -1
  24. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +1 -1
  25. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +1 -1
  26. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +1 -1
  27. package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +1 -1
  28. package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +1 -1
  29. package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +1 -1
  30. package/esm/typings/src/book-2.0/commitments/{_misc → _base}/ParsedCommitment.d.ts +1 -1
  31. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  32. package/esm/typings/src/book-2.0/utils/extractAgentMetadata.d.ts +17 -0
  33. package/esm/typings/src/book-2.0/utils/extractProfileImageFromSystemMessage.d.ts +12 -0
  34. package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +10 -0
  35. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +10 -0
  36. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +1 -1
  37. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +2 -8
  38. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  39. package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +16 -0
  40. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  41. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +21 -0
  42. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.test.d.ts +1 -0
  43. package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +1 -1
  44. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +2 -1
  45. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -1
  46. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -1
  47. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +2 -1
  48. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -0
  49. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +3 -1
  50. package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +2 -0
  51. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +13 -0
  52. package/esm/typings/src/utils/markdown/humanizeAiText.test.d.ts +1 -0
  53. package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +13 -0
  54. package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +13 -0
  55. package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +13 -0
  56. package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +13 -0
  57. package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +8 -0
  58. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +12 -0
  59. package/esm/typings/src/utils/markdown/promptbookifyAiText.test.d.ts +1 -0
  60. package/esm/typings/src/utils/markdown/removeMarkdownLinks.d.ts +11 -0
  61. package/esm/typings/src/utils/markdown/removeMarkdownLinks.test.d.ts +4 -0
  62. package/esm/typings/src/utils/normalization/capitalize.d.ts +2 -0
  63. package/esm/typings/src/utils/normalization/decapitalize.d.ts +3 -1
  64. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +2 -0
  65. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +2 -0
  66. package/esm/typings/src/utils/normalization/normalizeWhitespaces.d.ts +2 -0
  67. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +2 -0
  68. package/esm/typings/src/utils/parseNumber.d.ts +1 -0
  69. package/esm/typings/src/utils/removeEmojis.d.ts +2 -0
  70. package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
  71. package/esm/typings/src/utils/serialization/deepClone.d.ts +1 -0
  72. package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
  73. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -0
  74. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
  75. package/esm/typings/src/version.d.ts +1 -1
  76. package/package.json +2 -2
  77. package/umd/index.umd.js +44 -11
  78. package/umd/index.umd.js.map +1 -1
  79. package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +0 -24
  80. package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +0 -39
  81. /package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/removeCommentsFromSystemMessage.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -11,9 +11,6 @@ import { spawn } from 'child_process';
11
11
  import { stat, access, constants, readFile, writeFile, readdir, mkdir } from 'fs/promises';
12
12
  import { join, basename, dirname, isAbsolute } from 'path';
13
13
  import { Subject } from 'rxjs';
14
- import parserHtml from 'prettier/parser-html';
15
- import parserMarkdown from 'prettier/parser-markdown';
16
- import { format } from 'prettier/standalone';
17
14
  import hexEncoder from 'crypto-js/enc-hex';
18
15
  import sha256 from 'crypto-js/sha256';
19
16
  import { SHA256 } from 'crypto-js';
@@ -34,7 +31,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
34
31
  * @generated
35
32
  * @see https://github.com/webgptorg/promptbook
36
33
  */
37
- const PROMPTBOOK_ENGINE_VERSION = '0.100.4-0';
34
+ const PROMPTBOOK_ENGINE_VERSION = '0.101.0-1';
38
35
  /**
39
36
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
40
37
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1299,6 +1296,7 @@ function checkSerializableAsJson(options) {
1299
1296
  /**
1300
1297
  * Creates a deep clone of the given object
1301
1298
  *
1299
+ * Note: [🔂] This function is idempotent.
1302
1300
  * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
1303
1301
  *
1304
1302
  * @param objectValue The object to clone.
@@ -1464,6 +1462,7 @@ function isValidPromptbookVersion(version) {
1464
1462
  /**
1465
1463
  * Tests if given string is valid URL.
1466
1464
  *
1465
+ * Note: [🔂] This function is idempotent.
1467
1466
  * Note: Dataurl are considered perfectly valid.
1468
1467
  * Note: There are two similar functions:
1469
1468
  * - `isValidUrl` which tests any URL
@@ -2372,8 +2371,18 @@ function validatePipelineString(pipelineString) {
2372
2371
  * @private withing the package because of HUGE size of prettier dependency
2373
2372
  */
2374
2373
  function prettifyMarkdown(content) {
2374
+ // In browser/Next.js environments, just return the original content
2375
+ // since prettier parsers are not available and would cause bundling issues
2376
+ if (typeof window !== 'undefined') {
2377
+ return content;
2378
+ }
2375
2379
  try {
2376
- return format(content, {
2380
+ // Use dynamic require to avoid static imports that cause bundling issues
2381
+ // This will only work in Node.js environments
2382
+ const prettierStandalone = eval('require')('prettier/standalone');
2383
+ const parserMarkdown = eval('require')('prettier/parser-markdown');
2384
+ const parserHtml = eval('require')('prettier/parser-html');
2385
+ return prettierStandalone.format(content, {
2377
2386
  parser: 'markdown',
2378
2387
  plugins: [parserMarkdown, parserHtml],
2379
2388
  // TODO: DRY - make some import or auto-copy of .prettierrc
@@ -2401,6 +2410,8 @@ function prettifyMarkdown(content) {
2401
2410
  /**
2402
2411
  * Makes first letter of a string uppercase
2403
2412
  *
2413
+ * Note: [🔂] This function is idempotent.
2414
+ *
2404
2415
  * @public exported from `@promptbook/utils`
2405
2416
  */
2406
2417
  function capitalize(word) {
@@ -2932,7 +2943,7 @@ const LLM_PROVIDER_PROFILES = {
2932
2943
  };
2933
2944
  /**
2934
2945
  * TODO: Refactor this - each profile must be alongside the provider definition
2935
- * TODO: [🕛] Unite `AvatarProfileProps`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
2946
+ * TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
2936
2947
  * Note: [💞] Ignore a discrepancy between file name and entity name
2937
2948
  */
2938
2949
 
@@ -3241,6 +3252,8 @@ function $getGlobalScope() {
3241
3252
  /**
3242
3253
  * Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
3243
3254
  *
3255
+ * Note: [🔂] This function is idempotent.
3256
+ *
3244
3257
  * @param text The text string to be converted to SCREAMING_CASE format.
3245
3258
  * @returns The normalized text in SCREAMING_CASE format.
3246
3259
  * @example 'HELLO_WORLD'
@@ -3296,6 +3309,8 @@ function normalizeTo_SCREAMING_CASE(text) {
3296
3309
  /**
3297
3310
  * Normalizes a text string to snake_case format.
3298
3311
  *
3312
+ * Note: [🔂] This function is idempotent.
3313
+ *
3299
3314
  * @param text The text string to be converted to snake_case format.
3300
3315
  * @returns The normalized text in snake_case format.
3301
3316
  * @example 'hello_world'
@@ -3713,6 +3728,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
3713
3728
  /**
3714
3729
  * Removes diacritic marks (accents) from characters in a string.
3715
3730
  *
3731
+ * Note: [🔂] This function is idempotent.
3732
+ *
3716
3733
  * @param input The string containing diacritics to be normalized.
3717
3734
  * @returns The string with diacritics removed or normalized.
3718
3735
  * @public exported from `@promptbook/utils`
@@ -3867,6 +3884,8 @@ function mimeTypeToExtension(value) {
3867
3884
  /**
3868
3885
  * Removes emojis from a string and fix whitespaces
3869
3886
  *
3887
+ * Note: [🔂] This function is idempotent.
3888
+ *
3870
3889
  * @param text with emojis
3871
3890
  * @returns text without emojis
3872
3891
  * @public exported from `@promptbook/utils`
@@ -5260,6 +5279,7 @@ function countCharacters(text) {
5260
5279
  }
5261
5280
  /**
5262
5281
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5282
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
5263
5283
  */
5264
5284
 
5265
5285
  /**
@@ -5294,6 +5314,7 @@ function countLines(text) {
5294
5314
  }
5295
5315
  /**
5296
5316
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5317
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
5297
5318
  */
5298
5319
 
5299
5320
  /**
@@ -5308,6 +5329,7 @@ function countPages(text) {
5308
5329
  }
5309
5330
  /**
5310
5331
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5332
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
5311
5333
  */
5312
5334
 
5313
5335
  /**
@@ -5320,6 +5342,7 @@ function countParagraphs(text) {
5320
5342
  }
5321
5343
  /**
5322
5344
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5345
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
5323
5346
  */
5324
5347
 
5325
5348
  /**
@@ -5340,6 +5363,7 @@ function countSentences(text) {
5340
5363
  }
5341
5364
  /**
5342
5365
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5366
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
5343
5367
  */
5344
5368
 
5345
5369
  /**
@@ -5356,6 +5380,8 @@ function countWords(text) {
5356
5380
  }
5357
5381
  /**
5358
5382
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5383
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
5384
+ * TODO: [✌️] `countWords` should be just `splitWords(...).length`, and all other counters should use this pattern as well
5359
5385
  */
5360
5386
 
5361
5387
  /**
@@ -7018,7 +7044,9 @@ new Function(`
7018
7044
  */
7019
7045
 
7020
7046
  /**
7021
- * Makes first letter of a string uppercase
7047
+ * Makes first letter of a string lowercase
7048
+ *
7049
+ * Note: [🔂] This function is idempotent.
7022
7050
  *
7023
7051
  * @public exported from `@promptbook/utils`
7024
7052
  */
@@ -7088,6 +7116,8 @@ function normalizeTo_PascalCase(text) {
7088
7116
  /**
7089
7117
  * Take every whitespace (space, new line, tab) and replace it with a single space
7090
7118
  *
7119
+ * Note: [🔂] This function is idempotent.
7120
+ *
7091
7121
  * @public exported from `@promptbook/utils`
7092
7122
  */
7093
7123
  function normalizeWhitespaces(sentence) {
@@ -7097,6 +7127,7 @@ function normalizeWhitespaces(sentence) {
7097
7127
  /**
7098
7128
  * Removes quotes from a string
7099
7129
  *
7130
+ * Note: [🔂] This function is idempotent.
7100
7131
  * Tip: This is very useful for post-processing of the result of the LLM model
7101
7132
  * Note: This function removes only the same quotes from the beginning and the end of the string
7102
7133
  * Note: There are two similar functions:
@@ -7120,6 +7151,7 @@ function removeQuotes(text) {
7120
7151
  /**
7121
7152
  * Function trimCodeBlock will trim starting and ending code block from the string if it is present.
7122
7153
  *
7154
+ * Note: [🔂] This function is idempotent.
7123
7155
  * Note: This is useful for post-processing of the result of the chat LLM model
7124
7156
  * when the model wraps the result in the (markdown) code block.
7125
7157
  *