ttp-agent-sdk 2.43.0 → 2.45.1
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 +5999 -2308
- package/dist/agent-widget.dev.js.map +1 -1
- package/dist/agent-widget.esm.js +1 -1
- package/dist/agent-widget.esm.js.map +1 -1
- package/dist/agent-widget.js +1 -1
- package/dist/agent-widget.js.map +1 -1
- package/dist/audio-processor.js +2 -2
- package/dist/demos/demo-sdk-loader.js +1 -0
- package/dist/demos/discovery.js +1 -0
- package/dist/demos/index.html +0 -13
- package/dist/demos/test-ecommerce.html +28 -45
- package/dist/demos/test-tour.html +19 -35
- package/dist/demos/test-widget.html +38 -18
- package/dist/demos/widget-customization-dev.html +15 -6
- package/dist/demos/widget-customization.html +14 -6
- package/dist/discovery.js +1 -0
- package/dist/examples/demo-sdk-loader.js +1 -0
- package/dist/examples/demo-v2.html +2 -2
- package/dist/examples/discovery.js +1 -0
- package/dist/examples/ocado-cart-network-probe.js +1 -0
- package/dist/examples/sobeys-cart-dispatch-probe.js +1 -0
- package/dist/examples/sobeys-cart-read-test.html +112 -0
- package/dist/examples/sobeys-cart-read-test.js +1 -0
- package/dist/examples/sobeys-cart-subscribe-probe.js +1 -0
- package/dist/examples/sobeys-cart-subscribe-test.html +168 -0
- package/dist/examples/sobeys-cart-subscribe-test.js +1 -0
- package/dist/examples/sobeys-inject-probe-min.js +1 -0
- package/dist/examples/sobeys-inject-probe.js +1 -0
- package/dist/examples/test-ecommerce.html +28 -45
- package/dist/examples/test-index.html +0 -13
- package/dist/examples/test-restaurant.html +4 -2
- package/dist/examples/test-tour.html +19 -35
- package/dist/examples/test-widget.html +38 -18
- package/dist/examples/widget-customization-dev.html +15 -6
- package/dist/examples/widget-customization.html +14 -6
- package/dist/hooks/noyhasade.js +1 -0
- package/examples/demo-sdk-loader.js +249 -0
- package/examples/demo-v2.html +2 -2
- package/examples/test-ecommerce.html +28 -45
- package/examples/test-index.html +0 -13
- package/examples/test-restaurant.html +4 -2
- package/examples/test-tour.html +19 -35
- package/examples/test-widget.html +38 -18
- package/examples/widget-customization-dev.html +15 -6
- package/examples/widget-customization.html +14 -6
- package/package.json +2 -2
|
@@ -119,16 +119,14 @@
|
|
|
119
119
|
</head>
|
|
120
120
|
<body>
|
|
121
121
|
<div class="container">
|
|
122
|
-
<h1>TTP Hotels
|
|
122
|
+
<h1>TTP Flavor Test (Ecommerce / Hotels / …)</h1>
|
|
123
123
|
|
|
124
124
|
<div class="info">
|
|
125
125
|
<strong>How it works:</strong>
|
|
126
126
|
<ul>
|
|
127
|
-
<li>
|
|
128
|
-
<li>
|
|
129
|
-
<li>
|
|
130
|
-
<li>Booking summary updates on <code>booking_updated</code> messages</li>
|
|
131
|
-
<li>Gallery (<code>show_media</code>) opens fullscreen with widget minimized</li>
|
|
127
|
+
<li>Pick an <strong>Agent</strong> below — the demo passes <code>flavor: { type, partnerId, callView: 'minimized' }</code> for every vertical.</li>
|
|
128
|
+
<li>On <strong>desktop</strong> (>768px), <strong><code>callView: 'minimized'</code></strong> uses the bottom voice strip when a call is active (in-panel active call UI is hidden). Mobile keeps the existing minimized bar behavior.</li>
|
|
129
|
+
<li>Each vertical wires WebSocket handlers (e.g. hotels: <code>show_items</code> rooms, <code>booking_updated</code>, <code>show_media</code>).</li>
|
|
132
130
|
</ul>
|
|
133
131
|
</div>
|
|
134
132
|
|
|
@@ -138,8 +136,8 @@
|
|
|
138
136
|
<div class="settings-grid">
|
|
139
137
|
<label>Agent
|
|
140
138
|
<select id="agentSelect" onchange="handleAgentChange()">
|
|
141
|
-
<option value="agent_ed18369b3|app_wNGQKiMUfUT5JdVIaxzXOJfdcgBegxGY5hZo|ecommerce|mock-store">Ecommerce Demo (agent_ed18369b3)</option>
|
|
142
|
-
<option value="agent_d0774f1af|app_wNGQKiMUfUT5JdVIaxzXOJfdcgBegxGY5hZo|hotels|mock-hotel"
|
|
139
|
+
<option value="agent_ed18369b3|app_wNGQKiMUfUT5JdVIaxzXOJfdcgBegxGY5hZo|ecommerce|mock-store" selected>Ecommerce Demo (agent_ed18369b3)</option>
|
|
140
|
+
<option value="agent_d0774f1af|app_wNGQKiMUfUT5JdVIaxzXOJfdcgBegxGY5hZo|hotels|mock-hotel">Hotels Demo (agent_d0774f1af)</option>
|
|
143
141
|
<option value="agent_PHARMA_ID|app_wNGQKiMUfUT5JdVIaxzXOJfdcgBegxGY5hZo|pharma|mock-pharm">Pharma Demo (update agent ID)</option>
|
|
144
142
|
<option value="agent_RESTAURANT_ID|app_wNGQKiMUfUT5JdVIaxzXOJfdcgBegxGY5hZo|restaurants|mock-restaurant">Restaurant Demo (update agent ID)</option>
|
|
145
143
|
<option value="agent_TOUR_ID|app_wNGQKiMUfUT5JdVIaxzXOJfdcgBegxGY5hZo|tours|mock-tour">Tour Demo (update agent ID)</option>
|
|
@@ -166,11 +164,11 @@
|
|
|
166
164
|
</label>
|
|
167
165
|
<label>STT Provider
|
|
168
166
|
<select id="sttSelect">
|
|
167
|
+
<option value="soniox" selected>Soniox (default — no override)</option>
|
|
169
168
|
<option value="">Default (server)</option>
|
|
170
|
-
<option value="azure-stt"
|
|
169
|
+
<option value="azure-stt">Azure STT</option>
|
|
171
170
|
<option value="cartesia-stt">Cartesia (Ink-Whisper)</option>
|
|
172
171
|
<option value="openai-realtime">OpenAI Realtime</option>
|
|
173
|
-
<option value="soniox">Soniox</option>
|
|
174
172
|
</select>
|
|
175
173
|
</label>
|
|
176
174
|
<label>Start Open
|
|
@@ -233,24 +231,7 @@ window.testWidget._flavor.messageHandlers['show_media']({
|
|
|
233
231
|
});</div>
|
|
234
232
|
</div>
|
|
235
233
|
|
|
236
|
-
<script>
|
|
237
|
-
(function() {
|
|
238
|
-
var isNgrok = window.location.hostname.includes('ngrok');
|
|
239
|
-
if (isNgrok) {
|
|
240
|
-
var s = document.createElement('script');
|
|
241
|
-
s.type = 'text/javascript';
|
|
242
|
-
document.head.appendChild(s);
|
|
243
|
-
fetch('/agent-widget.js', { headers: { 'ngrok-skip-browser-warning': '1' } })
|
|
244
|
-
.then(function(r) { return r.text(); })
|
|
245
|
-
.then(function(code) { s.textContent = code; })
|
|
246
|
-
.catch(function(e) { console.error('SDK fetch failed:', e); });
|
|
247
|
-
} else {
|
|
248
|
-
var s = document.createElement('script');
|
|
249
|
-
s.src = '/agent-widget.js';
|
|
250
|
-
document.head.appendChild(s);
|
|
251
|
-
}
|
|
252
|
-
})();
|
|
253
|
-
</script>
|
|
234
|
+
<script src="demo-sdk-loader.js"></script>
|
|
254
235
|
|
|
255
236
|
<script>
|
|
256
237
|
let chatWidget = null;
|
|
@@ -296,7 +277,7 @@ window.testWidget._flavor.messageHandlers['show_media']({
|
|
|
296
277
|
|
|
297
278
|
const agent = getAgentConfig();
|
|
298
279
|
|
|
299
|
-
|
|
280
|
+
const widgetConfig = window.TTPDemoSdkLoader.applyWebSocketUrl({
|
|
300
281
|
agentId: agent.agentId,
|
|
301
282
|
appId: agent.appId,
|
|
302
283
|
language: document.getElementById('languageSelect').value,
|
|
@@ -304,7 +285,8 @@ window.testWidget._flavor.messageHandlers['show_media']({
|
|
|
304
285
|
agentSettingsOverride: (() => {
|
|
305
286
|
const override = {};
|
|
306
287
|
const stt = document.getElementById('sttSelect').value;
|
|
307
|
-
|
|
288
|
+
// Soniox is server default; only override when picking a non-default provider
|
|
289
|
+
if (stt && stt !== 'soniox') override.sttProvider = stt;
|
|
308
290
|
return override;
|
|
309
291
|
})(),
|
|
310
292
|
behavior: {
|
|
@@ -312,7 +294,8 @@ window.testWidget._flavor.messageHandlers['show_media']({
|
|
|
312
294
|
},
|
|
313
295
|
flavor: {
|
|
314
296
|
type: agent.flavorType,
|
|
315
|
-
partnerId: agent.partnerId
|
|
297
|
+
partnerId: agent.partnerId,
|
|
298
|
+
callView: 'minimized',
|
|
316
299
|
},
|
|
317
300
|
icon: {
|
|
318
301
|
type: 'custom',
|
|
@@ -325,6 +308,7 @@ window.testWidget._flavor.messageHandlers['show_media']({
|
|
|
325
308
|
text: 'היי, אשמח אם תוכלי לעזור לי '
|
|
326
309
|
}
|
|
327
310
|
});
|
|
311
|
+
chatWidget = new TTPAgentSDK.TTPChatWidget(widgetConfig);
|
|
328
312
|
|
|
329
313
|
window.testWidget = chatWidget;
|
|
330
314
|
const sttLabel = document.getElementById('sttSelect').selectedOptions[0].text;
|
|
@@ -415,24 +399,23 @@ window.testWidget._flavor.messageHandlers['show_media']({
|
|
|
415
399
|
};
|
|
416
400
|
|
|
417
401
|
// Wait for SDK and auto-create
|
|
418
|
-
function
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const iv = setInterval(() => {
|
|
423
|
-
attempts++;
|
|
424
|
-
if (window.TTPAgentSDK?.TTPChatWidget) { clearInterval(iv); resolve(); }
|
|
425
|
-
else if (attempts >= 150) { clearInterval(iv); reject(new Error('SDK failed to load')); }
|
|
426
|
-
}, 100);
|
|
427
|
-
});
|
|
402
|
+
function boot() {
|
|
403
|
+
const mode = window.TTPDemoSdkLoader?.getMode?.() || 'prod';
|
|
404
|
+
updateStatus('SDK loaded (' + mode + ') — click Create Widget or wait...', '');
|
|
405
|
+
createWidget();
|
|
428
406
|
}
|
|
429
407
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
408
|
+
window.addEventListener('ttp-demo-sdk-ready', () => {
|
|
409
|
+
if (chatWidget) {
|
|
410
|
+
chatWidget.destroy();
|
|
411
|
+
chatWidget = null;
|
|
412
|
+
}
|
|
413
|
+
boot();
|
|
414
|
+
});
|
|
415
|
+
window.TTPDemoSdkLoader.waitForReady().then(boot).catch((e) => {
|
|
434
416
|
updateStatus('SDK load failed: ' + e.message, 'error');
|
|
435
417
|
});
|
|
436
418
|
</script>
|
|
419
|
+
<script src="discovery.js"></script>
|
|
437
420
|
</body>
|
|
438
421
|
</html>
|
package/examples/test-index.html
CHANGED
|
@@ -192,19 +192,6 @@
|
|
|
192
192
|
</div>
|
|
193
193
|
</a>
|
|
194
194
|
|
|
195
|
-
<a href="../examples/test-signed-link.html" class="test-card">
|
|
196
|
-
<span class="test-card__icon">🔐</span>
|
|
197
|
-
<h3 class="test-card__title">Signed Link Test</h3>
|
|
198
|
-
<p class="test-card__description">
|
|
199
|
-
Test secure authentication using signed links. Demonstrates how to use signed URLs
|
|
200
|
-
for production-ready voice agent integration without exposing agent IDs.
|
|
201
|
-
</p>
|
|
202
|
-
<div class="test-card__badges">
|
|
203
|
-
<span class="badge badge--voice">Voice</span>
|
|
204
|
-
<span class="badge badge--sdk">Security</span>
|
|
205
|
-
</div>
|
|
206
|
-
</a>
|
|
207
|
-
|
|
208
195
|
<a href="../examples/test.html" class="test-card">
|
|
209
196
|
<span class="test-card__icon">⚡</span>
|
|
210
197
|
<h3 class="test-card__title">Basic Voice Test</h3>
|
|
@@ -149,8 +149,9 @@
|
|
|
149
149
|
</label>
|
|
150
150
|
<label>STT Provider
|
|
151
151
|
<select id="sttSelect">
|
|
152
|
+
<option value="soniox" selected>Soniox (default — no override)</option>
|
|
152
153
|
<option value="">Default (server)</option>
|
|
153
|
-
<option value="azure-stt"
|
|
154
|
+
<option value="azure-stt">Azure STT</option>
|
|
154
155
|
</select>
|
|
155
156
|
</label>
|
|
156
157
|
</div>
|
|
@@ -251,7 +252,8 @@ window.testWidget._flavor.messageHandlers['show_items']({
|
|
|
251
252
|
agentSettingsOverride: (() => {
|
|
252
253
|
const override = {};
|
|
253
254
|
const stt = document.getElementById('sttSelect').value;
|
|
254
|
-
|
|
255
|
+
// Soniox is server default; only override when picking a non-default provider
|
|
256
|
+
if (stt && stt !== 'soniox') override.sttProvider = stt;
|
|
255
257
|
return override;
|
|
256
258
|
})(),
|
|
257
259
|
behavior: {
|
package/examples/test-tour.html
CHANGED
|
@@ -149,8 +149,9 @@
|
|
|
149
149
|
</label>
|
|
150
150
|
<label>STT Provider
|
|
151
151
|
<select id="sttSelect">
|
|
152
|
+
<option value="soniox" selected>Soniox (default — no override)</option>
|
|
152
153
|
<option value="">Default (server)</option>
|
|
153
|
-
<option value="azure-stt"
|
|
154
|
+
<option value="azure-stt">Azure STT</option>
|
|
154
155
|
</select>
|
|
155
156
|
</label>
|
|
156
157
|
</div>
|
|
@@ -201,24 +202,7 @@ window.testWidget._flavor.messageHandlers['show_items']({
|
|
|
201
202
|
});</div>
|
|
202
203
|
</div>
|
|
203
204
|
|
|
204
|
-
<script>
|
|
205
|
-
(function() {
|
|
206
|
-
var isNgrok = window.location.hostname.includes('ngrok');
|
|
207
|
-
if (isNgrok) {
|
|
208
|
-
var s = document.createElement('script');
|
|
209
|
-
s.type = 'text/javascript';
|
|
210
|
-
document.head.appendChild(s);
|
|
211
|
-
fetch('/agent-widget.js', { headers: { 'ngrok-skip-browser-warning': '1' } })
|
|
212
|
-
.then(function(r) { return r.text(); })
|
|
213
|
-
.then(function(code) { s.textContent = code; })
|
|
214
|
-
.catch(function(e) { console.error('SDK fetch failed:', e); });
|
|
215
|
-
} else {
|
|
216
|
-
var s = document.createElement('script');
|
|
217
|
-
s.src = '/agent-widget.js';
|
|
218
|
-
document.head.appendChild(s);
|
|
219
|
-
}
|
|
220
|
-
})();
|
|
221
|
-
</script>
|
|
205
|
+
<script src="demo-sdk-loader.js"></script>
|
|
222
206
|
|
|
223
207
|
<script>
|
|
224
208
|
let chatWidget = null;
|
|
@@ -244,14 +228,15 @@ window.testWidget._flavor.messageHandlers['show_items']({
|
|
|
244
228
|
const agentId = document.getElementById('agentId').value;
|
|
245
229
|
const appId = document.getElementById('appId').value;
|
|
246
230
|
|
|
247
|
-
|
|
231
|
+
const widgetConfig = window.TTPDemoSdkLoader.applyWebSocketUrl({
|
|
248
232
|
agentId,
|
|
249
233
|
appId,
|
|
250
234
|
language: document.getElementById('languageSelect').value,
|
|
251
235
|
agentSettingsOverride: (() => {
|
|
252
236
|
const override = {};
|
|
253
237
|
const stt = document.getElementById('sttSelect').value;
|
|
254
|
-
|
|
238
|
+
// Soniox is server default; only override when picking a non-default provider
|
|
239
|
+
if (stt && stt !== 'soniox') override.sttProvider = stt;
|
|
255
240
|
return override;
|
|
256
241
|
})(),
|
|
257
242
|
behavior: {
|
|
@@ -272,6 +257,7 @@ window.testWidget._flavor.messageHandlers['show_items']({
|
|
|
272
257
|
text: 'היי, אשמח אם תוכלי לעזור לי במשהו....'
|
|
273
258
|
}
|
|
274
259
|
});
|
|
260
|
+
chatWidget = new TTPAgentSDK.TTPChatWidget(widgetConfig);
|
|
275
261
|
|
|
276
262
|
window.testWidget = chatWidget;
|
|
277
263
|
updateStatus('TTPChatWidget created — tours flavor (mock-tour)', 'success');
|
|
@@ -352,22 +338,20 @@ window.testWidget._flavor.messageHandlers['show_items']({
|
|
|
352
338
|
updateStatus('Booking cleared', '');
|
|
353
339
|
};
|
|
354
340
|
|
|
355
|
-
function
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const iv = setInterval(() => {
|
|
360
|
-
attempts++;
|
|
361
|
-
if (window.TTPAgentSDK?.TTPChatWidget) { clearInterval(iv); resolve(); }
|
|
362
|
-
else if (attempts >= 150) { clearInterval(iv); reject(new Error('SDK failed to load')); }
|
|
363
|
-
}, 100);
|
|
364
|
-
});
|
|
341
|
+
function boot() {
|
|
342
|
+
const mode = window.TTPDemoSdkLoader?.getMode?.() || 'prod';
|
|
343
|
+
updateStatus('SDK loaded (' + mode + ') — creating widget...', '');
|
|
344
|
+
createWidget();
|
|
365
345
|
}
|
|
366
346
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
347
|
+
window.addEventListener('ttp-demo-sdk-ready', () => {
|
|
348
|
+
if (chatWidget) {
|
|
349
|
+
chatWidget.destroy();
|
|
350
|
+
chatWidget = null;
|
|
351
|
+
}
|
|
352
|
+
boot();
|
|
353
|
+
});
|
|
354
|
+
window.TTPDemoSdkLoader.waitForReady().then(boot).catch((e) => {
|
|
371
355
|
updateStatus('SDK load failed: ' + e.message, 'error');
|
|
372
356
|
});
|
|
373
357
|
</script>
|
|
@@ -285,9 +285,11 @@
|
|
|
285
285
|
<input type="text" id="getSessionUrl" value="" placeholder="https://your-api.com/get-session">
|
|
286
286
|
</div>
|
|
287
287
|
|
|
288
|
-
<div class="config-group">
|
|
289
|
-
<label
|
|
290
|
-
<
|
|
288
|
+
<div class="config-group" style="grid-column: 1 / -1;">
|
|
289
|
+
<label>WebSocket URL</label>
|
|
290
|
+
<p id="demoWsUrlDisplay" style="font-size: 13px; color: #4b5563; margin-top: 4px; font-family: monospace;">
|
|
291
|
+
Set by SDK toggle (top-right): Production → speech.talktopc.com · Development → speech.bidme.co.il
|
|
292
|
+
</p>
|
|
291
293
|
</div>
|
|
292
294
|
|
|
293
295
|
<div class="config-group">
|
|
@@ -398,16 +400,12 @@
|
|
|
398
400
|
</div>
|
|
399
401
|
</div>
|
|
400
402
|
|
|
401
|
-
|
|
402
|
-
<script src="/agent-widget.js" onload="console.log('✅ SDK script loaded, TTPAgentSDK:', typeof window.TTPAgentSDK)" onerror="console.error('❌ Failed to load SDK script')"></script>
|
|
403
|
+
<script src="demo-sdk-loader.js"></script>
|
|
403
404
|
<script>
|
|
404
|
-
console.log('🔵 Waiting for SDK to load...');
|
|
405
|
-
|
|
406
|
-
// Wait for TTPAgentSDK to be available (UMD library loads as global)
|
|
405
|
+
console.log('🔵 Waiting for SDK to load (use top-right toggle for prod/dev)...');
|
|
406
|
+
|
|
407
407
|
function initSDK() {
|
|
408
408
|
if (typeof window.TTPAgentSDK === 'undefined') {
|
|
409
|
-
console.log('⏳ TTPAgentSDK not ready yet, waiting...');
|
|
410
|
-
setTimeout(initSDK, 100);
|
|
411
409
|
return;
|
|
412
410
|
}
|
|
413
411
|
|
|
@@ -427,6 +425,8 @@
|
|
|
427
425
|
|
|
428
426
|
window.TTPChatWidget = TTPChatWidget;
|
|
429
427
|
window.widgetInstance = null;
|
|
428
|
+
const mode = window.TTPDemoSdkLoader?.getMode?.() || '?';
|
|
429
|
+
console.log('✅ SDK ready:', window.TTPDemoSdkLoader?.getSrc?.(mode), '(' + mode + ')');
|
|
430
430
|
|
|
431
431
|
// Define functions after module loads
|
|
432
432
|
window.initializeWidget = function() {
|
|
@@ -442,7 +442,6 @@
|
|
|
442
442
|
const agentId = document.getElementById('agentId').value;
|
|
443
443
|
const appId = document.getElementById('appId').value;
|
|
444
444
|
const getSessionUrl = document.getElementById('getSessionUrl').value;
|
|
445
|
-
const websocketUrl = document.getElementById('websocketUrl').value;
|
|
446
445
|
const position = document.getElementById('position').value;
|
|
447
446
|
const language = document.getElementById('language').value;
|
|
448
447
|
const mode = document.getElementById('mode').value;
|
|
@@ -477,9 +476,8 @@
|
|
|
477
476
|
config.getSessionUrl = getSessionUrl;
|
|
478
477
|
}
|
|
479
478
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}
|
|
479
|
+
window.TTPDemoSdkLoader.applyWebSocketUrl(config);
|
|
480
|
+
console.log('🔌 websocketUrl:', config.websocketUrl, '(SDK mode:', window.TTPDemoSdkLoader.getMode() + ')');
|
|
483
481
|
|
|
484
482
|
// Handle position
|
|
485
483
|
if (position) {
|
|
@@ -549,7 +547,6 @@
|
|
|
549
547
|
document.getElementById('agentId').value = 'agent_e5cf06457';
|
|
550
548
|
document.getElementById('appId').value = 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC';
|
|
551
549
|
document.getElementById('getSessionUrl').value = '';
|
|
552
|
-
document.getElementById('websocketUrl').value = 'wss://speech.talktopc.com/ws/conv';
|
|
553
550
|
document.getElementById('position').value = 'bottom-right';
|
|
554
551
|
document.getElementById('language').value = 'en';
|
|
555
552
|
document.getElementById('mode').value = 'unified';
|
|
@@ -638,9 +635,32 @@
|
|
|
638
635
|
resetConfig: typeof window.resetConfig
|
|
639
636
|
});
|
|
640
637
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
638
|
+
|
|
639
|
+
function updateWsUrlDisplay() {
|
|
640
|
+
const el = document.getElementById('demoWsUrlDisplay');
|
|
641
|
+
if (!el || !window.TTPDemoSdkLoader) return;
|
|
642
|
+
const mode = window.TTPDemoSdkLoader.getMode();
|
|
643
|
+
el.textContent = window.TTPDemoSdkLoader.getWebSocketUrl(mode) + ' (' + mode + ')';
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
window.addEventListener('ttp-demo-sdk-ready', () => {
|
|
647
|
+
updateWsUrlDisplay();
|
|
648
|
+
if (window.widgetInstance && typeof window.destroyWidget === 'function') {
|
|
649
|
+
window.destroyWidget();
|
|
650
|
+
}
|
|
651
|
+
initSDK();
|
|
652
|
+
// Re-create widget if user already initialized (so WS URL matches new SDK mode)
|
|
653
|
+
if (typeof window.initializeWidget === 'function' && document.getElementById('widgetStatus')?.textContent === 'Yes') {
|
|
654
|
+
window.initializeWidget();
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
window.TTPDemoSdkLoader.waitForReady().then(() => {
|
|
658
|
+
updateWsUrlDisplay();
|
|
659
|
+
initSDK();
|
|
660
|
+
}).catch((e) => {
|
|
661
|
+
console.error('❌ SDK load failed:', e);
|
|
662
|
+
alert('SDK load failed. Check Network for agent-widget*.js');
|
|
663
|
+
});
|
|
644
664
|
</script>
|
|
645
665
|
</body>
|
|
646
666
|
</html>
|
|
@@ -1280,10 +1280,11 @@
|
|
|
1280
1280
|
}
|
|
1281
1281
|
}
|
|
1282
1282
|
</style>
|
|
1283
|
+
<script src="demo-sdk-loader.js"></script>
|
|
1283
1284
|
</head>
|
|
1284
1285
|
<body>
|
|
1285
1286
|
<div class="header">
|
|
1286
|
-
<div class="dev-banner"
|
|
1287
|
+
<div class="dev-banner">🔧 Use the SDK toggle (top-right) to switch Production ↔ Development bundles</div>
|
|
1287
1288
|
<a href="test-index.html" class="back-link">← Back to Demos</a>
|
|
1288
1289
|
<h1>🎨 Widget Live Customization (Dev Page)</h1>
|
|
1289
1290
|
<div style="margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 24px; flex-wrap: wrap;">
|
|
@@ -4126,6 +4127,10 @@
|
|
|
4126
4127
|
}
|
|
4127
4128
|
};
|
|
4128
4129
|
|
|
4130
|
+
if (window.TTPDemoSdkLoader) {
|
|
4131
|
+
window.TTPDemoSdkLoader.applyWebSocketUrl(actualConfig);
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4129
4134
|
try {
|
|
4130
4135
|
// Reset manual close tracking when widget is recreated (unless user manually closed it)
|
|
4131
4136
|
// Don't reset if widget was manually closed and mock panel is also closed
|
|
@@ -4348,8 +4353,15 @@
|
|
|
4348
4353
|
};
|
|
4349
4354
|
|
|
4350
4355
|
// Start checking for SDK (will also be called when script loads)
|
|
4351
|
-
window.
|
|
4352
|
-
|
|
4356
|
+
window.addEventListener('ttp-demo-sdk-ready', () => {
|
|
4357
|
+
if (actualWidgetInstance) {
|
|
4358
|
+
try { actualWidgetInstance.destroy(); } catch (e) { /* ignore */ }
|
|
4359
|
+
actualWidgetInstance = null;
|
|
4360
|
+
}
|
|
4361
|
+
window.checkAndInitWidget();
|
|
4362
|
+
});
|
|
4363
|
+
window.TTPDemoSdkLoader.waitForReady().then(() => window.checkAndInitWidget());
|
|
4364
|
+
|
|
4353
4365
|
// Debug helper - expose widget instance globally for inspection
|
|
4354
4366
|
window.debugWidget = function() {
|
|
4355
4367
|
console.log('=== Widget Debug Info ===');
|
|
@@ -4376,8 +4388,5 @@
|
|
|
4376
4388
|
};
|
|
4377
4389
|
};
|
|
4378
4390
|
</script>
|
|
4379
|
-
|
|
4380
|
-
<!-- Load the widget SDK (production version) -->
|
|
4381
|
-
<script src="/agent-widget.js?v=2.34.2" onload="if (typeof window.checkAndInitWidget === 'function') setTimeout(window.checkAndInitWidget, 100);" onerror="console.error('❌ Failed to load SDK script from /agent-widget.js'); alert('Failed to load SDK. Check console for details.');"></script>
|
|
4382
4391
|
</body>
|
|
4383
4392
|
</html>
|
|
@@ -1793,6 +1793,7 @@
|
|
|
1793
1793
|
}
|
|
1794
1794
|
}
|
|
1795
1795
|
</style>
|
|
1796
|
+
<script src="demo-sdk-loader.js"></script>
|
|
1796
1797
|
</head>
|
|
1797
1798
|
<body>
|
|
1798
1799
|
<div class="header">
|
|
@@ -5017,6 +5018,10 @@
|
|
|
5017
5018
|
}
|
|
5018
5019
|
};
|
|
5019
5020
|
|
|
5021
|
+
if (window.TTPDemoSdkLoader) {
|
|
5022
|
+
window.TTPDemoSdkLoader.applyWebSocketUrl(actualConfig);
|
|
5023
|
+
}
|
|
5024
|
+
|
|
5020
5025
|
try {
|
|
5021
5026
|
// Reset manual close tracking when widget is recreated (unless user manually closed it)
|
|
5022
5027
|
// Don't reset if widget was manually closed and mock panel is also closed
|
|
@@ -5450,9 +5455,15 @@
|
|
|
5450
5455
|
}
|
|
5451
5456
|
};
|
|
5452
5457
|
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5458
|
+
window.addEventListener('ttp-demo-sdk-ready', () => {
|
|
5459
|
+
if (actualWidgetInstance) {
|
|
5460
|
+
try { actualWidgetInstance.destroy(); } catch (e) { /* ignore */ }
|
|
5461
|
+
actualWidgetInstance = null;
|
|
5462
|
+
}
|
|
5463
|
+
window.checkAndInitWidget();
|
|
5464
|
+
});
|
|
5465
|
+
window.TTPDemoSdkLoader.waitForReady().then(() => window.checkAndInitWidget());
|
|
5466
|
+
|
|
5456
5467
|
// Debug helper - expose widget instance globally for inspection
|
|
5457
5468
|
window.debugWidget = function() {
|
|
5458
5469
|
console.log('=== Widget Debug Info ===');
|
|
@@ -5479,8 +5490,5 @@
|
|
|
5479
5490
|
};
|
|
5480
5491
|
};
|
|
5481
5492
|
</script>
|
|
5482
|
-
|
|
5483
|
-
<!-- Load the widget SDK -->
|
|
5484
|
-
<script src="/agent-widget.js" onload="if (typeof window.checkAndInitWidget === 'function') setTimeout(window.checkAndInitWidget, 100);" onerror="console.error('❌ Failed to load SDK script from /agent-widget.js'); alert('Failed to load SDK. Check console for details.');"></script>
|
|
5485
5493
|
</body>
|
|
5486
5494
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ttp-agent-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.45.1",
|
|
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",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"README.md",
|
|
20
20
|
"GETTING_STARTED.md",
|
|
21
21
|
"ENHANCED_WIDGET_GUIDE.md",
|
|
22
|
-
"SIGNED_LINK_GUIDE.md",
|
|
23
22
|
"WORDPRESS_WIX_GUIDE.md"
|
|
24
23
|
],
|
|
25
24
|
"scripts": {
|
|
26
25
|
"build": "npm run build:umd && npm run build:esm && npm run build:dev",
|
|
27
26
|
"deploy": "npm run build && npx wrangler pages deploy dist --project-name=ttp-sdk-front --branch=master --commit-dirty=true",
|
|
27
|
+
"deploy:sandbox": "./deploy-sandbox-sdk.sh",
|
|
28
28
|
"deploy:prod": "./deploy-production.sh",
|
|
29
29
|
"build:prod": "webpack --config webpack.config.js",
|
|
30
30
|
"build:dev": "webpack --config webpack.dev.config.js",
|