@nac3/runtime 2.6.0 → 2.9.0

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.
@@ -34,13 +34,50 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
34
34
  NacChat.setLang(code)
35
35
  NacChat.snapshotTree() // returns the tree posted to backend
36
36
  NacChat.onAction(kind, fn) // override or extend a kind handler
37
+ NacChat.debug = true // turn the diagnostic log on (OFF by default)
38
+
39
+ THE DIAGNOSTIC LOG IS OFF BY DEFAULT, and that is a deliberate
40
+ change of behaviour made on 2026-11-24. This file carried five
41
+ unconditional console.log calls in published code, and three of them
42
+ printed CONTENT rather than control flow: the language model's reply
43
+ to the user, and -- twice, in the speech path -- the text the
44
+ microphone had just transcribed. An adopter embedding this on a page
45
+ where someone dictates a name, an address or a diagnosis was putting
46
+ that text in the browser console on every utterance, with no switch
47
+ to stop it and nothing in the documentation saying so.
48
+
49
+ What did NOT change: console.warn and console.error still speak
50
+ unconditionally. An adopter has to be able to see that something
51
+ broke; a silent failure is the thing this project argues against.
52
+ Only the diagnostics are behind the switch.
53
+
54
+ To turn them back on, either set NacChat.debug = true at runtime or
55
+ define window.NAC_CHAT_DEBUG = true before this file loads (the
56
+ second form exists because the most useful diagnostics happen during
57
+ init, before anyone has a handle to the object).
37
58
 
38
59
  ASCII-only.
39
60
  =============================================================== */
40
61
  (function (global) {
41
62
  'use strict';
42
63
 
64
+ /* The diagnostic log, off unless asked for. See the header: three of
65
+ these printed user content, so the default has to be quiet. */
66
+ function _dbgEnabled() {
67
+ if (NacChat && NacChat.debug === true) return true;
68
+ return global.NAC_CHAT_DEBUG === true;
69
+ }
70
+ function _dbg() {
71
+ if (!_dbgEnabled()) return;
72
+ if (!global.console || typeof global.console.log !== 'function') return;
73
+ global.console.log.apply(global.console, arguments);
74
+ }
75
+
43
76
  var NacChat = {
77
+ /* Public, additive, and documented in the header. Not a private
78
+ underscore field: an adopter debugging a page needs to be able
79
+ to reach for it without reading the source. */
80
+ debug: false,
44
81
  _endpoint: '/crm/api/v1/yujin/nac-demo',
45
82
  _sessionId: 'sess_' + Math.random().toString(36).slice(2, 10),
46
83
  _lang: 'es',
@@ -290,10 +327,10 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
290
327
  }
291
328
  }
292
329
  } catch (_) {}
293
- console.log('[nac-chat] snapshot plugins (' + plugins.length + '):',
330
+ _dbg('[nac-chat] snapshot plugins (' + plugins.length + '):',
294
331
  plugins.map(function (p) { return p.plugin; }).join(', '));
295
332
  if (out.data_tables && out.data_tables.length) {
296
- console.log('[nac-chat] data_tables:',
333
+ _dbg('[nac-chat] data_tables:',
297
334
  out.data_tables.map(function (t) {
298
335
  return t.table_id + ' (' + t.subkind + ')';
299
336
  }).join(', '));
@@ -519,8 +556,12 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
519
556
  returned so 'chat says X but nothing happens' is
520
557
  distinguishable from 'chat dispatched X but it failed
521
558
  silently'. If the LLM only emits a {message} with no
522
- actions, this log makes it obvious. */
523
- console.log('[nac-chat] backend response: message="' + message
559
+ actions, this log makes it obvious.
560
+
561
+ Behind NacChat.debug since 2026-11-24: `message` is the model's
562
+ reply to the user, so this line published user-facing content to
563
+ the console of every page that embedded the client. */
564
+ _dbg('[nac-chat] backend response: message="' + message
524
565
  + '" actions=' + JSON.stringify(actions));
525
566
  if (message) {
526
567
  _bubble('bot', message);
@@ -559,11 +600,11 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
559
600
  if (NacChat._sttFlushTimer) { clearTimeout(NacChat._sttFlushTimer); NacChat._sttFlushTimer = null; }
560
601
  if (!text) return;
561
602
  if (_isBotEcho(text)) {
562
- console.log('[nac-chat-stt] dropping bot-echo:', text);
603
+ _dbg('[nac-chat-stt] dropping bot-echo:', text);
563
604
  return;
564
605
  }
565
606
  if ('speechSynthesis' in window && window.speechSynthesis.speaking) {
566
- console.log('[nac-chat-stt] dropping during TTS:', text);
607
+ _dbg('[nac-chat-stt] dropping during TTS:', text);
567
608
  return;
568
609
  }
569
610
  NacChat.send(text);
@@ -34,13 +34,50 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
34
34
  NacChat.setLang(code)
35
35
  NacChat.snapshotTree() // returns the tree posted to backend
36
36
  NacChat.onAction(kind, fn) // override or extend a kind handler
37
+ NacChat.debug = true // turn the diagnostic log on (OFF by default)
38
+
39
+ THE DIAGNOSTIC LOG IS OFF BY DEFAULT, and that is a deliberate
40
+ change of behaviour made on 2026-11-24. This file carried five
41
+ unconditional console.log calls in published code, and three of them
42
+ printed CONTENT rather than control flow: the language model's reply
43
+ to the user, and -- twice, in the speech path -- the text the
44
+ microphone had just transcribed. An adopter embedding this on a page
45
+ where someone dictates a name, an address or a diagnosis was putting
46
+ that text in the browser console on every utterance, with no switch
47
+ to stop it and nothing in the documentation saying so.
48
+
49
+ What did NOT change: console.warn and console.error still speak
50
+ unconditionally. An adopter has to be able to see that something
51
+ broke; a silent failure is the thing this project argues against.
52
+ Only the diagnostics are behind the switch.
53
+
54
+ To turn them back on, either set NacChat.debug = true at runtime or
55
+ define window.NAC_CHAT_DEBUG = true before this file loads (the
56
+ second form exists because the most useful diagnostics happen during
57
+ init, before anyone has a handle to the object).
37
58
 
38
59
  ASCII-only.
39
60
  =============================================================== */
40
61
  (function (global) {
41
62
  'use strict';
42
63
 
64
+ /* The diagnostic log, off unless asked for. See the header: three of
65
+ these printed user content, so the default has to be quiet. */
66
+ function _dbgEnabled() {
67
+ if (NacChat && NacChat.debug === true) return true;
68
+ return global.NAC_CHAT_DEBUG === true;
69
+ }
70
+ function _dbg() {
71
+ if (!_dbgEnabled()) return;
72
+ if (!global.console || typeof global.console.log !== 'function') return;
73
+ global.console.log.apply(global.console, arguments);
74
+ }
75
+
43
76
  var NacChat = {
77
+ /* Public, additive, and documented in the header. Not a private
78
+ underscore field: an adopter debugging a page needs to be able
79
+ to reach for it without reading the source. */
80
+ debug: false,
44
81
  _endpoint: '/crm/api/v1/yujin/nac-demo',
45
82
  _sessionId: 'sess_' + Math.random().toString(36).slice(2, 10),
46
83
  _lang: 'es',
@@ -290,10 +327,10 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
290
327
  }
291
328
  }
292
329
  } catch (_) {}
293
- console.log('[nac-chat] snapshot plugins (' + plugins.length + '):',
330
+ _dbg('[nac-chat] snapshot plugins (' + plugins.length + '):',
294
331
  plugins.map(function (p) { return p.plugin; }).join(', '));
295
332
  if (out.data_tables && out.data_tables.length) {
296
- console.log('[nac-chat] data_tables:',
333
+ _dbg('[nac-chat] data_tables:',
297
334
  out.data_tables.map(function (t) {
298
335
  return t.table_id + ' (' + t.subkind + ')';
299
336
  }).join(', '));
@@ -519,8 +556,12 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
519
556
  returned so 'chat says X but nothing happens' is
520
557
  distinguishable from 'chat dispatched X but it failed
521
558
  silently'. If the LLM only emits a {message} with no
522
- actions, this log makes it obvious. */
523
- console.log('[nac-chat] backend response: message="' + message
559
+ actions, this log makes it obvious.
560
+
561
+ Behind NacChat.debug since 2026-11-24: `message` is the model's
562
+ reply to the user, so this line published user-facing content to
563
+ the console of every page that embedded the client. */
564
+ _dbg('[nac-chat] backend response: message="' + message
524
565
  + '" actions=' + JSON.stringify(actions));
525
566
  if (message) {
526
567
  _bubble('bot', message);
@@ -559,11 +600,11 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
559
600
  if (NacChat._sttFlushTimer) { clearTimeout(NacChat._sttFlushTimer); NacChat._sttFlushTimer = null; }
560
601
  if (!text) return;
561
602
  if (_isBotEcho(text)) {
562
- console.log('[nac-chat-stt] dropping bot-echo:', text);
603
+ _dbg('[nac-chat-stt] dropping bot-echo:', text);
563
604
  return;
564
605
  }
565
606
  if ('speechSynthesis' in window && window.speechSynthesis.speaking) {
566
- console.log('[nac-chat-stt] dropping during TTS:', text);
607
+ _dbg('[nac-chat-stt] dropping during TTS:', text);
567
608
  return;
568
609
  }
569
610
  NacChat.send(text);