@promptbook/browser 0.105.0-4 → 0.105.0-5
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 +128 -4
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/browser.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +12 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +3 -6
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +9 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +7 -0
- package/esm/typings/src/search-engines/_index.d.ts +6 -0
- package/esm/typings/src/search-engines/google/GoogleSearchEngine.d.ts +18 -0
- package/esm/typings/src/search-engines/serp/SerpSearchEngine.d.ts +15 -0
- package/esm/typings/src/speech-recognition/BrowserSpeechRecognition.d.ts +21 -0
- package/esm/typings/src/speech-recognition/OpenAiSpeechRecognition.d.ts +32 -0
- package/esm/typings/src/types/SpeechRecognition.d.ts +58 -0
- package/esm/typings/src/types/typeAliases.d.ts +4 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +128 -3
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -19,7 +19,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
19
19
|
* @generated
|
|
20
20
|
* @see https://github.com/webgptorg/promptbook
|
|
21
21
|
*/
|
|
22
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
22
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-5';
|
|
23
23
|
/**
|
|
24
24
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
25
25
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1406,6 +1406,104 @@ async function $provideScrapersForBrowser(tools, options) {
|
|
|
1406
1406
|
return scrapers;
|
|
1407
1407
|
}
|
|
1408
1408
|
|
|
1409
|
+
/**
|
|
1410
|
+
* Speech recognition using Web Speech API `SpeechRecognition` available in modern browsers
|
|
1411
|
+
*
|
|
1412
|
+
* @public exported from `@promptbook/browser`
|
|
1413
|
+
*/
|
|
1414
|
+
class BrowserSpeechRecognition {
|
|
1415
|
+
get state() {
|
|
1416
|
+
return this._state;
|
|
1417
|
+
}
|
|
1418
|
+
constructor() {
|
|
1419
|
+
this.recognition = null;
|
|
1420
|
+
this.callbacks = [];
|
|
1421
|
+
this._state = 'IDLE';
|
|
1422
|
+
if (typeof window !== 'undefined') {
|
|
1423
|
+
const SpeechRecognitionValue = window.SpeechRecognition ||
|
|
1424
|
+
window /* <- TODO: !!!! Make special windowAny */.webkitSpeechRecognition;
|
|
1425
|
+
if (SpeechRecognitionValue) {
|
|
1426
|
+
this.recognition = new SpeechRecognitionValue();
|
|
1427
|
+
this.recognition.continuous = true;
|
|
1428
|
+
this.recognition.interimResults = true;
|
|
1429
|
+
this.recognition.onstart = () => {
|
|
1430
|
+
this._state = 'RECORDING';
|
|
1431
|
+
this.emit({ type: 'START' });
|
|
1432
|
+
};
|
|
1433
|
+
this.recognition.onresult = (event) => {
|
|
1434
|
+
let finalTranscript = '';
|
|
1435
|
+
let interimTranscript = '';
|
|
1436
|
+
for (let i = event.resultIndex; i < event.results.length; ++i) {
|
|
1437
|
+
if (event.results[i].isFinal) {
|
|
1438
|
+
finalTranscript += event.results[i][0].transcript;
|
|
1439
|
+
}
|
|
1440
|
+
else {
|
|
1441
|
+
interimTranscript += event.results[i][0].transcript;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
const text = (finalTranscript + interimTranscript).trim();
|
|
1445
|
+
if (text) {
|
|
1446
|
+
this.emit({
|
|
1447
|
+
type: 'RESULT',
|
|
1448
|
+
text,
|
|
1449
|
+
isFinal: interimTranscript === '',
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
};
|
|
1453
|
+
this.recognition.onerror = (event) => {
|
|
1454
|
+
this._state = 'ERROR';
|
|
1455
|
+
this.emit({ type: 'ERROR', message: event.error || 'Unknown error' });
|
|
1456
|
+
};
|
|
1457
|
+
this.recognition.onend = () => {
|
|
1458
|
+
this._state = 'IDLE';
|
|
1459
|
+
this.emit({ type: 'STOP' });
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
$start(options = {}) {
|
|
1465
|
+
var _a;
|
|
1466
|
+
if (!this.recognition) {
|
|
1467
|
+
this.emit({ type: 'ERROR', message: 'Speech recognition is not supported in this browser.' });
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
if (this._state !== 'IDLE') {
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
this._state = 'STARTING';
|
|
1474
|
+
this.recognition.lang = options.language || 'en'; // Note: Web Speech API usually accepts ISO-639-1 or BCP-47
|
|
1475
|
+
this.recognition.interimResults = (_a = options.interimResults) !== null && _a !== void 0 ? _a : true;
|
|
1476
|
+
try {
|
|
1477
|
+
this.recognition.start();
|
|
1478
|
+
}
|
|
1479
|
+
catch (error) {
|
|
1480
|
+
this._state = 'ERROR';
|
|
1481
|
+
this.emit({ type: 'ERROR', message: error.message });
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
$stop() {
|
|
1485
|
+
if (!this.recognition || this._state === 'IDLE') {
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
this.recognition.stop();
|
|
1489
|
+
}
|
|
1490
|
+
subscribe(callback) {
|
|
1491
|
+
this.callbacks.push(callback);
|
|
1492
|
+
return () => {
|
|
1493
|
+
this.callbacks = this.callbacks.filter((cb) => cb !== callback);
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
emit(event) {
|
|
1497
|
+
for (const callback of this.callbacks) {
|
|
1498
|
+
callback(event);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* TODO: !!!! Search ACRY for `window` and put -> [🔵]
|
|
1504
|
+
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
1505
|
+
*/
|
|
1506
|
+
|
|
1409
1507
|
/**
|
|
1410
1508
|
* Creates a PromptbookStorage backed by IndexedDB.
|
|
1411
1509
|
* Uses a single object store named 'promptbook'.
|
|
@@ -6677,26 +6775,52 @@ function parseAgentSource(agentSource) {
|
|
|
6677
6775
|
});
|
|
6678
6776
|
continue;
|
|
6679
6777
|
}
|
|
6778
|
+
if (commitment.type === 'FROM') {
|
|
6779
|
+
const content = spaceTrim$2(commitment.content).split('\n')[0] || '';
|
|
6780
|
+
if (content === 'Adam' || content === '' /* <- Note: Adam is implicit */) {
|
|
6781
|
+
continue;
|
|
6782
|
+
}
|
|
6783
|
+
let label = content;
|
|
6784
|
+
let iconName = 'SquareArrowOutUpRight'; // Inheritance remote
|
|
6785
|
+
if (content.startsWith('./') || content.startsWith('../') || content.startsWith('/')) {
|
|
6786
|
+
label = content.split('/').pop() || content;
|
|
6787
|
+
iconName = 'SquareArrowUpRight'; // Inheritance local
|
|
6788
|
+
}
|
|
6789
|
+
if (content === 'VOID') {
|
|
6790
|
+
label = 'VOID';
|
|
6791
|
+
iconName = 'ShieldAlert'; // [🧠] Or some other icon for VOID
|
|
6792
|
+
}
|
|
6793
|
+
capabilities.push({
|
|
6794
|
+
type: 'inheritance',
|
|
6795
|
+
label,
|
|
6796
|
+
iconName,
|
|
6797
|
+
agentUrl: content,
|
|
6798
|
+
});
|
|
6799
|
+
continue;
|
|
6800
|
+
}
|
|
6680
6801
|
if (commitment.type === 'IMPORT') {
|
|
6681
6802
|
const content = spaceTrim$2(commitment.content).split('\n')[0] || '';
|
|
6682
6803
|
let label = content;
|
|
6683
|
-
|
|
6804
|
+
let iconName = 'ExternalLink'; // Import remote
|
|
6684
6805
|
try {
|
|
6685
6806
|
if (content.startsWith('http://') || content.startsWith('https://')) {
|
|
6686
6807
|
const url = new URL(content);
|
|
6687
6808
|
label = url.hostname.replace(/^www\./, '') + '.../' + url.pathname.split('/').pop();
|
|
6809
|
+
iconName = 'ExternalLink';
|
|
6688
6810
|
}
|
|
6689
6811
|
else if (content.startsWith('./') || content.startsWith('../') || content.startsWith('/')) {
|
|
6690
6812
|
label = content.split('/').pop() || content;
|
|
6813
|
+
iconName = 'Link'; // Import local
|
|
6691
6814
|
}
|
|
6692
6815
|
}
|
|
6693
6816
|
catch (e) {
|
|
6694
6817
|
// Invalid URL or path, keep default label
|
|
6695
6818
|
}
|
|
6696
6819
|
capabilities.push({
|
|
6697
|
-
type: '
|
|
6820
|
+
type: 'import',
|
|
6698
6821
|
label,
|
|
6699
6822
|
iconName,
|
|
6823
|
+
agentUrl: content,
|
|
6700
6824
|
});
|
|
6701
6825
|
continue;
|
|
6702
6826
|
}
|
|
@@ -6922,5 +7046,5 @@ async function $induceBookDownload(book) {
|
|
|
6922
7046
|
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
6923
7047
|
*/
|
|
6924
7048
|
|
|
6925
|
-
export { $induceBookDownload, $induceFileDownload, $provideScrapersForBrowser, BOOK_LANGUAGE_VERSION, ObjectUrl, PROMPTBOOK_ENGINE_VERSION, SimplePromptInterfaceTools, getIndexedDbStorage, getLocalStorage, getSessionStorage };
|
|
7049
|
+
export { $induceBookDownload, $induceFileDownload, $provideScrapersForBrowser, BOOK_LANGUAGE_VERSION, BrowserSpeechRecognition, ObjectUrl, PROMPTBOOK_ENGINE_VERSION, SimplePromptInterfaceTools, getIndexedDbStorage, getLocalStorage, getSessionStorage };
|
|
6926
7050
|
//# sourceMappingURL=index.es.js.map
|