@promptbook/remote-server 0.108.0-0 → 0.110.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/esm/index.es.js +71 -62
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatActionsBar.d.ts +32 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatCitationModal.d.ts +21 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatInputArea.d.ts +48 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageList.d.ts +40 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatRatingModal.d.ts +30 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatSelfLearningSummary.d.ts +24 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +23 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatToolCallModalComponents.d.ts +39 -0
- package/esm/typings/src/book-components/Chat/hooks/useChatActionsOverlap.d.ts +55 -0
- package/esm/typings/src/book-components/Chat/hooks/useChatRatings.d.ts +67 -0
- package/esm/typings/src/book-components/icons/TeacherIcon.d.ts +15 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +18 -1
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +40 -3
- package/esm/typings/src/types/ToolCall.d.ts +4 -0
- package/esm/typings/src/utils/linguistic-hash/linguisticHash.d.ts +1 -24
- package/esm/typings/src/utils/linguistic-hash/linguisticHashWordCount.d.ts +31 -0
- package/esm/typings/src/utils/linguistic-hash/linguisticHashWordSelection.d.ts +22 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +71 -62
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -39,7 +39,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
39
39
|
* @generated
|
|
40
40
|
* @see https://github.com/webgptorg/promptbook
|
|
41
41
|
*/
|
|
42
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
42
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-0';
|
|
43
43
|
/**
|
|
44
44
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
45
45
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -9754,60 +9754,12 @@ function getLinguisticHashLanguageConfig(language) {
|
|
|
9754
9754
|
return LANGUAGE_CONFIGS[normalized];
|
|
9755
9755
|
}
|
|
9756
9756
|
|
|
9757
|
-
// <- TODO: !!!! Remove re-exports
|
|
9758
|
-
/**
|
|
9759
|
-
* Creates a human-readable hash as a short, story-like phrase.
|
|
9760
|
-
*
|
|
9761
|
-
* @param wordCount how many words to include (defaults to {@link DEFAULT_LINGUISTIC_HASH_WORD_COUNT}, clamped to
|
|
9762
|
-
* {@link MIN_LINGUISTIC_HASH_WORD_COUNT}..{@link MAX_LINGUISTIC_HASH_WORD_COUNT})
|
|
9763
|
-
* @param language optional language code (defaults to {@link DEFAULT_LINGUISTIC_HASH_LANGUAGE})
|
|
9764
|
-
*
|
|
9765
|
-
* @public exported from `@promptbook/utils`
|
|
9766
|
-
*/
|
|
9767
|
-
async function linguisticHash(input, wordCount, language) {
|
|
9768
|
-
const hash = computeHash(input);
|
|
9769
|
-
const normalizedWordCount = normalizeLinguisticHashWordCount(wordCount);
|
|
9770
|
-
const languageConfig = getLinguisticHashLanguageConfig(language);
|
|
9771
|
-
const words = createLinguisticHashWords(hash, normalizedWordCount, languageConfig.wordLists);
|
|
9772
|
-
return capitalize(words.join(' '));
|
|
9773
|
-
}
|
|
9774
9757
|
/**
|
|
9775
9758
|
* @@@
|
|
9776
9759
|
*
|
|
9777
9760
|
* @private utility of `linguisticHash`
|
|
9778
9761
|
*/
|
|
9779
9762
|
const HASH_SEGMENT_LENGTH = 8;
|
|
9780
|
-
/**
|
|
9781
|
-
* The minimum number of words for a linguistic hash.
|
|
9782
|
-
*
|
|
9783
|
-
* @private utility of `linguisticHash`
|
|
9784
|
-
*/
|
|
9785
|
-
const MIN_LINGUISTIC_HASH_WORD_COUNT = 1;
|
|
9786
|
-
/**
|
|
9787
|
-
* The default number of words for a linguistic hash.
|
|
9788
|
-
*
|
|
9789
|
-
* @private utility of `linguisticHash`
|
|
9790
|
-
*/
|
|
9791
|
-
const DEFAULT_LINGUISTIC_HASH_WORD_COUNT = 7;
|
|
9792
|
-
/**
|
|
9793
|
-
* Extracts a deterministic numeric seed from a SHA-256 hash.
|
|
9794
|
-
*
|
|
9795
|
-
* @private utility of `linguisticHash`
|
|
9796
|
-
*/
|
|
9797
|
-
function getHashSeed(hash, segmentIndex) {
|
|
9798
|
-
const expandedHash = `${hash}${hash}`;
|
|
9799
|
-
const start = (segmentIndex * HASH_SEGMENT_LENGTH + segmentIndex) % hash.length;
|
|
9800
|
-
return parseInt(expandedHash.substring(start, start + HASH_SEGMENT_LENGTH), 16);
|
|
9801
|
-
}
|
|
9802
|
-
/**
|
|
9803
|
-
* Picks a deterministic item from a list based on the hash seed.
|
|
9804
|
-
*
|
|
9805
|
-
* @private utility of `linguisticHash`
|
|
9806
|
-
*/
|
|
9807
|
-
function pickFromHash(hash, segmentIndex, list) {
|
|
9808
|
-
const seed = getHashSeed(hash, segmentIndex);
|
|
9809
|
-
return list[seed % list.length];
|
|
9810
|
-
}
|
|
9811
9763
|
/**
|
|
9812
9764
|
* Ordered word kinds used to build the linguistic hash output.
|
|
9813
9765
|
*
|
|
@@ -9848,16 +9800,23 @@ const MAX_LINGUISTIC_HASH_WORD_COUNT = WORD_SEQUENCE.length;
|
|
|
9848
9800
|
*/
|
|
9849
9801
|
const SINGLE_WORD_INDEX = 1;
|
|
9850
9802
|
/**
|
|
9851
|
-
*
|
|
9803
|
+
* Extracts a deterministic numeric seed from a SHA-256 hash.
|
|
9852
9804
|
*
|
|
9853
9805
|
* @private utility of `linguisticHash`
|
|
9854
9806
|
*/
|
|
9855
|
-
function
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
9807
|
+
function getHashSeed(hash, segmentIndex) {
|
|
9808
|
+
const expandedHash = `${hash}${hash}`;
|
|
9809
|
+
const start = (segmentIndex * HASH_SEGMENT_LENGTH + segmentIndex) % hash.length;
|
|
9810
|
+
return parseInt(expandedHash.substring(start, start + HASH_SEGMENT_LENGTH), 16);
|
|
9811
|
+
}
|
|
9812
|
+
/**
|
|
9813
|
+
* Picks a deterministic item from a list based on the hash seed.
|
|
9814
|
+
*
|
|
9815
|
+
* @private utility of `linguisticHash`
|
|
9816
|
+
*/
|
|
9817
|
+
function pickFromHash(hash, segmentIndex, list) {
|
|
9818
|
+
const seed = getHashSeed(hash, segmentIndex);
|
|
9819
|
+
return list[seed % list.length];
|
|
9861
9820
|
}
|
|
9862
9821
|
/**
|
|
9863
9822
|
* Picks a deterministic word from the hash by kind.
|
|
@@ -9888,6 +9847,49 @@ function createLinguisticHashWords(hash, wordCount, wordLists) {
|
|
|
9888
9847
|
return words.slice(0, wordCount);
|
|
9889
9848
|
}
|
|
9890
9849
|
|
|
9850
|
+
/**
|
|
9851
|
+
* The minimum number of words for a linguistic hash.
|
|
9852
|
+
*
|
|
9853
|
+
* @private utility of `linguisticHash`
|
|
9854
|
+
*/
|
|
9855
|
+
const MIN_LINGUISTIC_HASH_WORD_COUNT = 1;
|
|
9856
|
+
/**
|
|
9857
|
+
* The default number of words for a linguistic hash.
|
|
9858
|
+
*
|
|
9859
|
+
* @private utility of `linguisticHash`
|
|
9860
|
+
*/
|
|
9861
|
+
const DEFAULT_LINGUISTIC_HASH_WORD_COUNT = 7;
|
|
9862
|
+
/**
|
|
9863
|
+
* Normalizes the word count to a supported integer range.
|
|
9864
|
+
*
|
|
9865
|
+
* @private utility of `linguisticHash`
|
|
9866
|
+
*/
|
|
9867
|
+
function normalizeLinguisticHashWordCount(wordCount) {
|
|
9868
|
+
if (typeof wordCount !== 'number' || !Number.isFinite(wordCount)) {
|
|
9869
|
+
return DEFAULT_LINGUISTIC_HASH_WORD_COUNT;
|
|
9870
|
+
}
|
|
9871
|
+
const rounded = Math.round(wordCount);
|
|
9872
|
+
return Math.min(MAX_LINGUISTIC_HASH_WORD_COUNT, Math.max(MIN_LINGUISTIC_HASH_WORD_COUNT, rounded));
|
|
9873
|
+
}
|
|
9874
|
+
|
|
9875
|
+
// <- TODO: !!!! Remove re-exports
|
|
9876
|
+
/**
|
|
9877
|
+
* Creates a human-readable hash as a short, story-like phrase.
|
|
9878
|
+
*
|
|
9879
|
+
* @param wordCount how many words to include (defaults to {@link DEFAULT_LINGUISTIC_HASH_WORD_COUNT}, clamped to
|
|
9880
|
+
* {@link MIN_LINGUISTIC_HASH_WORD_COUNT}..{@link MAX_LINGUISTIC_HASH_WORD_COUNT})
|
|
9881
|
+
* @param language optional language code (defaults to {@link DEFAULT_LINGUISTIC_HASH_LANGUAGE})
|
|
9882
|
+
*
|
|
9883
|
+
* @public exported from `@promptbook/utils`
|
|
9884
|
+
*/
|
|
9885
|
+
async function linguisticHash(input, wordCount, language) {
|
|
9886
|
+
const hash = computeHash(input);
|
|
9887
|
+
const normalizedWordCount = normalizeLinguisticHashWordCount(wordCount);
|
|
9888
|
+
const languageConfig = getLinguisticHashLanguageConfig(language);
|
|
9889
|
+
const words = createLinguisticHashWords(hash, normalizedWordCount, languageConfig.wordLists);
|
|
9890
|
+
return capitalize(words.join(' '));
|
|
9891
|
+
}
|
|
9892
|
+
|
|
9891
9893
|
/**
|
|
9892
9894
|
* Simple wrapper `new Date().toISOString()`
|
|
9893
9895
|
*
|
|
@@ -21787,15 +21789,20 @@ function createEmptySelfLearningCommitmentCounts() {
|
|
|
21787
21789
|
};
|
|
21788
21790
|
}
|
|
21789
21791
|
/**
|
|
21790
|
-
*
|
|
21792
|
+
* Normalizes teacher commitments into trimmed, display-ready lines.
|
|
21791
21793
|
*/
|
|
21792
|
-
function
|
|
21793
|
-
|
|
21794
|
-
const counts = createEmptySelfLearningCommitmentCounts();
|
|
21795
|
-
const lines = commitments
|
|
21794
|
+
function getTeacherCommitmentLines(commitments) {
|
|
21795
|
+
return commitments
|
|
21796
21796
|
.split(/\r?\n/)
|
|
21797
21797
|
.map((line) => line.trim())
|
|
21798
21798
|
.filter((line) => line.length > 0 && line !== '---' && !line.startsWith('```'));
|
|
21799
|
+
}
|
|
21800
|
+
/**
|
|
21801
|
+
* Summarizes teacher commitment lines into user-friendly counts for self-learning.
|
|
21802
|
+
*/
|
|
21803
|
+
function summarizeTeacherCommitmentLines(lines) {
|
|
21804
|
+
var _a, _b;
|
|
21805
|
+
const counts = createEmptySelfLearningCommitmentCounts();
|
|
21799
21806
|
for (const line of lines) {
|
|
21800
21807
|
const keyword = (_b = (_a = line.split(/\s+/)[0]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : '';
|
|
21801
21808
|
if (!/^[A-Z][A-Z_-]*$/.test(keyword)) {
|
|
@@ -21821,9 +21828,11 @@ function summarizeTeacherCommitments(commitments) {
|
|
|
21821
21828
|
* Builds the teacher summary payload for the self-learning tool call.
|
|
21822
21829
|
*/
|
|
21823
21830
|
function buildTeacherSummary(commitments, used) {
|
|
21831
|
+
const commitmentLines = getTeacherCommitmentLines(commitments);
|
|
21824
21832
|
return {
|
|
21825
21833
|
used,
|
|
21826
|
-
commitmentTypes:
|
|
21834
|
+
commitmentTypes: summarizeTeacherCommitmentLines(commitmentLines),
|
|
21835
|
+
commitments: commitmentLines.length > 0 ? commitmentLines : undefined,
|
|
21827
21836
|
};
|
|
21828
21837
|
}
|
|
21829
21838
|
/**
|