@promptbook/browser 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.
Files changed (25) hide show
  1. package/esm/index.es.js +71 -62
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  4. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +1 -1
  5. package/esm/typings/src/book-components/Chat/Chat/ChatActionsBar.d.ts +32 -0
  6. package/esm/typings/src/book-components/Chat/Chat/ChatCitationModal.d.ts +21 -0
  7. package/esm/typings/src/book-components/Chat/Chat/ChatInputArea.d.ts +48 -0
  8. package/esm/typings/src/book-components/Chat/Chat/ChatMessageList.d.ts +40 -0
  9. package/esm/typings/src/book-components/Chat/Chat/ChatRatingModal.d.ts +30 -0
  10. package/esm/typings/src/book-components/Chat/Chat/ChatSelfLearningSummary.d.ts +24 -0
  11. package/esm/typings/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +23 -0
  12. package/esm/typings/src/book-components/Chat/Chat/ChatToolCallModalComponents.d.ts +39 -0
  13. package/esm/typings/src/book-components/Chat/hooks/useChatActionsOverlap.d.ts +55 -0
  14. package/esm/typings/src/book-components/Chat/hooks/useChatRatings.d.ts +67 -0
  15. package/esm/typings/src/book-components/icons/TeacherIcon.d.ts +15 -0
  16. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +18 -1
  17. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +40 -3
  18. package/esm/typings/src/types/ToolCall.d.ts +4 -0
  19. package/esm/typings/src/utils/linguistic-hash/linguisticHash.d.ts +1 -24
  20. package/esm/typings/src/utils/linguistic-hash/linguisticHashWordCount.d.ts +31 -0
  21. package/esm/typings/src/utils/linguistic-hash/linguisticHashWordSelection.d.ts +22 -0
  22. package/esm/typings/src/version.d.ts +1 -1
  23. package/package.json +2 -2
  24. package/umd/index.umd.js +71 -62
  25. package/umd/index.umd.js.map +1 -1
package/esm/index.es.js CHANGED
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.108.0-0';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.110.0-0';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -5343,60 +5343,12 @@ function getLinguisticHashLanguageConfig(language) {
5343
5343
  return LANGUAGE_CONFIGS[normalized];
5344
5344
  }
5345
5345
 
5346
- // <- TODO: !!!! Remove re-exports
5347
- /**
5348
- * Creates a human-readable hash as a short, story-like phrase.
5349
- *
5350
- * @param wordCount how many words to include (defaults to {@link DEFAULT_LINGUISTIC_HASH_WORD_COUNT}, clamped to
5351
- * {@link MIN_LINGUISTIC_HASH_WORD_COUNT}..{@link MAX_LINGUISTIC_HASH_WORD_COUNT})
5352
- * @param language optional language code (defaults to {@link DEFAULT_LINGUISTIC_HASH_LANGUAGE})
5353
- *
5354
- * @public exported from `@promptbook/utils`
5355
- */
5356
- async function linguisticHash(input, wordCount, language) {
5357
- const hash = computeHash(input);
5358
- const normalizedWordCount = normalizeLinguisticHashWordCount(wordCount);
5359
- const languageConfig = getLinguisticHashLanguageConfig(language);
5360
- const words = createLinguisticHashWords(hash, normalizedWordCount, languageConfig.wordLists);
5361
- return capitalize(words.join(' '));
5362
- }
5363
5346
  /**
5364
5347
  * @@@
5365
5348
  *
5366
5349
  * @private utility of `linguisticHash`
5367
5350
  */
5368
5351
  const HASH_SEGMENT_LENGTH = 8;
5369
- /**
5370
- * The minimum number of words for a linguistic hash.
5371
- *
5372
- * @private utility of `linguisticHash`
5373
- */
5374
- const MIN_LINGUISTIC_HASH_WORD_COUNT = 1;
5375
- /**
5376
- * The default number of words for a linguistic hash.
5377
- *
5378
- * @private utility of `linguisticHash`
5379
- */
5380
- const DEFAULT_LINGUISTIC_HASH_WORD_COUNT = 7;
5381
- /**
5382
- * Extracts a deterministic numeric seed from a SHA-256 hash.
5383
- *
5384
- * @private utility of `linguisticHash`
5385
- */
5386
- function getHashSeed(hash, segmentIndex) {
5387
- const expandedHash = `${hash}${hash}`;
5388
- const start = (segmentIndex * HASH_SEGMENT_LENGTH + segmentIndex) % hash.length;
5389
- return parseInt(expandedHash.substring(start, start + HASH_SEGMENT_LENGTH), 16);
5390
- }
5391
- /**
5392
- * Picks a deterministic item from a list based on the hash seed.
5393
- *
5394
- * @private utility of `linguisticHash`
5395
- */
5396
- function pickFromHash(hash, segmentIndex, list) {
5397
- const seed = getHashSeed(hash, segmentIndex);
5398
- return list[seed % list.length];
5399
- }
5400
5352
  /**
5401
5353
  * Ordered word kinds used to build the linguistic hash output.
5402
5354
  *
@@ -5437,16 +5389,23 @@ const MAX_LINGUISTIC_HASH_WORD_COUNT = WORD_SEQUENCE.length;
5437
5389
  */
5438
5390
  const SINGLE_WORD_INDEX = 1;
5439
5391
  /**
5440
- * Normalizes the word count to a supported integer range.
5392
+ * Extracts a deterministic numeric seed from a SHA-256 hash.
5441
5393
  *
5442
5394
  * @private utility of `linguisticHash`
5443
5395
  */
5444
- function normalizeLinguisticHashWordCount(wordCount) {
5445
- if (typeof wordCount !== 'number' || !Number.isFinite(wordCount)) {
5446
- return DEFAULT_LINGUISTIC_HASH_WORD_COUNT;
5447
- }
5448
- const rounded = Math.round(wordCount);
5449
- return Math.min(MAX_LINGUISTIC_HASH_WORD_COUNT, Math.max(MIN_LINGUISTIC_HASH_WORD_COUNT, rounded));
5396
+ function getHashSeed(hash, segmentIndex) {
5397
+ const expandedHash = `${hash}${hash}`;
5398
+ const start = (segmentIndex * HASH_SEGMENT_LENGTH + segmentIndex) % hash.length;
5399
+ return parseInt(expandedHash.substring(start, start + HASH_SEGMENT_LENGTH), 16);
5400
+ }
5401
+ /**
5402
+ * Picks a deterministic item from a list based on the hash seed.
5403
+ *
5404
+ * @private utility of `linguisticHash`
5405
+ */
5406
+ function pickFromHash(hash, segmentIndex, list) {
5407
+ const seed = getHashSeed(hash, segmentIndex);
5408
+ return list[seed % list.length];
5450
5409
  }
5451
5410
  /**
5452
5411
  * Picks a deterministic word from the hash by kind.
@@ -5477,6 +5436,49 @@ function createLinguisticHashWords(hash, wordCount, wordLists) {
5477
5436
  return words.slice(0, wordCount);
5478
5437
  }
5479
5438
 
5439
+ /**
5440
+ * The minimum number of words for a linguistic hash.
5441
+ *
5442
+ * @private utility of `linguisticHash`
5443
+ */
5444
+ const MIN_LINGUISTIC_HASH_WORD_COUNT = 1;
5445
+ /**
5446
+ * The default number of words for a linguistic hash.
5447
+ *
5448
+ * @private utility of `linguisticHash`
5449
+ */
5450
+ const DEFAULT_LINGUISTIC_HASH_WORD_COUNT = 7;
5451
+ /**
5452
+ * Normalizes the word count to a supported integer range.
5453
+ *
5454
+ * @private utility of `linguisticHash`
5455
+ */
5456
+ function normalizeLinguisticHashWordCount(wordCount) {
5457
+ if (typeof wordCount !== 'number' || !Number.isFinite(wordCount)) {
5458
+ return DEFAULT_LINGUISTIC_HASH_WORD_COUNT;
5459
+ }
5460
+ const rounded = Math.round(wordCount);
5461
+ return Math.min(MAX_LINGUISTIC_HASH_WORD_COUNT, Math.max(MIN_LINGUISTIC_HASH_WORD_COUNT, rounded));
5462
+ }
5463
+
5464
+ // <- TODO: !!!! Remove re-exports
5465
+ /**
5466
+ * Creates a human-readable hash as a short, story-like phrase.
5467
+ *
5468
+ * @param wordCount how many words to include (defaults to {@link DEFAULT_LINGUISTIC_HASH_WORD_COUNT}, clamped to
5469
+ * {@link MIN_LINGUISTIC_HASH_WORD_COUNT}..{@link MAX_LINGUISTIC_HASH_WORD_COUNT})
5470
+ * @param language optional language code (defaults to {@link DEFAULT_LINGUISTIC_HASH_LANGUAGE})
5471
+ *
5472
+ * @public exported from `@promptbook/utils`
5473
+ */
5474
+ async function linguisticHash(input, wordCount, language) {
5475
+ const hash = computeHash(input);
5476
+ const normalizedWordCount = normalizeLinguisticHashWordCount(wordCount);
5477
+ const languageConfig = getLinguisticHashLanguageConfig(language);
5478
+ const words = createLinguisticHashWords(hash, normalizedWordCount, languageConfig.wordLists);
5479
+ return capitalize(words.join(' '));
5480
+ }
5481
+
5480
5482
  /**
5481
5483
  * Simple wrapper `new Date().toISOString()`
5482
5484
  *
@@ -19349,15 +19351,20 @@ function createEmptySelfLearningCommitmentCounts() {
19349
19351
  };
19350
19352
  }
19351
19353
  /**
19352
- * Summarizes teacher commitments into user-friendly counts for self-learning.
19354
+ * Normalizes teacher commitments into trimmed, display-ready lines.
19353
19355
  */
19354
- function summarizeTeacherCommitments(commitments) {
19355
- var _a, _b;
19356
- const counts = createEmptySelfLearningCommitmentCounts();
19357
- const lines = commitments
19356
+ function getTeacherCommitmentLines(commitments) {
19357
+ return commitments
19358
19358
  .split(/\r?\n/)
19359
19359
  .map((line) => line.trim())
19360
19360
  .filter((line) => line.length > 0 && line !== '---' && !line.startsWith('```'));
19361
+ }
19362
+ /**
19363
+ * Summarizes teacher commitment lines into user-friendly counts for self-learning.
19364
+ */
19365
+ function summarizeTeacherCommitmentLines(lines) {
19366
+ var _a, _b;
19367
+ const counts = createEmptySelfLearningCommitmentCounts();
19361
19368
  for (const line of lines) {
19362
19369
  const keyword = (_b = (_a = line.split(/\s+/)[0]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : '';
19363
19370
  if (!/^[A-Z][A-Z_-]*$/.test(keyword)) {
@@ -19383,9 +19390,11 @@ function summarizeTeacherCommitments(commitments) {
19383
19390
  * Builds the teacher summary payload for the self-learning tool call.
19384
19391
  */
19385
19392
  function buildTeacherSummary(commitments, used) {
19393
+ const commitmentLines = getTeacherCommitmentLines(commitments);
19386
19394
  return {
19387
19395
  used,
19388
- commitmentTypes: summarizeTeacherCommitments(commitments),
19396
+ commitmentTypes: summarizeTeacherCommitmentLines(commitmentLines),
19397
+ commitments: commitmentLines.length > 0 ? commitmentLines : undefined,
19389
19398
  };
19390
19399
  }
19391
19400
  /**