ttp-agent-sdk 2.44.0 → 2.45.4

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.
@@ -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 for="websocketUrl">WebSocket URL</label>
290
- <input type="text" id="websocketUrl" value="wss://speech.talktopc.com/ws/conv" placeholder="wss://...">
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
- <!-- Load SDK as UMD library (script tag) -->
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
- if (websocketUrl) {
481
- config.websocketUrl = websocketUrl;
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
- // Start initialization
643
- initSDK();
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">⚠️ DEV PAGE - Using production SDK (agent-widget.js)</div>
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.checkAndInitWidget();
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
- // Start checking for SDK (will also be called when script loads)
5454
- window.checkAndInitWidget();
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.44.0",
3
+ "version": "2.45.4",
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",
@@ -24,6 +24,7 @@
24
24
  "scripts": {
25
25
  "build": "npm run build:umd && npm run build:esm && npm run build:dev",
26
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",
27
28
  "deploy:prod": "./deploy-production.sh",
28
29
  "build:prod": "webpack --config webpack.config.js",
29
30
  "build:dev": "webpack --config webpack.dev.config.js",