@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.
- package/README.md +4 -0
- package/esm/index.es.js +75 -2
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +12 -0
- package/esm/typings/src/book-2.0/agent-source/BookEditable.d.ts +41 -0
- package/esm/typings/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/Chat/ImagePromptRenderer.d.ts +21 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/LlmChat/defaults.d.ts +9 -0
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +7 -1
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +6 -5
- package/esm/typings/src/book-components/Chat/save/index.d.ts +3 -3
- package/esm/typings/src/book-components/Chat/save/pdf/buildChatPdf.d.ts +11 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +2 -2
- package/esm/typings/src/book-components/Chat/utils/parseImagePrompts.d.ts +42 -0
- package/esm/typings/src/book-components/Chat/utils/parseImagePrompts.test.d.ts +1 -0
- package/esm/typings/src/commitments/MEMORY/MEMORY.d.ts +67 -0
- package/esm/typings/src/commitments/MEMORY/MEMORY.test.d.ts +1 -0
- package/esm/typings/src/commitments/_common/toolRuntimeContext.d.ts +49 -0
- package/esm/typings/src/constants/streaming.d.ts +20 -0
- package/esm/typings/src/llm-providers/openai/utils/buildToolInvocationScript.d.ts +9 -0
- package/esm/typings/src/utils/clientVersion.d.ts +51 -0
- package/esm/typings/src/utils/knowledge/inlineKnowledgeSource.d.ts +13 -9
- package/esm/typings/src/utils/normalization/constructImageFilename.d.ts +18 -0
- package/esm/typings/src/utils/normalization/constructImageFilename.test.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +80 -1
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.111.0-0';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3075,6 +3075,79 @@
|
|
|
3075
3075
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3076
3076
|
*/
|
|
3077
3077
|
|
|
3078
|
+
/**
|
|
3079
|
+
* HTTP header used by Promptbook clients to advertise their release version.
|
|
3080
|
+
*
|
|
3081
|
+
* @public exported from `@promptbook/utils`
|
|
3082
|
+
*/
|
|
3083
|
+
const CLIENT_VERSION_HEADER = 'x-promptbook-client-version';
|
|
3084
|
+
/**
|
|
3085
|
+
* The latest client (engine) version that the server expects.
|
|
3086
|
+
*
|
|
3087
|
+
* @public exported from `@promptbook/utils`
|
|
3088
|
+
*/
|
|
3089
|
+
const CLIENT_LATEST_VERSION = PROMPTBOOK_ENGINE_VERSION;
|
|
3090
|
+
/**
|
|
3091
|
+
* Determines if the provided version string exactly matches the latest release.
|
|
3092
|
+
*
|
|
3093
|
+
* @param version - Version string obtained from a request header.
|
|
3094
|
+
* @returns True when the version equals `CLIENT_LATEST_VERSION`.
|
|
3095
|
+
*
|
|
3096
|
+
* @public exported from `@promptbook/utils`
|
|
3097
|
+
*/
|
|
3098
|
+
function isClientVersionCompatible(version) {
|
|
3099
|
+
return typeof version === 'string' && version === CLIENT_LATEST_VERSION;
|
|
3100
|
+
}
|
|
3101
|
+
/**
|
|
3102
|
+
* Formats the message that should be shown when a client is out of date.
|
|
3103
|
+
*
|
|
3104
|
+
* @param clientVersion - The version reported by the client (optional).
|
|
3105
|
+
* @returns User-facing text explaining how to fix the mismatch.
|
|
3106
|
+
*
|
|
3107
|
+
* @public exported from `@promptbook/utils`
|
|
3108
|
+
*/
|
|
3109
|
+
function formatClientVersionMismatchMessage(clientVersion) {
|
|
3110
|
+
const reportedVersion = clientVersion !== null && clientVersion !== void 0 ? clientVersion : 'unknown';
|
|
3111
|
+
return spaceTrim__default["default"](`
|
|
3112
|
+
Your Promptbook client (v${reportedVersion}) is out of date.
|
|
3113
|
+
This server runs on Vercel and now requires v${CLIENT_LATEST_VERSION}.
|
|
3114
|
+
Please update the app or reload the latest release before you continue using chat.
|
|
3115
|
+
`);
|
|
3116
|
+
}
|
|
3117
|
+
/**
|
|
3118
|
+
* Creates a headers object that includes the client version header.
|
|
3119
|
+
*
|
|
3120
|
+
* @param headers - Optional base headers to clone.
|
|
3121
|
+
* @returns New headers object augmented with `CLIENT_VERSION_HEADER`.
|
|
3122
|
+
*
|
|
3123
|
+
* @public exported from `@promptbook/utils`
|
|
3124
|
+
*/
|
|
3125
|
+
function attachClientVersionHeader(headers) {
|
|
3126
|
+
return {
|
|
3127
|
+
...(headers !== null && headers !== void 0 ? headers : {}),
|
|
3128
|
+
[CLIENT_VERSION_HEADER]: CLIENT_LATEST_VERSION,
|
|
3129
|
+
};
|
|
3130
|
+
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Normalizes the client version reported inside a `HeadersInit` object.
|
|
3133
|
+
*
|
|
3134
|
+
* @param headers - Headers collection to read from.
|
|
3135
|
+
* @returns The trimmed client version or `null` when it is missing.
|
|
3136
|
+
*
|
|
3137
|
+
* @public exported from `@promptbook/utils`
|
|
3138
|
+
*/
|
|
3139
|
+
function getClientVersionFromHeaders(headers) {
|
|
3140
|
+
if (!headers) {
|
|
3141
|
+
return null;
|
|
3142
|
+
}
|
|
3143
|
+
const normalizedHeaders = new Headers(headers);
|
|
3144
|
+
const value = normalizedHeaders.get(CLIENT_VERSION_HEADER);
|
|
3145
|
+
return value ? value.trim() : null;
|
|
3146
|
+
}
|
|
3147
|
+
/**
|
|
3148
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3149
|
+
*/
|
|
3150
|
+
|
|
3078
3151
|
/**
|
|
3079
3152
|
* Detects if the code is running in a browser environment in main thread (Not in a web worker)
|
|
3080
3153
|
*
|
|
@@ -5695,6 +5768,8 @@
|
|
|
5695
5768
|
exports.$isRunningInWebWorker = $isRunningInWebWorker;
|
|
5696
5769
|
exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
|
|
5697
5770
|
exports.CHARACTERS_PER_STANDARD_LINE = CHARACTERS_PER_STANDARD_LINE;
|
|
5771
|
+
exports.CLIENT_LATEST_VERSION = CLIENT_LATEST_VERSION;
|
|
5772
|
+
exports.CLIENT_VERSION_HEADER = CLIENT_VERSION_HEADER;
|
|
5698
5773
|
exports.CountUtils = CountUtils;
|
|
5699
5774
|
exports.DIACRITIC_VARIANTS_LETTERS = DIACRITIC_VARIANTS_LETTERS;
|
|
5700
5775
|
exports.LINES_PER_STANDARD_PAGE = LINES_PER_STANDARD_PAGE;
|
|
@@ -5702,6 +5777,7 @@
|
|
|
5702
5777
|
exports.PromptString = PromptString;
|
|
5703
5778
|
exports.SMALL_NUMBER = SMALL_NUMBER;
|
|
5704
5779
|
exports.VALUE_STRINGS = VALUE_STRINGS;
|
|
5780
|
+
exports.attachClientVersionHeader = attachClientVersionHeader;
|
|
5705
5781
|
exports.capitalize = capitalize;
|
|
5706
5782
|
exports.checkSerializableAsJson = checkSerializableAsJson;
|
|
5707
5783
|
exports.clonePipeline = clonePipeline;
|
|
@@ -5720,7 +5796,10 @@
|
|
|
5720
5796
|
exports.exportJson = exportJson;
|
|
5721
5797
|
exports.extractParameterNames = extractParameterNames;
|
|
5722
5798
|
exports.forEachAsync = forEachAsync;
|
|
5799
|
+
exports.formatClientVersionMismatchMessage = formatClientVersionMismatchMessage;
|
|
5800
|
+
exports.getClientVersionFromHeaders = getClientVersionFromHeaders;
|
|
5723
5801
|
exports.intersection = intersection;
|
|
5802
|
+
exports.isClientVersionCompatible = isClientVersionCompatible;
|
|
5724
5803
|
exports.isHostnameOnPrivateNetwork = isHostnameOnPrivateNetwork;
|
|
5725
5804
|
exports.isRootPath = isRootPath;
|
|
5726
5805
|
exports.isSerializableAsJson = isSerializableAsJson;
|