ttp-agent-sdk 2.48.1 → 2.48.2
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/dist/agent-widget.dev.js +77 -66
- package/dist/agent-widget.esm.js +1 -1
- package/dist/agent-widget.js +1 -1
- package/dist/demos/test-widget.html +51 -2
- package/dist/examples/test-widget.html +5 -0
- package/dist/index.html +7 -1
- package/examples/test-widget.html +48 -2
- package/package.json +1 -1
|
@@ -273,6 +273,7 @@
|
|
|
273
273
|
<div class="config-group">
|
|
274
274
|
<label for="agentId">Agent ID *</label>
|
|
275
275
|
<input type="text" id="agentId" value="agent_e5cf06457" placeholder="agent_123">
|
|
276
|
+
<p style="font-size: 12px; color: #6b7280; margin-top: 6px;">Saved in this browser after you set them once.</p>
|
|
276
277
|
</div>
|
|
277
278
|
|
|
278
279
|
<div class="config-group">
|
|
@@ -412,9 +413,51 @@
|
|
|
412
413
|
|
|
413
414
|
<script src="demo-sdk-loader.js"></script>
|
|
414
415
|
<script>
|
|
416
|
+
const DEMO_IDS_KEY = 'ttp-demo-widget-ids';
|
|
417
|
+
const DEFAULT_AGENT_ID = 'agent_e5cf06457';
|
|
418
|
+
const DEFAULT_APP_ID = 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC';
|
|
419
|
+
|
|
420
|
+
function loadSavedDemoIds() {
|
|
421
|
+
try {
|
|
422
|
+
const parsed = JSON.parse(localStorage.getItem(DEMO_IDS_KEY) || 'null');
|
|
423
|
+
if (parsed && typeof parsed.agentId === 'string' && typeof parsed.appId === 'string'
|
|
424
|
+
&& parsed.agentId.trim() && parsed.appId.trim()) {
|
|
425
|
+
return { agentId: parsed.agentId.trim(), appId: parsed.appId.trim() };
|
|
426
|
+
}
|
|
427
|
+
} catch (e) { /* ignore bad localStorage */ }
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function saveDemoIds(agentId, appId) {
|
|
432
|
+
const next = { agentId: (agentId || '').trim(), appId: (appId || '').trim() };
|
|
433
|
+
if (!next.agentId || !next.appId) return;
|
|
434
|
+
localStorage.setItem(DEMO_IDS_KEY, JSON.stringify(next));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function applySavedDemoIds() {
|
|
438
|
+
const saved = loadSavedDemoIds();
|
|
439
|
+
if (!saved) return saved;
|
|
440
|
+
const agentEl = document.getElementById('agentId');
|
|
441
|
+
const appEl = document.getElementById('appId');
|
|
442
|
+
if (agentEl) agentEl.value = saved.agentId;
|
|
443
|
+
if (appEl) appEl.value = saved.appId;
|
|
444
|
+
return saved;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
applySavedDemoIds();
|
|
448
|
+
['agentId', 'appId'].forEach((id) => {
|
|
449
|
+
document.getElementById(id)?.addEventListener('change', () => {
|
|
450
|
+
saveDemoIds(
|
|
451
|
+
document.getElementById('agentId')?.value,
|
|
452
|
+
document.getElementById('appId')?.value
|
|
453
|
+
);
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
|
|
415
457
|
console.log('🔵 Waiting for SDK to load (use top-right toggle for prod/dev)...');
|
|
416
458
|
|
|
417
459
|
function initSDK() {
|
|
460
|
+
applySavedDemoIds();
|
|
418
461
|
if (typeof window.TTPAgentSDK === 'undefined') {
|
|
419
462
|
return;
|
|
420
463
|
}
|
|
@@ -462,6 +505,8 @@
|
|
|
462
505
|
return;
|
|
463
506
|
}
|
|
464
507
|
|
|
508
|
+
saveDemoIds(agentId, appId);
|
|
509
|
+
|
|
465
510
|
// Destroy existing widget if any
|
|
466
511
|
if (window.widgetInstance) {
|
|
467
512
|
window.destroyWidget();
|
|
@@ -476,6 +521,9 @@
|
|
|
476
521
|
language: language,
|
|
477
522
|
primaryColor: primaryColor,
|
|
478
523
|
useShadowDOM: useShadowDOM,
|
|
524
|
+
// Same last-hop as platform Test AI Agent (2.48.0 destination).
|
|
525
|
+
// 2.48.1 HTML <audio> hop played 24 kHz TTS ~2× on this page.
|
|
526
|
+
htmlAudioPlayback: false,
|
|
479
527
|
behavior: {
|
|
480
528
|
mode: mode
|
|
481
529
|
}
|
|
@@ -559,8 +607,9 @@
|
|
|
559
607
|
};
|
|
560
608
|
|
|
561
609
|
window.resetConfig = function() {
|
|
562
|
-
|
|
563
|
-
document.getElementById('
|
|
610
|
+
localStorage.removeItem(DEMO_IDS_KEY);
|
|
611
|
+
document.getElementById('agentId').value = DEFAULT_AGENT_ID;
|
|
612
|
+
document.getElementById('appId').value = DEFAULT_APP_ID;
|
|
564
613
|
document.getElementById('getSessionUrl').value = '';
|
|
565
614
|
document.getElementById('position').value = 'bottom-right';
|
|
566
615
|
document.getElementById('language').value = 'en';
|
|
@@ -673,6 +673,11 @@
|
|
|
673
673
|
window.TTPDemoSdkLoader.waitForReady().then(() => {
|
|
674
674
|
updateWsUrlDisplay();
|
|
675
675
|
initSDK();
|
|
676
|
+
// Auto-init on load so you don't have to click "Initialize Widget" every refresh
|
|
677
|
+
if (typeof window.initializeWidget === 'function'
|
|
678
|
+
&& document.getElementById('widgetStatus')?.textContent !== 'Yes') {
|
|
679
|
+
window.initializeWidget();
|
|
680
|
+
}
|
|
676
681
|
}).catch((e) => {
|
|
677
682
|
console.error('❌ SDK load failed:', e);
|
|
678
683
|
alert('SDK load failed. Check Network for agent-widget*.js');
|
package/dist/index.html
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<img src="https://talktopc.com/logo192.png" alt="TTP Logo" style="width: 40px; height: 40px; border-radius: 8px;">
|
|
24
24
|
<div>
|
|
25
25
|
<h1 style="margin: 0; font-size: 1.4rem;">TTP Agent SDK</h1>
|
|
26
|
-
<p class="version" style="margin: 0;">v2.
|
|
26
|
+
<p class="version" style="margin: 0;">v2.48.2</p>
|
|
27
27
|
</div>
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
@@ -3850,6 +3850,12 @@ async (ctx) => {
|
|
|
3850
3850
|
<td>No</td>
|
|
3851
3851
|
<td>Frame duration for raw PCM streaming in milliseconds (default: 600)</td>
|
|
3852
3852
|
</tr>
|
|
3853
|
+
<tr>
|
|
3854
|
+
<td><code>htmlAudioPlayback</code></td>
|
|
3855
|
+
<td>boolean</td>
|
|
3856
|
+
<td>No</td>
|
|
3857
|
+
<td>Play TTS through a hidden <code><audio></code> element (AEC far-end). Default <code>true</code>. The playback AudioContext runs at the device rate (typically 48 kHz); PCM buffers stay at <code>outputSampleRate</code> (default 24 kHz). Set <code>false</code> to use <code>AudioContext.destination</code> (2.48.0 path).</td>
|
|
3858
|
+
</tr>
|
|
3853
3859
|
<tr>
|
|
3854
3860
|
<td><code>protocolVersion</code></td>
|
|
3855
3861
|
<td>number</td>
|
|
@@ -273,6 +273,7 @@
|
|
|
273
273
|
<div class="config-group">
|
|
274
274
|
<label for="agentId">Agent ID *</label>
|
|
275
275
|
<input type="text" id="agentId" value="agent_e5cf06457" placeholder="agent_123">
|
|
276
|
+
<p style="font-size: 12px; color: #6b7280; margin-top: 6px;">Saved in this browser after you set them once.</p>
|
|
276
277
|
</div>
|
|
277
278
|
|
|
278
279
|
<div class="config-group">
|
|
@@ -412,9 +413,51 @@
|
|
|
412
413
|
|
|
413
414
|
<script src="demo-sdk-loader.js"></script>
|
|
414
415
|
<script>
|
|
416
|
+
const DEMO_IDS_KEY = 'ttp-demo-widget-ids';
|
|
417
|
+
const DEFAULT_AGENT_ID = 'agent_e5cf06457';
|
|
418
|
+
const DEFAULT_APP_ID = 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC';
|
|
419
|
+
|
|
420
|
+
function loadSavedDemoIds() {
|
|
421
|
+
try {
|
|
422
|
+
const parsed = JSON.parse(localStorage.getItem(DEMO_IDS_KEY) || 'null');
|
|
423
|
+
if (parsed && typeof parsed.agentId === 'string' && typeof parsed.appId === 'string'
|
|
424
|
+
&& parsed.agentId.trim() && parsed.appId.trim()) {
|
|
425
|
+
return { agentId: parsed.agentId.trim(), appId: parsed.appId.trim() };
|
|
426
|
+
}
|
|
427
|
+
} catch (e) { /* ignore bad localStorage */ }
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function saveDemoIds(agentId, appId) {
|
|
432
|
+
const next = { agentId: (agentId || '').trim(), appId: (appId || '').trim() };
|
|
433
|
+
if (!next.agentId || !next.appId) return;
|
|
434
|
+
localStorage.setItem(DEMO_IDS_KEY, JSON.stringify(next));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function applySavedDemoIds() {
|
|
438
|
+
const saved = loadSavedDemoIds();
|
|
439
|
+
if (!saved) return saved;
|
|
440
|
+
const agentEl = document.getElementById('agentId');
|
|
441
|
+
const appEl = document.getElementById('appId');
|
|
442
|
+
if (agentEl) agentEl.value = saved.agentId;
|
|
443
|
+
if (appEl) appEl.value = saved.appId;
|
|
444
|
+
return saved;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
applySavedDemoIds();
|
|
448
|
+
['agentId', 'appId'].forEach((id) => {
|
|
449
|
+
document.getElementById(id)?.addEventListener('change', () => {
|
|
450
|
+
saveDemoIds(
|
|
451
|
+
document.getElementById('agentId')?.value,
|
|
452
|
+
document.getElementById('appId')?.value
|
|
453
|
+
);
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
|
|
415
457
|
console.log('🔵 Waiting for SDK to load (use top-right toggle for prod/dev)...');
|
|
416
458
|
|
|
417
459
|
function initSDK() {
|
|
460
|
+
applySavedDemoIds();
|
|
418
461
|
if (typeof window.TTPAgentSDK === 'undefined') {
|
|
419
462
|
return;
|
|
420
463
|
}
|
|
@@ -462,6 +505,8 @@
|
|
|
462
505
|
return;
|
|
463
506
|
}
|
|
464
507
|
|
|
508
|
+
saveDemoIds(agentId, appId);
|
|
509
|
+
|
|
465
510
|
// Destroy existing widget if any
|
|
466
511
|
if (window.widgetInstance) {
|
|
467
512
|
window.destroyWidget();
|
|
@@ -559,8 +604,9 @@
|
|
|
559
604
|
};
|
|
560
605
|
|
|
561
606
|
window.resetConfig = function() {
|
|
562
|
-
|
|
563
|
-
document.getElementById('
|
|
607
|
+
localStorage.removeItem(DEMO_IDS_KEY);
|
|
608
|
+
document.getElementById('agentId').value = DEFAULT_AGENT_ID;
|
|
609
|
+
document.getElementById('appId').value = DEFAULT_APP_ID;
|
|
564
610
|
document.getElementById('getSessionUrl').value = '';
|
|
565
611
|
document.getElementById('position').value = 'bottom-right';
|
|
566
612
|
document.getElementById('language').value = 'en';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ttp-agent-sdk",
|
|
3
|
-
"version": "2.48.
|
|
3
|
+
"version": "2.48.2",
|
|
4
4
|
"description": "Comprehensive Voice Agent SDK with Customizable Widget - Real-time audio, WebSocket communication, React components, and extensive customization options",
|
|
5
5
|
"main": "dist/agent-widget.js",
|
|
6
6
|
"module": "dist/agent-widget.esm.js",
|