@promptbook/wizard 0.108.0-0 → 0.110.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.
- 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
|
@@ -37,7 +37,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
37
37
|
* @generated
|
|
38
38
|
* @see https://github.com/webgptorg/promptbook
|
|
39
39
|
*/
|
|
40
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
40
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-1';
|
|
41
41
|
/**
|
|
42
42
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
43
43
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -7862,60 +7862,12 @@ function getLinguisticHashLanguageConfig(language) {
|
|
|
7862
7862
|
return LANGUAGE_CONFIGS[normalized];
|
|
7863
7863
|
}
|
|
7864
7864
|
|
|
7865
|
-
// <- TODO: !!!! Remove re-exports
|
|
7866
|
-
/**
|
|
7867
|
-
* Creates a human-readable hash as a short, story-like phrase.
|
|
7868
|
-
*
|
|
7869
|
-
* @param wordCount how many words to include (defaults to {@link DEFAULT_LINGUISTIC_HASH_WORD_COUNT}, clamped to
|
|
7870
|
-
* {@link MIN_LINGUISTIC_HASH_WORD_COUNT}..{@link MAX_LINGUISTIC_HASH_WORD_COUNT})
|
|
7871
|
-
* @param language optional language code (defaults to {@link DEFAULT_LINGUISTIC_HASH_LANGUAGE})
|
|
7872
|
-
*
|
|
7873
|
-
* @public exported from `@promptbook/utils`
|
|
7874
|
-
*/
|
|
7875
|
-
async function linguisticHash(input, wordCount, language) {
|
|
7876
|
-
const hash = computeHash(input);
|
|
7877
|
-
const normalizedWordCount = normalizeLinguisticHashWordCount(wordCount);
|
|
7878
|
-
const languageConfig = getLinguisticHashLanguageConfig(language);
|
|
7879
|
-
const words = createLinguisticHashWords(hash, normalizedWordCount, languageConfig.wordLists);
|
|
7880
|
-
return capitalize(words.join(' '));
|
|
7881
|
-
}
|
|
7882
7865
|
/**
|
|
7883
7866
|
* @@@
|
|
7884
7867
|
*
|
|
7885
7868
|
* @private utility of `linguisticHash`
|
|
7886
7869
|
*/
|
|
7887
7870
|
const HASH_SEGMENT_LENGTH = 8;
|
|
7888
|
-
/**
|
|
7889
|
-
* The minimum number of words for a linguistic hash.
|
|
7890
|
-
*
|
|
7891
|
-
* @private utility of `linguisticHash`
|
|
7892
|
-
*/
|
|
7893
|
-
const MIN_LINGUISTIC_HASH_WORD_COUNT = 1;
|
|
7894
|
-
/**
|
|
7895
|
-
* The default number of words for a linguistic hash.
|
|
7896
|
-
*
|
|
7897
|
-
* @private utility of `linguisticHash`
|
|
7898
|
-
*/
|
|
7899
|
-
const DEFAULT_LINGUISTIC_HASH_WORD_COUNT = 7;
|
|
7900
|
-
/**
|
|
7901
|
-
* Extracts a deterministic numeric seed from a SHA-256 hash.
|
|
7902
|
-
*
|
|
7903
|
-
* @private utility of `linguisticHash`
|
|
7904
|
-
*/
|
|
7905
|
-
function getHashSeed(hash, segmentIndex) {
|
|
7906
|
-
const expandedHash = `${hash}${hash}`;
|
|
7907
|
-
const start = (segmentIndex * HASH_SEGMENT_LENGTH + segmentIndex) % hash.length;
|
|
7908
|
-
return parseInt(expandedHash.substring(start, start + HASH_SEGMENT_LENGTH), 16);
|
|
7909
|
-
}
|
|
7910
|
-
/**
|
|
7911
|
-
* Picks a deterministic item from a list based on the hash seed.
|
|
7912
|
-
*
|
|
7913
|
-
* @private utility of `linguisticHash`
|
|
7914
|
-
*/
|
|
7915
|
-
function pickFromHash(hash, segmentIndex, list) {
|
|
7916
|
-
const seed = getHashSeed(hash, segmentIndex);
|
|
7917
|
-
return list[seed % list.length];
|
|
7918
|
-
}
|
|
7919
7871
|
/**
|
|
7920
7872
|
* Ordered word kinds used to build the linguistic hash output.
|
|
7921
7873
|
*
|
|
@@ -7956,16 +7908,23 @@ const MAX_LINGUISTIC_HASH_WORD_COUNT = WORD_SEQUENCE.length;
|
|
|
7956
7908
|
*/
|
|
7957
7909
|
const SINGLE_WORD_INDEX = 1;
|
|
7958
7910
|
/**
|
|
7959
|
-
*
|
|
7911
|
+
* Extracts a deterministic numeric seed from a SHA-256 hash.
|
|
7960
7912
|
*
|
|
7961
7913
|
* @private utility of `linguisticHash`
|
|
7962
7914
|
*/
|
|
7963
|
-
function
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7915
|
+
function getHashSeed(hash, segmentIndex) {
|
|
7916
|
+
const expandedHash = `${hash}${hash}`;
|
|
7917
|
+
const start = (segmentIndex * HASH_SEGMENT_LENGTH + segmentIndex) % hash.length;
|
|
7918
|
+
return parseInt(expandedHash.substring(start, start + HASH_SEGMENT_LENGTH), 16);
|
|
7919
|
+
}
|
|
7920
|
+
/**
|
|
7921
|
+
* Picks a deterministic item from a list based on the hash seed.
|
|
7922
|
+
*
|
|
7923
|
+
* @private utility of `linguisticHash`
|
|
7924
|
+
*/
|
|
7925
|
+
function pickFromHash(hash, segmentIndex, list) {
|
|
7926
|
+
const seed = getHashSeed(hash, segmentIndex);
|
|
7927
|
+
return list[seed % list.length];
|
|
7969
7928
|
}
|
|
7970
7929
|
/**
|
|
7971
7930
|
* Picks a deterministic word from the hash by kind.
|
|
@@ -7996,6 +7955,49 @@ function createLinguisticHashWords(hash, wordCount, wordLists) {
|
|
|
7996
7955
|
return words.slice(0, wordCount);
|
|
7997
7956
|
}
|
|
7998
7957
|
|
|
7958
|
+
/**
|
|
7959
|
+
* The minimum number of words for a linguistic hash.
|
|
7960
|
+
*
|
|
7961
|
+
* @private utility of `linguisticHash`
|
|
7962
|
+
*/
|
|
7963
|
+
const MIN_LINGUISTIC_HASH_WORD_COUNT = 1;
|
|
7964
|
+
/**
|
|
7965
|
+
* The default number of words for a linguistic hash.
|
|
7966
|
+
*
|
|
7967
|
+
* @private utility of `linguisticHash`
|
|
7968
|
+
*/
|
|
7969
|
+
const DEFAULT_LINGUISTIC_HASH_WORD_COUNT = 7;
|
|
7970
|
+
/**
|
|
7971
|
+
* Normalizes the word count to a supported integer range.
|
|
7972
|
+
*
|
|
7973
|
+
* @private utility of `linguisticHash`
|
|
7974
|
+
*/
|
|
7975
|
+
function normalizeLinguisticHashWordCount(wordCount) {
|
|
7976
|
+
if (typeof wordCount !== 'number' || !Number.isFinite(wordCount)) {
|
|
7977
|
+
return DEFAULT_LINGUISTIC_HASH_WORD_COUNT;
|
|
7978
|
+
}
|
|
7979
|
+
const rounded = Math.round(wordCount);
|
|
7980
|
+
return Math.min(MAX_LINGUISTIC_HASH_WORD_COUNT, Math.max(MIN_LINGUISTIC_HASH_WORD_COUNT, rounded));
|
|
7981
|
+
}
|
|
7982
|
+
|
|
7983
|
+
// <- TODO: !!!! Remove re-exports
|
|
7984
|
+
/**
|
|
7985
|
+
* Creates a human-readable hash as a short, story-like phrase.
|
|
7986
|
+
*
|
|
7987
|
+
* @param wordCount how many words to include (defaults to {@link DEFAULT_LINGUISTIC_HASH_WORD_COUNT}, clamped to
|
|
7988
|
+
* {@link MIN_LINGUISTIC_HASH_WORD_COUNT}..{@link MAX_LINGUISTIC_HASH_WORD_COUNT})
|
|
7989
|
+
* @param language optional language code (defaults to {@link DEFAULT_LINGUISTIC_HASH_LANGUAGE})
|
|
7990
|
+
*
|
|
7991
|
+
* @public exported from `@promptbook/utils`
|
|
7992
|
+
*/
|
|
7993
|
+
async function linguisticHash(input, wordCount, language) {
|
|
7994
|
+
const hash = computeHash(input);
|
|
7995
|
+
const normalizedWordCount = normalizeLinguisticHashWordCount(wordCount);
|
|
7996
|
+
const languageConfig = getLinguisticHashLanguageConfig(language);
|
|
7997
|
+
const words = createLinguisticHashWords(hash, normalizedWordCount, languageConfig.wordLists);
|
|
7998
|
+
return capitalize(words.join(' '));
|
|
7999
|
+
}
|
|
8000
|
+
|
|
7999
8001
|
/**
|
|
8000
8002
|
* Function parseNumber will parse number from string
|
|
8001
8003
|
*
|
|
@@ -29512,15 +29514,20 @@ function createEmptySelfLearningCommitmentCounts() {
|
|
|
29512
29514
|
};
|
|
29513
29515
|
}
|
|
29514
29516
|
/**
|
|
29515
|
-
*
|
|
29517
|
+
* Normalizes teacher commitments into trimmed, display-ready lines.
|
|
29516
29518
|
*/
|
|
29517
|
-
function
|
|
29518
|
-
|
|
29519
|
-
const counts = createEmptySelfLearningCommitmentCounts();
|
|
29520
|
-
const lines = commitments
|
|
29519
|
+
function getTeacherCommitmentLines(commitments) {
|
|
29520
|
+
return commitments
|
|
29521
29521
|
.split(/\r?\n/)
|
|
29522
29522
|
.map((line) => line.trim())
|
|
29523
29523
|
.filter((line) => line.length > 0 && line !== '---' && !line.startsWith('```'));
|
|
29524
|
+
}
|
|
29525
|
+
/**
|
|
29526
|
+
* Summarizes teacher commitment lines into user-friendly counts for self-learning.
|
|
29527
|
+
*/
|
|
29528
|
+
function summarizeTeacherCommitmentLines(lines) {
|
|
29529
|
+
var _a, _b;
|
|
29530
|
+
const counts = createEmptySelfLearningCommitmentCounts();
|
|
29524
29531
|
for (const line of lines) {
|
|
29525
29532
|
const keyword = (_b = (_a = line.split(/\s+/)[0]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : '';
|
|
29526
29533
|
if (!/^[A-Z][A-Z_-]*$/.test(keyword)) {
|
|
@@ -29546,9 +29553,11 @@ function summarizeTeacherCommitments(commitments) {
|
|
|
29546
29553
|
* Builds the teacher summary payload for the self-learning tool call.
|
|
29547
29554
|
*/
|
|
29548
29555
|
function buildTeacherSummary(commitments, used) {
|
|
29556
|
+
const commitmentLines = getTeacherCommitmentLines(commitments);
|
|
29549
29557
|
return {
|
|
29550
29558
|
used,
|
|
29551
|
-
commitmentTypes:
|
|
29559
|
+
commitmentTypes: summarizeTeacherCommitmentLines(commitmentLines),
|
|
29560
|
+
commitments: commitmentLines.length > 0 ? commitmentLines : undefined,
|
|
29552
29561
|
};
|
|
29553
29562
|
}
|
|
29554
29563
|
/**
|