ttp-agent-sdk 2.48.0 → 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 +431 -154
- package/dist/agent-widget.esm.js +1 -1
- package/dist/agent-widget.js +1 -1
- package/dist/demos/test-widget.html +72 -2
- package/dist/examples/test-widget.html +21 -0
- package/dist/index.html +19 -2
- package/examples/test-widget.html +69 -2
- package/package.json +2 -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">
|
|
@@ -335,6 +336,16 @@
|
|
|
335
336
|
<span>Use Shadow DOM</span>
|
|
336
337
|
</label>
|
|
337
338
|
</div>
|
|
339
|
+
|
|
340
|
+
<div class="config-group">
|
|
341
|
+
<label style="display: flex; align-items: center; gap: 8px;">
|
|
342
|
+
<input type="checkbox" id="flavorCallViewMinimized">
|
|
343
|
+
<span>Flavor: callView minimized</span>
|
|
344
|
+
</label>
|
|
345
|
+
<p style="font-size: 12px; color: #6b7280; margin-top: 6px;">
|
|
346
|
+
When checked, initializes with <code>flavor: { callView: "minimized" }</code>
|
|
347
|
+
</p>
|
|
348
|
+
</div>
|
|
338
349
|
</div>
|
|
339
350
|
|
|
340
351
|
<div class="info-box" style="margin-top: 24px;">
|
|
@@ -402,9 +413,51 @@
|
|
|
402
413
|
|
|
403
414
|
<script src="demo-sdk-loader.js"></script>
|
|
404
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
|
+
|
|
405
457
|
console.log('🔵 Waiting for SDK to load (use top-right toggle for prod/dev)...');
|
|
406
458
|
|
|
407
459
|
function initSDK() {
|
|
460
|
+
applySavedDemoIds();
|
|
408
461
|
if (typeof window.TTPAgentSDK === 'undefined') {
|
|
409
462
|
return;
|
|
410
463
|
}
|
|
@@ -452,6 +505,8 @@
|
|
|
452
505
|
return;
|
|
453
506
|
}
|
|
454
507
|
|
|
508
|
+
saveDemoIds(agentId, appId);
|
|
509
|
+
|
|
455
510
|
// Destroy existing widget if any
|
|
456
511
|
if (window.widgetInstance) {
|
|
457
512
|
window.destroyWidget();
|
|
@@ -466,6 +521,9 @@
|
|
|
466
521
|
language: language,
|
|
467
522
|
primaryColor: primaryColor,
|
|
468
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,
|
|
469
527
|
behavior: {
|
|
470
528
|
mode: mode
|
|
471
529
|
}
|
|
@@ -501,6 +559,11 @@
|
|
|
501
559
|
console.log('👁️ Visual Assistant enabled:', config.visualAssistant);
|
|
502
560
|
}
|
|
503
561
|
|
|
562
|
+
if (document.getElementById('flavorCallViewMinimized').checked) {
|
|
563
|
+
config.flavor = { callView: 'minimized' };
|
|
564
|
+
console.log('Flavor callView:', config.flavor);
|
|
565
|
+
}
|
|
566
|
+
|
|
504
567
|
console.log('Initializing widget with config:', config);
|
|
505
568
|
console.log('TTPChatWidget constructor:', window.TTPChatWidget);
|
|
506
569
|
window.widgetInstance = new window.TTPChatWidget(config);
|
|
@@ -544,14 +607,16 @@
|
|
|
544
607
|
};
|
|
545
608
|
|
|
546
609
|
window.resetConfig = function() {
|
|
547
|
-
|
|
548
|
-
document.getElementById('
|
|
610
|
+
localStorage.removeItem(DEMO_IDS_KEY);
|
|
611
|
+
document.getElementById('agentId').value = DEFAULT_AGENT_ID;
|
|
612
|
+
document.getElementById('appId').value = DEFAULT_APP_ID;
|
|
549
613
|
document.getElementById('getSessionUrl').value = '';
|
|
550
614
|
document.getElementById('position').value = 'bottom-right';
|
|
551
615
|
document.getElementById('language').value = 'en';
|
|
552
616
|
document.getElementById('mode').value = 'unified';
|
|
553
617
|
document.getElementById('primaryColor').value = '#7C3AED';
|
|
554
618
|
document.getElementById('useShadowDOM').checked = true;
|
|
619
|
+
document.getElementById('flavorCallViewMinimized').checked = false;
|
|
555
620
|
// Reset Visual Assistant settings
|
|
556
621
|
document.getElementById('visualAssistantEnabled').checked = true;
|
|
557
622
|
document.getElementById('allowHighlight').checked = true;
|
|
@@ -657,6 +722,11 @@
|
|
|
657
722
|
window.TTPDemoSdkLoader.waitForReady().then(() => {
|
|
658
723
|
updateWsUrlDisplay();
|
|
659
724
|
initSDK();
|
|
725
|
+
// Auto-init on load so you don't have to click "Initialize Widget" every refresh
|
|
726
|
+
if (typeof window.initializeWidget === 'function'
|
|
727
|
+
&& document.getElementById('widgetStatus')?.textContent !== 'Yes') {
|
|
728
|
+
window.initializeWidget();
|
|
729
|
+
}
|
|
660
730
|
}).catch((e) => {
|
|
661
731
|
console.error('❌ SDK load failed:', e);
|
|
662
732
|
alert('SDK load failed. Check Network for agent-widget*.js');
|
|
@@ -335,6 +335,16 @@
|
|
|
335
335
|
<span>Use Shadow DOM</span>
|
|
336
336
|
</label>
|
|
337
337
|
</div>
|
|
338
|
+
|
|
339
|
+
<div class="config-group">
|
|
340
|
+
<label style="display: flex; align-items: center; gap: 8px;">
|
|
341
|
+
<input type="checkbox" id="flavorCallViewMinimized">
|
|
342
|
+
<span>Flavor: callView minimized</span>
|
|
343
|
+
</label>
|
|
344
|
+
<p style="font-size: 12px; color: #6b7280; margin-top: 6px;">
|
|
345
|
+
When checked, initializes with <code>flavor: { callView: "minimized" }</code>
|
|
346
|
+
</p>
|
|
347
|
+
</div>
|
|
338
348
|
</div>
|
|
339
349
|
|
|
340
350
|
<div class="info-box" style="margin-top: 24px;">
|
|
@@ -501,6 +511,11 @@
|
|
|
501
511
|
console.log('👁️ Visual Assistant enabled:', config.visualAssistant);
|
|
502
512
|
}
|
|
503
513
|
|
|
514
|
+
if (document.getElementById('flavorCallViewMinimized').checked) {
|
|
515
|
+
config.flavor = { callView: 'minimized' };
|
|
516
|
+
console.log('Flavor callView:', config.flavor);
|
|
517
|
+
}
|
|
518
|
+
|
|
504
519
|
console.log('Initializing widget with config:', config);
|
|
505
520
|
console.log('TTPChatWidget constructor:', window.TTPChatWidget);
|
|
506
521
|
window.widgetInstance = new window.TTPChatWidget(config);
|
|
@@ -552,6 +567,7 @@
|
|
|
552
567
|
document.getElementById('mode').value = 'unified';
|
|
553
568
|
document.getElementById('primaryColor').value = '#7C3AED';
|
|
554
569
|
document.getElementById('useShadowDOM').checked = true;
|
|
570
|
+
document.getElementById('flavorCallViewMinimized').checked = false;
|
|
555
571
|
// Reset Visual Assistant settings
|
|
556
572
|
document.getElementById('visualAssistantEnabled').checked = true;
|
|
557
573
|
document.getElementById('allowHighlight').checked = true;
|
|
@@ -657,6 +673,11 @@
|
|
|
657
673
|
window.TTPDemoSdkLoader.waitForReady().then(() => {
|
|
658
674
|
updateWsUrlDisplay();
|
|
659
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
|
+
}
|
|
660
681
|
}).catch((e) => {
|
|
661
682
|
console.error('❌ SDK load failed:', e);
|
|
662
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>
|
|
@@ -1656,6 +1656,12 @@ document.getElementById('myButton').onclick = () => {
|
|
|
1656
1656
|
<td>auto</td>
|
|
1657
1657
|
<td><strong>Root-level override.</strong> Force mobile-style voice call UI (bottom bar + overlay) or desktop hero. Takes precedence over <code>behavior.mobileVoiceUI</code> when both are set. Omit for auto: native iOS/Android, or viewport ≤768px with touch/coarse pointer.</td>
|
|
1658
1658
|
</tr>
|
|
1659
|
+
<tr>
|
|
1660
|
+
<td><code>flavor</code></td>
|
|
1661
|
+
<td>object</td>
|
|
1662
|
+
<td>null</td>
|
|
1663
|
+
<td>Optional flavor object. Verticals use <code>type</code> + <code>partnerId</code> (see <a href="#widget-flavors">Widget Flavors</a>). <code>callView: 'minimized'</code> is a <strong>widget-only</strong> UI flag (desktop >768px bottom voice strip). It is not sent on the hello wire and is ignored by the backend Flavor DTO. Standalone example: <code>flavor: { callView: 'minimized' }</code>. On phones the strip does not apply — mobile uses the normal panel / text chat.</td>
|
|
1664
|
+
</tr>
|
|
1659
1665
|
<tr>
|
|
1660
1666
|
<td><code>inputFormat</code></td>
|
|
1661
1667
|
<td>object</td>
|
|
@@ -3519,9 +3525,14 @@ flyToCart.triggerFly(cardElement, product, () => {
|
|
|
3519
3525
|
appId: 'app_...',
|
|
3520
3526
|
flavor: {
|
|
3521
3527
|
type: 'pharma', // 'ecommerce' | 'hotels' | 'pharma' | 'restaurants' | 'tours'
|
|
3522
|
-
partnerId: 'mock-pharm' // partner-specific data source
|
|
3528
|
+
partnerId: 'mock-pharm', // partner-specific data source
|
|
3529
|
+
callView: 'minimized' // optional — desktop bottom voice strip during a call
|
|
3523
3530
|
}
|
|
3524
3531
|
});</code></pre>
|
|
3532
|
+
<p><code>callView: 'minimized'</code> also works with no vertical <code>type</code>:</p>
|
|
3533
|
+
<pre><code>flavor: {
|
|
3534
|
+
callView: "minimized"
|
|
3535
|
+
}</code></pre>
|
|
3525
3536
|
|
|
3526
3537
|
<h2>Pharma Flavor</h2>
|
|
3527
3538
|
<p>The pharmacy flavor provides a medication search and prescription management experience.</p>
|
|
@@ -3839,6 +3850,12 @@ async (ctx) => {
|
|
|
3839
3850
|
<td>No</td>
|
|
3840
3851
|
<td>Frame duration for raw PCM streaming in milliseconds (default: 600)</td>
|
|
3841
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>
|
|
3842
3859
|
<tr>
|
|
3843
3860
|
<td><code>protocolVersion</code></td>
|
|
3844
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">
|
|
@@ -335,6 +336,16 @@
|
|
|
335
336
|
<span>Use Shadow DOM</span>
|
|
336
337
|
</label>
|
|
337
338
|
</div>
|
|
339
|
+
|
|
340
|
+
<div class="config-group">
|
|
341
|
+
<label style="display: flex; align-items: center; gap: 8px;">
|
|
342
|
+
<input type="checkbox" id="flavorCallViewMinimized">
|
|
343
|
+
<span>Flavor: callView minimized</span>
|
|
344
|
+
</label>
|
|
345
|
+
<p style="font-size: 12px; color: #6b7280; margin-top: 6px;">
|
|
346
|
+
When checked, initializes with <code>flavor: { callView: "minimized" }</code>
|
|
347
|
+
</p>
|
|
348
|
+
</div>
|
|
338
349
|
</div>
|
|
339
350
|
|
|
340
351
|
<div class="info-box" style="margin-top: 24px;">
|
|
@@ -402,9 +413,51 @@
|
|
|
402
413
|
|
|
403
414
|
<script src="demo-sdk-loader.js"></script>
|
|
404
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
|
+
|
|
405
457
|
console.log('🔵 Waiting for SDK to load (use top-right toggle for prod/dev)...');
|
|
406
458
|
|
|
407
459
|
function initSDK() {
|
|
460
|
+
applySavedDemoIds();
|
|
408
461
|
if (typeof window.TTPAgentSDK === 'undefined') {
|
|
409
462
|
return;
|
|
410
463
|
}
|
|
@@ -452,6 +505,8 @@
|
|
|
452
505
|
return;
|
|
453
506
|
}
|
|
454
507
|
|
|
508
|
+
saveDemoIds(agentId, appId);
|
|
509
|
+
|
|
455
510
|
// Destroy existing widget if any
|
|
456
511
|
if (window.widgetInstance) {
|
|
457
512
|
window.destroyWidget();
|
|
@@ -501,6 +556,11 @@
|
|
|
501
556
|
console.log('👁️ Visual Assistant enabled:', config.visualAssistant);
|
|
502
557
|
}
|
|
503
558
|
|
|
559
|
+
if (document.getElementById('flavorCallViewMinimized').checked) {
|
|
560
|
+
config.flavor = { callView: 'minimized' };
|
|
561
|
+
console.log('Flavor callView:', config.flavor);
|
|
562
|
+
}
|
|
563
|
+
|
|
504
564
|
console.log('Initializing widget with config:', config);
|
|
505
565
|
console.log('TTPChatWidget constructor:', window.TTPChatWidget);
|
|
506
566
|
window.widgetInstance = new window.TTPChatWidget(config);
|
|
@@ -544,14 +604,16 @@
|
|
|
544
604
|
};
|
|
545
605
|
|
|
546
606
|
window.resetConfig = function() {
|
|
547
|
-
|
|
548
|
-
document.getElementById('
|
|
607
|
+
localStorage.removeItem(DEMO_IDS_KEY);
|
|
608
|
+
document.getElementById('agentId').value = DEFAULT_AGENT_ID;
|
|
609
|
+
document.getElementById('appId').value = DEFAULT_APP_ID;
|
|
549
610
|
document.getElementById('getSessionUrl').value = '';
|
|
550
611
|
document.getElementById('position').value = 'bottom-right';
|
|
551
612
|
document.getElementById('language').value = 'en';
|
|
552
613
|
document.getElementById('mode').value = 'unified';
|
|
553
614
|
document.getElementById('primaryColor').value = '#7C3AED';
|
|
554
615
|
document.getElementById('useShadowDOM').checked = true;
|
|
616
|
+
document.getElementById('flavorCallViewMinimized').checked = false;
|
|
555
617
|
// Reset Visual Assistant settings
|
|
556
618
|
document.getElementById('visualAssistantEnabled').checked = true;
|
|
557
619
|
document.getElementById('allowHighlight').checked = true;
|
|
@@ -657,6 +719,11 @@
|
|
|
657
719
|
window.TTPDemoSdkLoader.waitForReady().then(() => {
|
|
658
720
|
updateWsUrlDisplay();
|
|
659
721
|
initSDK();
|
|
722
|
+
// Auto-init on load so you don't have to click "Initialize Widget" every refresh
|
|
723
|
+
if (typeof window.initializeWidget === 'function'
|
|
724
|
+
&& document.getElementById('widgetStatus')?.textContent !== 'Yes') {
|
|
725
|
+
window.initializeWidget();
|
|
726
|
+
}
|
|
660
727
|
}).catch((e) => {
|
|
661
728
|
console.error('❌ SDK load failed:', e);
|
|
662
729
|
alert('SDK load failed. Check Network for agent-widget*.js');
|
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",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"test:verify-adapter": "node scripts/verify-adapter.test.mjs",
|
|
40
40
|
"test:compile-adapter": "node scripts/compile-adapter.test.mjs",
|
|
41
41
|
"test:adapters": "npm run test:compile-adapter && npm run test:verify-adapter",
|
|
42
|
+
"test:client-tools": "node --test test/client-tools-registry.test.mjs",
|
|
42
43
|
"clean": "rm -rf dist/",
|
|
43
44
|
"prebuild": "npm run clean"
|
|
44
45
|
},
|