@promptbook/utils 0.110.0 → 0.111.0-0

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 (29) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +75 -2
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/utils.index.d.ts +12 -0
  5. package/esm/typings/src/book-2.0/agent-source/BookEditable.d.ts +41 -0
  6. package/esm/typings/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +5 -0
  7. package/esm/typings/src/book-components/Chat/Chat/ImagePromptRenderer.d.ts +21 -0
  8. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
  9. package/esm/typings/src/book-components/Chat/LlmChat/defaults.d.ts +9 -0
  10. package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +7 -1
  11. package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +6 -5
  12. package/esm/typings/src/book-components/Chat/save/index.d.ts +3 -3
  13. package/esm/typings/src/book-components/Chat/save/pdf/buildChatPdf.d.ts +11 -0
  14. package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +2 -2
  15. package/esm/typings/src/book-components/Chat/utils/parseImagePrompts.d.ts +42 -0
  16. package/esm/typings/src/book-components/Chat/utils/parseImagePrompts.test.d.ts +1 -0
  17. package/esm/typings/src/commitments/MEMORY/MEMORY.d.ts +67 -0
  18. package/esm/typings/src/commitments/MEMORY/MEMORY.test.d.ts +1 -0
  19. package/esm/typings/src/commitments/_common/toolRuntimeContext.d.ts +49 -0
  20. package/esm/typings/src/constants/streaming.d.ts +20 -0
  21. package/esm/typings/src/llm-providers/openai/utils/buildToolInvocationScript.d.ts +9 -0
  22. package/esm/typings/src/utils/clientVersion.d.ts +51 -0
  23. package/esm/typings/src/utils/knowledge/inlineKnowledgeSource.d.ts +13 -9
  24. package/esm/typings/src/utils/normalization/constructImageFilename.d.ts +18 -0
  25. package/esm/typings/src/utils/normalization/constructImageFilename.test.d.ts +1 -0
  26. package/esm/typings/src/version.d.ts +1 -1
  27. package/package.json +1 -1
  28. package/umd/index.umd.js +80 -1
  29. package/umd/index.umd.js.map +1 -1
package/README.md CHANGED
@@ -27,6 +27,10 @@ Turn your company's scattered knowledge into AI ready Books
27
27
 
28
28
 
29
29
 
30
+ <blockquote style="color: #ff8811">
31
+ <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
32
+ </blockquote>
33
+
30
34
  ## 📦 Package `@promptbook/utils`
31
35
 
32
36
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
package/esm/index.es.js CHANGED
@@ -18,7 +18,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
18
18
  * @generated
19
19
  * @see https://github.com/webgptorg/promptbook
20
20
  */
21
- const PROMPTBOOK_ENGINE_VERSION = '0.110.0';
21
+ const PROMPTBOOK_ENGINE_VERSION = '0.111.0-0';
22
22
  /**
23
23
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
24
24
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3070,6 +3070,79 @@ const promptTemplate = prompt;
3070
3070
  * Note: [💞] Ignore a discrepancy between file name and entity name
3071
3071
  */
3072
3072
 
3073
+ /**
3074
+ * HTTP header used by Promptbook clients to advertise their release version.
3075
+ *
3076
+ * @public exported from `@promptbook/utils`
3077
+ */
3078
+ const CLIENT_VERSION_HEADER = 'x-promptbook-client-version';
3079
+ /**
3080
+ * The latest client (engine) version that the server expects.
3081
+ *
3082
+ * @public exported from `@promptbook/utils`
3083
+ */
3084
+ const CLIENT_LATEST_VERSION = PROMPTBOOK_ENGINE_VERSION;
3085
+ /**
3086
+ * Determines if the provided version string exactly matches the latest release.
3087
+ *
3088
+ * @param version - Version string obtained from a request header.
3089
+ * @returns True when the version equals `CLIENT_LATEST_VERSION`.
3090
+ *
3091
+ * @public exported from `@promptbook/utils`
3092
+ */
3093
+ function isClientVersionCompatible(version) {
3094
+ return typeof version === 'string' && version === CLIENT_LATEST_VERSION;
3095
+ }
3096
+ /**
3097
+ * Formats the message that should be shown when a client is out of date.
3098
+ *
3099
+ * @param clientVersion - The version reported by the client (optional).
3100
+ * @returns User-facing text explaining how to fix the mismatch.
3101
+ *
3102
+ * @public exported from `@promptbook/utils`
3103
+ */
3104
+ function formatClientVersionMismatchMessage(clientVersion) {
3105
+ const reportedVersion = clientVersion !== null && clientVersion !== void 0 ? clientVersion : 'unknown';
3106
+ return spaceTrim$2(`
3107
+ Your Promptbook client (v${reportedVersion}) is out of date.
3108
+ This server runs on Vercel and now requires v${CLIENT_LATEST_VERSION}.
3109
+ Please update the app or reload the latest release before you continue using chat.
3110
+ `);
3111
+ }
3112
+ /**
3113
+ * Creates a headers object that includes the client version header.
3114
+ *
3115
+ * @param headers - Optional base headers to clone.
3116
+ * @returns New headers object augmented with `CLIENT_VERSION_HEADER`.
3117
+ *
3118
+ * @public exported from `@promptbook/utils`
3119
+ */
3120
+ function attachClientVersionHeader(headers) {
3121
+ return {
3122
+ ...(headers !== null && headers !== void 0 ? headers : {}),
3123
+ [CLIENT_VERSION_HEADER]: CLIENT_LATEST_VERSION,
3124
+ };
3125
+ }
3126
+ /**
3127
+ * Normalizes the client version reported inside a `HeadersInit` object.
3128
+ *
3129
+ * @param headers - Headers collection to read from.
3130
+ * @returns The trimmed client version or `null` when it is missing.
3131
+ *
3132
+ * @public exported from `@promptbook/utils`
3133
+ */
3134
+ function getClientVersionFromHeaders(headers) {
3135
+ if (!headers) {
3136
+ return null;
3137
+ }
3138
+ const normalizedHeaders = new Headers(headers);
3139
+ const value = normalizedHeaders.get(CLIENT_VERSION_HEADER);
3140
+ return value ? value.trim() : null;
3141
+ }
3142
+ /**
3143
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3144
+ */
3145
+
3073
3146
  /**
3074
3147
  * Detects if the code is running in a browser environment in main thread (Not in a web worker)
3075
3148
  *
@@ -5681,5 +5754,5 @@ function isValidUuid(value) {
5681
5754
  return /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i.test(value);
5682
5755
  }
5683
5756
 
5684
- export { $deepFreeze, $detectRuntimeEnvironment, $getCurrentDate, $isRunningInBrowser, $isRunningInJest, $isRunningInNode, $isRunningInWebWorker, BOOK_LANGUAGE_VERSION, CHARACTERS_PER_STANDARD_LINE, CountUtils, DIACRITIC_VARIANTS_LETTERS, LINES_PER_STANDARD_PAGE, PROMPTBOOK_ENGINE_VERSION, PromptString, SMALL_NUMBER, VALUE_STRINGS, capitalize, checkSerializableAsJson, clonePipeline, computeHash, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, debounce, decapitalize, deepClone, deserializeError, difference, exportJson, extractParameterNames, forEachAsync, intersection, isHostnameOnPrivateNetwork, isRootPath, isSerializableAsJson, isUrlOnPrivateNetwork, isValidAgentUrl, isValidCsvString, isValidEmail, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidKeyword, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, isValidXmlString, jsonParse, jsonStringsToJsons, linguisticHash, nameToUriPart, nameToUriParts, normalizeMessageText, normalizeToKebabCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_camelCase, normalizeTo_snake_case, normalizeWhitespaces, numberToString, orderJson, parseKeywords, parseKeywordsFromString, parseNumber, prompt, promptTemplate, removeDiacritics, removeEmojis, removeQuotes, renderPromptbookMermaid, searchKeywords, serializeError, serializeToPromptbookJavascript, spaceTrim, splitIntoSentences, suffixUrl, templateParameters, titleToName, union, unwrapResult, valueToString };
5757
+ export { $deepFreeze, $detectRuntimeEnvironment, $getCurrentDate, $isRunningInBrowser, $isRunningInJest, $isRunningInNode, $isRunningInWebWorker, BOOK_LANGUAGE_VERSION, CHARACTERS_PER_STANDARD_LINE, CLIENT_LATEST_VERSION, CLIENT_VERSION_HEADER, CountUtils, DIACRITIC_VARIANTS_LETTERS, LINES_PER_STANDARD_PAGE, PROMPTBOOK_ENGINE_VERSION, PromptString, SMALL_NUMBER, VALUE_STRINGS, attachClientVersionHeader, capitalize, checkSerializableAsJson, clonePipeline, computeHash, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, debounce, decapitalize, deepClone, deserializeError, difference, exportJson, extractParameterNames, forEachAsync, formatClientVersionMismatchMessage, getClientVersionFromHeaders, intersection, isClientVersionCompatible, isHostnameOnPrivateNetwork, isRootPath, isSerializableAsJson, isUrlOnPrivateNetwork, isValidAgentUrl, isValidCsvString, isValidEmail, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidKeyword, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, isValidXmlString, jsonParse, jsonStringsToJsons, linguisticHash, nameToUriPart, nameToUriParts, normalizeMessageText, normalizeToKebabCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_camelCase, normalizeTo_snake_case, normalizeWhitespaces, numberToString, orderJson, parseKeywords, parseKeywordsFromString, parseNumber, prompt, promptTemplate, removeDiacritics, removeEmojis, removeQuotes, renderPromptbookMermaid, searchKeywords, serializeError, serializeToPromptbookJavascript, spaceTrim, splitIntoSentences, suffixUrl, templateParameters, titleToName, union, unwrapResult, valueToString };
5685
5758
  //# sourceMappingURL=index.es.js.map