ttp-agent-sdk 2.3.21 → 2.3.23
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.js +1 -1
- package/dist/agent-widget.js.map +1 -1
- package/dist/examples/demo-v2.html +146 -16
- package/dist/examples/test-text-chat.html +9 -3
- package/dist/index.html +3 -3
- package/examples/demo-v2.html +146 -16
- package/examples/test-text-chat.html +9 -3
- package/package.json +1 -1
|
@@ -524,6 +524,64 @@
|
|
|
524
524
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
.variable-item {
|
|
530
|
+
|
|
531
|
+
display: grid;
|
|
532
|
+
|
|
533
|
+
grid-template-columns: 1fr 1fr auto;
|
|
534
|
+
|
|
535
|
+
gap: 10px;
|
|
536
|
+
|
|
537
|
+
margin-bottom: 10px;
|
|
538
|
+
|
|
539
|
+
align-items: center;
|
|
540
|
+
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
.variable-item input {
|
|
546
|
+
|
|
547
|
+
padding: 8px;
|
|
548
|
+
|
|
549
|
+
border: 1px solid #ddd;
|
|
550
|
+
|
|
551
|
+
border-radius: 6px;
|
|
552
|
+
|
|
553
|
+
font-size: 13px;
|
|
554
|
+
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
.variable-item button {
|
|
560
|
+
|
|
561
|
+
padding: 8px 12px;
|
|
562
|
+
|
|
563
|
+
background: #ef4444;
|
|
564
|
+
|
|
565
|
+
color: white;
|
|
566
|
+
|
|
567
|
+
border: none;
|
|
568
|
+
|
|
569
|
+
border-radius: 6px;
|
|
570
|
+
|
|
571
|
+
cursor: pointer;
|
|
572
|
+
|
|
573
|
+
font-size: 12px;
|
|
574
|
+
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
.variable-item button:hover {
|
|
580
|
+
|
|
581
|
+
background: #dc2626;
|
|
582
|
+
|
|
583
|
+
}
|
|
584
|
+
|
|
527
585
|
</style>
|
|
528
586
|
|
|
529
587
|
</head>
|
|
@@ -543,6 +601,11 @@
|
|
|
543
601
|
<div class="config-section">
|
|
544
602
|
|
|
545
603
|
<h2 style="margin-bottom: 15px; font-size: 18px;">⚙️ Configuration</h2>
|
|
604
|
+
|
|
605
|
+
<!-- Mobile Browser Notice -->
|
|
606
|
+
<div style="background: #fef3c7; border-left: 4px solid #f59e0b; padding: 12px; border-radius: 6px; margin-bottom: 15px; font-size: 13px;">
|
|
607
|
+
<strong>📱 Mobile Browser Note:</strong> Microphone access requires HTTPS and must be triggered by a direct button tap. If you see permission errors, ensure you're using HTTPS and tap the recording button directly (not from an iframe).
|
|
608
|
+
</div>
|
|
546
609
|
|
|
547
610
|
|
|
548
611
|
|
|
@@ -566,7 +629,7 @@
|
|
|
566
629
|
|
|
567
630
|
<label>WebSocket URL</label>
|
|
568
631
|
|
|
569
|
-
<input type="text" id="websocketUrl" value="wss://speech.
|
|
632
|
+
<input type="text" id="websocketUrl" value="wss://speech.talktopc.com/ws/conv">
|
|
570
633
|
|
|
571
634
|
</div>
|
|
572
635
|
|
|
@@ -578,7 +641,7 @@
|
|
|
578
641
|
|
|
579
642
|
<label>Agent ID</label>
|
|
580
643
|
|
|
581
|
-
<input type="text" id="agentId" value="
|
|
644
|
+
<input type="text" id="agentId" value="agent_e5cf06457" placeholder="agent-123">
|
|
582
645
|
|
|
583
646
|
</div>
|
|
584
647
|
|
|
@@ -594,6 +657,22 @@
|
|
|
594
657
|
|
|
595
658
|
|
|
596
659
|
|
|
660
|
+
<!-- Variables Section -->
|
|
661
|
+
<div class="config-group" style="margin-top: 20px;">
|
|
662
|
+
<label>Variables (Optional)</label>
|
|
663
|
+
<div id="variablesContainer" style="background: white; padding: 15px; border-radius: 8px; border: 2px solid #ddd;">
|
|
664
|
+
<div id="variablesList"></div>
|
|
665
|
+
<button type="button" id="addVariableBtn" style="margin-top: 10px; padding: 8px 15px; background: #667eea; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 13px;">
|
|
666
|
+
+ Add Variable
|
|
667
|
+
</button>
|
|
668
|
+
</div>
|
|
669
|
+
<small style="color: #666; font-size: 12px; margin-top: 5px; display: block;">
|
|
670
|
+
Variables will replace {{VARIABLE_NAME}} placeholders in your agent's prompt
|
|
671
|
+
</small>
|
|
672
|
+
</div>
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
597
676
|
<div class="config-row" id="v2OnlyConfig">
|
|
598
677
|
|
|
599
678
|
<div class="config-group">
|
|
@@ -602,9 +681,9 @@
|
|
|
602
681
|
|
|
603
682
|
<select id="outputContainer">
|
|
604
683
|
|
|
605
|
-
<option value="raw">Raw (No container)</option>
|
|
684
|
+
<option value="raw" selected>Raw (No container)</option>
|
|
606
685
|
|
|
607
|
-
<option value="wav"
|
|
686
|
+
<option value="wav">WAV (With header)</option>
|
|
608
687
|
|
|
609
688
|
</select>
|
|
610
689
|
|
|
@@ -640,13 +719,13 @@
|
|
|
640
719
|
|
|
641
720
|
<option value="8000">8 kHz (Telephony)</option>
|
|
642
721
|
|
|
643
|
-
<option value="16000"
|
|
722
|
+
<option value="16000">16 kHz (Voice)</option>
|
|
644
723
|
|
|
645
724
|
<option value="22050">22.05 kHz</option>
|
|
646
725
|
|
|
647
726
|
<option value="24000">24 kHz</option>
|
|
648
727
|
|
|
649
|
-
<option value="44100">44.1 kHz (CD Quality)</option>
|
|
728
|
+
<option value="44100" selected>44.1 kHz (CD Quality)</option>
|
|
650
729
|
|
|
651
730
|
<option value="48000">48 kHz (Pro)</option>
|
|
652
731
|
|
|
@@ -788,8 +867,8 @@
|
|
|
788
867
|
|
|
789
868
|
<!-- Load SDK -->
|
|
790
869
|
|
|
791
|
-
<!-- Load SDK
|
|
792
|
-
<script src="../agent-widget.js"></script>
|
|
870
|
+
<!-- Load SDK from local build -->
|
|
871
|
+
<script src="../dist/agent-widget.js"></script>
|
|
793
872
|
|
|
794
873
|
<script>
|
|
795
874
|
|
|
@@ -846,6 +925,55 @@
|
|
|
846
925
|
|
|
847
926
|
let sdk = null;
|
|
848
927
|
|
|
928
|
+
// Variables management
|
|
929
|
+
let variableCount = 0;
|
|
930
|
+
const variablesContainer = document.getElementById('variablesContainer');
|
|
931
|
+
const variablesList = document.getElementById('variablesList');
|
|
932
|
+
const addVariableBtn = document.getElementById('addVariableBtn');
|
|
933
|
+
|
|
934
|
+
function addVariableRow(key = '', value = '') {
|
|
935
|
+
const id = `var_${variableCount++}`;
|
|
936
|
+
const row = document.createElement('div');
|
|
937
|
+
row.className = 'variable-item';
|
|
938
|
+
row.id = id;
|
|
939
|
+
row.innerHTML = `
|
|
940
|
+
<input type="text" placeholder="Variable name (e.g., USER_NAME)" class="var-key" value="${key}" />
|
|
941
|
+
<input type="text" placeholder="Variable value" class="var-value" value="${value}" />
|
|
942
|
+
<button type="button" onclick="removeVariable('${id}')">Remove</button>
|
|
943
|
+
`;
|
|
944
|
+
variablesList.appendChild(row);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
window.removeVariable = function(id) {
|
|
948
|
+
const row = document.getElementById(id);
|
|
949
|
+
if (row) {
|
|
950
|
+
row.remove();
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
function getVariables() {
|
|
955
|
+
const variables = {};
|
|
956
|
+
const rows = variablesList.querySelectorAll('.variable-item');
|
|
957
|
+
rows.forEach(row => {
|
|
958
|
+
const keyInput = row.querySelector('.var-key');
|
|
959
|
+
const valueInput = row.querySelector('.var-value');
|
|
960
|
+
const key = keyInput?.value?.trim();
|
|
961
|
+
const value = valueInput?.value?.trim();
|
|
962
|
+
if (key && value) {
|
|
963
|
+
variables[key] = value;
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
return Object.keys(variables).length > 0 ? variables : undefined;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// Add initial variable rows
|
|
970
|
+
addVariableRow('USER_NAME', '');
|
|
971
|
+
addVariableRow('ACCOUNT_TYPE', '');
|
|
972
|
+
|
|
973
|
+
addVariableBtn.addEventListener('click', () => {
|
|
974
|
+
addVariableRow();
|
|
975
|
+
});
|
|
976
|
+
|
|
849
977
|
// Toggle v2-only config visibility
|
|
850
978
|
const sdkVersionSelect = document.getElementById('sdkVersion');
|
|
851
979
|
const v2OnlyConfig = document.getElementById('v2OnlyConfig');
|
|
@@ -893,6 +1021,9 @@
|
|
|
893
1021
|
// Get selected SDK version
|
|
894
1022
|
const sdkVersion = document.getElementById('sdkVersion').value;
|
|
895
1023
|
|
|
1024
|
+
// Get variables
|
|
1025
|
+
const variables = getVariables();
|
|
1026
|
+
|
|
896
1027
|
// Base config
|
|
897
1028
|
const baseConfig = {
|
|
898
1029
|
websocketUrl: document.getElementById('websocketUrl').value,
|
|
@@ -901,6 +1032,12 @@
|
|
|
901
1032
|
autoReconnect: false
|
|
902
1033
|
};
|
|
903
1034
|
|
|
1035
|
+
// Add variables if provided (v2 only)
|
|
1036
|
+
if (sdkVersion === 'v2' && variables) {
|
|
1037
|
+
baseConfig.variables = variables;
|
|
1038
|
+
log(`📝 Using variables: ${Object.keys(variables).join(', ')}`, 'info');
|
|
1039
|
+
}
|
|
1040
|
+
|
|
904
1041
|
let config;
|
|
905
1042
|
|
|
906
1043
|
if (sdkVersion === 'v2') {
|
|
@@ -1011,21 +1148,14 @@
|
|
|
1011
1148
|
|
|
1012
1149
|
|
|
1013
1150
|
// Record button
|
|
1014
|
-
|
|
1151
|
+
// SDK now handles mobile browser requirements by requesting permission first
|
|
1015
1152
|
btnRecord.addEventListener('click', async () => {
|
|
1016
|
-
|
|
1017
1153
|
try {
|
|
1018
|
-
|
|
1019
1154
|
log('Starting recording...', 'info');
|
|
1020
|
-
|
|
1021
1155
|
await sdk.startRecording();
|
|
1022
|
-
|
|
1023
1156
|
} catch (error) {
|
|
1024
|
-
|
|
1025
1157
|
log(`Error starting recording: ${error.message}`, 'error');
|
|
1026
|
-
|
|
1027
1158
|
}
|
|
1028
|
-
|
|
1029
1159
|
});
|
|
1030
1160
|
|
|
1031
1161
|
|
|
@@ -315,6 +315,12 @@
|
|
|
315
315
|
<span class="section-toggle" id="common-toggle">▼</span>
|
|
316
316
|
</div>
|
|
317
317
|
<div class="section-content" id="common-content">
|
|
318
|
+
<label id="labelAgentId">Agent ID
|
|
319
|
+
<input id="agentIdInput" type="text" value="agent_87c4a55a1" placeholder="agent_xxxxx" />
|
|
320
|
+
</label>
|
|
321
|
+
<label id="labelAppId">App ID
|
|
322
|
+
<input id="appIdInput" type="text" value="app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC" placeholder="app_xxxxx" />
|
|
323
|
+
</label>
|
|
318
324
|
<label id="labelLanguage">Language
|
|
319
325
|
<select id="languageSelect">
|
|
320
326
|
<option value="en">English</option>
|
|
@@ -719,7 +725,7 @@
|
|
|
719
725
|
</div>
|
|
720
726
|
|
|
721
727
|
<!-- Load the SDK from dist folder -->
|
|
722
|
-
<script src="
|
|
728
|
+
<script src="/dist/agent-widget.js" data-agent-id="agent_87c4a55a1" data-app-id="app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC" onload="console.log('SDK script loaded successfully')" onerror="console.error('Failed to load SDK script')"></script>
|
|
723
729
|
|
|
724
730
|
<script>
|
|
725
731
|
// Language selection only affects widget, not page UI
|
|
@@ -870,8 +876,8 @@
|
|
|
870
876
|
|
|
871
877
|
function getConfigFromForm() {
|
|
872
878
|
return {
|
|
873
|
-
agentId: 'agent_87c4a55a1',
|
|
874
|
-
appId: 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC',
|
|
879
|
+
agentId: document.getElementById('agentIdInput').value || 'agent_87c4a55a1',
|
|
880
|
+
appId: document.getElementById('appIdInput').value || 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC',
|
|
875
881
|
direction: document.getElementById('dirSelect').value,
|
|
876
882
|
language: document.getElementById('languageSelect').value,
|
|
877
883
|
position: document.getElementById('posSelect').value,
|
package/dist/index.html
CHANGED
|
@@ -746,7 +746,7 @@ voiceSDK.on('domainError', (error) => {
|
|
|
746
746
|
</tr>
|
|
747
747
|
<tr>
|
|
748
748
|
<td><code>sampleRate</code></td>
|
|
749
|
-
<td>8000, 16000, 24000, 48000 Hz</td>
|
|
749
|
+
<td>8000, 16000, 22050, 24000, 44100, 48000 Hz</td>
|
|
750
750
|
</tr>
|
|
751
751
|
<tr>
|
|
752
752
|
<td><code>bitDepth</code></td>
|
|
@@ -2451,7 +2451,7 @@ function App() {
|
|
|
2451
2451
|
<td><code>sampleRate</code></td>
|
|
2452
2452
|
<td>number</td>
|
|
2453
2453
|
<td>No</td>
|
|
2454
|
-
<td>Input audio sample rate: 8000, 16000, 24000, or 48000 Hz (default: 16000)</td>
|
|
2454
|
+
<td>Input audio sample rate: 8000, 16000, 22050, 24000, 44100, or 48000 Hz (default: 16000)</td>
|
|
2455
2455
|
</tr>
|
|
2456
2456
|
<tr>
|
|
2457
2457
|
<td><code>channels</code></td>
|
|
@@ -2523,7 +2523,7 @@ function App() {
|
|
|
2523
2523
|
<strong>📋 Format Support:</strong>
|
|
2524
2524
|
<ul style="margin-top: 10px;">
|
|
2525
2525
|
<li><strong>Input Encodings:</strong> PCM, PCMU (μ-law), PCMA (A-law)</li>
|
|
2526
|
-
<li><strong>Input Sample Rates:</strong> 8000, 16000, 24000, 48000 Hz</li>
|
|
2526
|
+
<li><strong>Input Sample Rates:</strong> 8000, 16000, 22050, 24000, 44100, 48000 Hz</li>
|
|
2527
2527
|
<li><strong>Input Bit Depths:</strong> 8, 16, 24 bits</li>
|
|
2528
2528
|
<li><strong>Output Containers:</strong> 'raw' (no header) or 'wav' (with header)</li>
|
|
2529
2529
|
<li><strong>Output Encodings:</strong> PCM, PCMU (μ-law), PCMA (A-law)</li>
|
package/examples/demo-v2.html
CHANGED
|
@@ -524,6 +524,64 @@
|
|
|
524
524
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
.variable-item {
|
|
530
|
+
|
|
531
|
+
display: grid;
|
|
532
|
+
|
|
533
|
+
grid-template-columns: 1fr 1fr auto;
|
|
534
|
+
|
|
535
|
+
gap: 10px;
|
|
536
|
+
|
|
537
|
+
margin-bottom: 10px;
|
|
538
|
+
|
|
539
|
+
align-items: center;
|
|
540
|
+
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
.variable-item input {
|
|
546
|
+
|
|
547
|
+
padding: 8px;
|
|
548
|
+
|
|
549
|
+
border: 1px solid #ddd;
|
|
550
|
+
|
|
551
|
+
border-radius: 6px;
|
|
552
|
+
|
|
553
|
+
font-size: 13px;
|
|
554
|
+
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
.variable-item button {
|
|
560
|
+
|
|
561
|
+
padding: 8px 12px;
|
|
562
|
+
|
|
563
|
+
background: #ef4444;
|
|
564
|
+
|
|
565
|
+
color: white;
|
|
566
|
+
|
|
567
|
+
border: none;
|
|
568
|
+
|
|
569
|
+
border-radius: 6px;
|
|
570
|
+
|
|
571
|
+
cursor: pointer;
|
|
572
|
+
|
|
573
|
+
font-size: 12px;
|
|
574
|
+
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
.variable-item button:hover {
|
|
580
|
+
|
|
581
|
+
background: #dc2626;
|
|
582
|
+
|
|
583
|
+
}
|
|
584
|
+
|
|
527
585
|
</style>
|
|
528
586
|
|
|
529
587
|
</head>
|
|
@@ -543,6 +601,11 @@
|
|
|
543
601
|
<div class="config-section">
|
|
544
602
|
|
|
545
603
|
<h2 style="margin-bottom: 15px; font-size: 18px;">⚙️ Configuration</h2>
|
|
604
|
+
|
|
605
|
+
<!-- Mobile Browser Notice -->
|
|
606
|
+
<div style="background: #fef3c7; border-left: 4px solid #f59e0b; padding: 12px; border-radius: 6px; margin-bottom: 15px; font-size: 13px;">
|
|
607
|
+
<strong>📱 Mobile Browser Note:</strong> Microphone access requires HTTPS and must be triggered by a direct button tap. If you see permission errors, ensure you're using HTTPS and tap the recording button directly (not from an iframe).
|
|
608
|
+
</div>
|
|
546
609
|
|
|
547
610
|
|
|
548
611
|
|
|
@@ -566,7 +629,7 @@
|
|
|
566
629
|
|
|
567
630
|
<label>WebSocket URL</label>
|
|
568
631
|
|
|
569
|
-
<input type="text" id="websocketUrl" value="wss://speech.
|
|
632
|
+
<input type="text" id="websocketUrl" value="wss://speech.talktopc.com/ws/conv">
|
|
570
633
|
|
|
571
634
|
</div>
|
|
572
635
|
|
|
@@ -578,7 +641,7 @@
|
|
|
578
641
|
|
|
579
642
|
<label>Agent ID</label>
|
|
580
643
|
|
|
581
|
-
<input type="text" id="agentId" value="
|
|
644
|
+
<input type="text" id="agentId" value="agent_e5cf06457" placeholder="agent-123">
|
|
582
645
|
|
|
583
646
|
</div>
|
|
584
647
|
|
|
@@ -594,6 +657,22 @@
|
|
|
594
657
|
|
|
595
658
|
|
|
596
659
|
|
|
660
|
+
<!-- Variables Section -->
|
|
661
|
+
<div class="config-group" style="margin-top: 20px;">
|
|
662
|
+
<label>Variables (Optional)</label>
|
|
663
|
+
<div id="variablesContainer" style="background: white; padding: 15px; border-radius: 8px; border: 2px solid #ddd;">
|
|
664
|
+
<div id="variablesList"></div>
|
|
665
|
+
<button type="button" id="addVariableBtn" style="margin-top: 10px; padding: 8px 15px; background: #667eea; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 13px;">
|
|
666
|
+
+ Add Variable
|
|
667
|
+
</button>
|
|
668
|
+
</div>
|
|
669
|
+
<small style="color: #666; font-size: 12px; margin-top: 5px; display: block;">
|
|
670
|
+
Variables will replace {{VARIABLE_NAME}} placeholders in your agent's prompt
|
|
671
|
+
</small>
|
|
672
|
+
</div>
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
597
676
|
<div class="config-row" id="v2OnlyConfig">
|
|
598
677
|
|
|
599
678
|
<div class="config-group">
|
|
@@ -602,9 +681,9 @@
|
|
|
602
681
|
|
|
603
682
|
<select id="outputContainer">
|
|
604
683
|
|
|
605
|
-
<option value="raw">Raw (No container)</option>
|
|
684
|
+
<option value="raw" selected>Raw (No container)</option>
|
|
606
685
|
|
|
607
|
-
<option value="wav"
|
|
686
|
+
<option value="wav">WAV (With header)</option>
|
|
608
687
|
|
|
609
688
|
</select>
|
|
610
689
|
|
|
@@ -640,13 +719,13 @@
|
|
|
640
719
|
|
|
641
720
|
<option value="8000">8 kHz (Telephony)</option>
|
|
642
721
|
|
|
643
|
-
<option value="16000"
|
|
722
|
+
<option value="16000">16 kHz (Voice)</option>
|
|
644
723
|
|
|
645
724
|
<option value="22050">22.05 kHz</option>
|
|
646
725
|
|
|
647
726
|
<option value="24000">24 kHz</option>
|
|
648
727
|
|
|
649
|
-
<option value="44100">44.1 kHz (CD Quality)</option>
|
|
728
|
+
<option value="44100" selected>44.1 kHz (CD Quality)</option>
|
|
650
729
|
|
|
651
730
|
<option value="48000">48 kHz (Pro)</option>
|
|
652
731
|
|
|
@@ -788,8 +867,8 @@
|
|
|
788
867
|
|
|
789
868
|
<!-- Load SDK -->
|
|
790
869
|
|
|
791
|
-
<!-- Load SDK
|
|
792
|
-
<script src="../agent-widget.js"></script>
|
|
870
|
+
<!-- Load SDK from local build -->
|
|
871
|
+
<script src="../dist/agent-widget.js"></script>
|
|
793
872
|
|
|
794
873
|
<script>
|
|
795
874
|
|
|
@@ -846,6 +925,55 @@
|
|
|
846
925
|
|
|
847
926
|
let sdk = null;
|
|
848
927
|
|
|
928
|
+
// Variables management
|
|
929
|
+
let variableCount = 0;
|
|
930
|
+
const variablesContainer = document.getElementById('variablesContainer');
|
|
931
|
+
const variablesList = document.getElementById('variablesList');
|
|
932
|
+
const addVariableBtn = document.getElementById('addVariableBtn');
|
|
933
|
+
|
|
934
|
+
function addVariableRow(key = '', value = '') {
|
|
935
|
+
const id = `var_${variableCount++}`;
|
|
936
|
+
const row = document.createElement('div');
|
|
937
|
+
row.className = 'variable-item';
|
|
938
|
+
row.id = id;
|
|
939
|
+
row.innerHTML = `
|
|
940
|
+
<input type="text" placeholder="Variable name (e.g., USER_NAME)" class="var-key" value="${key}" />
|
|
941
|
+
<input type="text" placeholder="Variable value" class="var-value" value="${value}" />
|
|
942
|
+
<button type="button" onclick="removeVariable('${id}')">Remove</button>
|
|
943
|
+
`;
|
|
944
|
+
variablesList.appendChild(row);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
window.removeVariable = function(id) {
|
|
948
|
+
const row = document.getElementById(id);
|
|
949
|
+
if (row) {
|
|
950
|
+
row.remove();
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
function getVariables() {
|
|
955
|
+
const variables = {};
|
|
956
|
+
const rows = variablesList.querySelectorAll('.variable-item');
|
|
957
|
+
rows.forEach(row => {
|
|
958
|
+
const keyInput = row.querySelector('.var-key');
|
|
959
|
+
const valueInput = row.querySelector('.var-value');
|
|
960
|
+
const key = keyInput?.value?.trim();
|
|
961
|
+
const value = valueInput?.value?.trim();
|
|
962
|
+
if (key && value) {
|
|
963
|
+
variables[key] = value;
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
return Object.keys(variables).length > 0 ? variables : undefined;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// Add initial variable rows
|
|
970
|
+
addVariableRow('USER_NAME', '');
|
|
971
|
+
addVariableRow('ACCOUNT_TYPE', '');
|
|
972
|
+
|
|
973
|
+
addVariableBtn.addEventListener('click', () => {
|
|
974
|
+
addVariableRow();
|
|
975
|
+
});
|
|
976
|
+
|
|
849
977
|
// Toggle v2-only config visibility
|
|
850
978
|
const sdkVersionSelect = document.getElementById('sdkVersion');
|
|
851
979
|
const v2OnlyConfig = document.getElementById('v2OnlyConfig');
|
|
@@ -893,6 +1021,9 @@
|
|
|
893
1021
|
// Get selected SDK version
|
|
894
1022
|
const sdkVersion = document.getElementById('sdkVersion').value;
|
|
895
1023
|
|
|
1024
|
+
// Get variables
|
|
1025
|
+
const variables = getVariables();
|
|
1026
|
+
|
|
896
1027
|
// Base config
|
|
897
1028
|
const baseConfig = {
|
|
898
1029
|
websocketUrl: document.getElementById('websocketUrl').value,
|
|
@@ -901,6 +1032,12 @@
|
|
|
901
1032
|
autoReconnect: false
|
|
902
1033
|
};
|
|
903
1034
|
|
|
1035
|
+
// Add variables if provided (v2 only)
|
|
1036
|
+
if (sdkVersion === 'v2' && variables) {
|
|
1037
|
+
baseConfig.variables = variables;
|
|
1038
|
+
log(`📝 Using variables: ${Object.keys(variables).join(', ')}`, 'info');
|
|
1039
|
+
}
|
|
1040
|
+
|
|
904
1041
|
let config;
|
|
905
1042
|
|
|
906
1043
|
if (sdkVersion === 'v2') {
|
|
@@ -1011,21 +1148,14 @@
|
|
|
1011
1148
|
|
|
1012
1149
|
|
|
1013
1150
|
// Record button
|
|
1014
|
-
|
|
1151
|
+
// SDK now handles mobile browser requirements by requesting permission first
|
|
1015
1152
|
btnRecord.addEventListener('click', async () => {
|
|
1016
|
-
|
|
1017
1153
|
try {
|
|
1018
|
-
|
|
1019
1154
|
log('Starting recording...', 'info');
|
|
1020
|
-
|
|
1021
1155
|
await sdk.startRecording();
|
|
1022
|
-
|
|
1023
1156
|
} catch (error) {
|
|
1024
|
-
|
|
1025
1157
|
log(`Error starting recording: ${error.message}`, 'error');
|
|
1026
|
-
|
|
1027
1158
|
}
|
|
1028
|
-
|
|
1029
1159
|
});
|
|
1030
1160
|
|
|
1031
1161
|
|
|
@@ -315,6 +315,12 @@
|
|
|
315
315
|
<span class="section-toggle" id="common-toggle">▼</span>
|
|
316
316
|
</div>
|
|
317
317
|
<div class="section-content" id="common-content">
|
|
318
|
+
<label id="labelAgentId">Agent ID
|
|
319
|
+
<input id="agentIdInput" type="text" value="agent_87c4a55a1" placeholder="agent_xxxxx" />
|
|
320
|
+
</label>
|
|
321
|
+
<label id="labelAppId">App ID
|
|
322
|
+
<input id="appIdInput" type="text" value="app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC" placeholder="app_xxxxx" />
|
|
323
|
+
</label>
|
|
318
324
|
<label id="labelLanguage">Language
|
|
319
325
|
<select id="languageSelect">
|
|
320
326
|
<option value="en">English</option>
|
|
@@ -719,7 +725,7 @@
|
|
|
719
725
|
</div>
|
|
720
726
|
|
|
721
727
|
<!-- Load the SDK from dist folder -->
|
|
722
|
-
<script src="
|
|
728
|
+
<script src="/dist/agent-widget.js" data-agent-id="agent_87c4a55a1" data-app-id="app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC" onload="console.log('SDK script loaded successfully')" onerror="console.error('Failed to load SDK script')"></script>
|
|
723
729
|
|
|
724
730
|
<script>
|
|
725
731
|
// Language selection only affects widget, not page UI
|
|
@@ -870,8 +876,8 @@
|
|
|
870
876
|
|
|
871
877
|
function getConfigFromForm() {
|
|
872
878
|
return {
|
|
873
|
-
agentId: 'agent_87c4a55a1',
|
|
874
|
-
appId: 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC',
|
|
879
|
+
agentId: document.getElementById('agentIdInput').value || 'agent_87c4a55a1',
|
|
880
|
+
appId: document.getElementById('appIdInput').value || 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC',
|
|
875
881
|
direction: document.getElementById('dirSelect').value,
|
|
876
882
|
language: document.getElementById('languageSelect').value,
|
|
877
883
|
position: document.getElementById('posSelect').value,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ttp-agent-sdk",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.23",
|
|
4
4
|
"description": "Comprehensive Voice Agent SDK with Enhanced 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.js",
|