@syntrologie/adapt-chatbot 2.57.1 → 2.58.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.
package/dist/runtime.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  decodeMutationEnvelope,
6
6
  fetchMountedElements,
7
7
  renderFallbackHtml
8
- } from "./chunk-AIQMQZBV.js";
8
+ } from "./chunk-HD2NXGYO.js";
9
9
  import {
10
10
  ElementInstanceStore,
11
11
  TileHandler,
@@ -14,13 +14,13 @@ import {
14
14
  } from "./chunk-VIRIVP7H.js";
15
15
  import {
16
16
  pickPersona
17
- } from "./chunk-XPUHW2YO.js";
17
+ } from "./chunk-T6VEDUXD.js";
18
18
  import {
19
19
  getElementInstanceStore,
20
20
  setElementInstanceStore
21
21
  } from "./chunk-EWPPVPJ4.js";
22
- import "./chunk-LFJ54PIF.js";
23
- import "./chunk-GN7Z5IVP.js";
22
+ import "./chunk-UFTSEIQP.js";
23
+ import "./chunk-YFZCMLV6.js";
24
24
  import "./chunk-HV52LYST.js";
25
25
  import {
26
26
  DIVE_DEEPER_EVENT,
@@ -3152,6 +3152,14 @@ function getState(container) {
3152
3152
  function setState(container, state) {
3153
3153
  container[STATE_KEY] = state;
3154
3154
  }
3155
+ function transcriptMessages(transcript) {
3156
+ return transcript.map((m, i) => ({
3157
+ id: `transcript-${i}`,
3158
+ role: m.role,
3159
+ text: m.text,
3160
+ status: "complete"
3161
+ }));
3162
+ }
3155
3163
  function applyPlaceholder(bar, cfg2) {
3156
3164
  if (cfg2.placeholder !== void 0) bar.placeholder = cfg2.placeholder;
3157
3165
  if (cfg2.assistantName !== void 0) bar.assistantName = cfg2.assistantName;
@@ -3331,6 +3339,19 @@ function wireListeners(bar, state) {
3331
3339
  var AdaptiveChatBarMountable = {
3332
3340
  mount(container, mountConfig) {
3333
3341
  const cfg2 = mountConfig ?? {};
3342
+ if (cfg2.transcript?.length) {
3343
+ const bar2 = document.createElement("adaptive-chat-bar");
3344
+ applyPlaceholder(bar2, cfg2);
3345
+ bar2.readOnly = true;
3346
+ bar2.messages = transcriptMessages(cfg2.transcript);
3347
+ container.appendChild(bar2);
3348
+ const cleanup = () => {
3349
+ bar2.remove();
3350
+ setState(container, null);
3351
+ };
3352
+ setState(container, { bar: bar2, cleanup, cfg: cfg2 });
3353
+ return cleanup;
3354
+ }
3334
3355
  configureTransportIfPossible(cfg2);
3335
3356
  const bridge = bootSupportChat(cfg2.supportChat);
3336
3357
  if (bridge && !isSupportChatInboxWired()) {
@@ -3402,6 +3423,19 @@ var AdaptiveChatBarMountable = {
3402
3423
  const state = getState(container);
3403
3424
  if (!state) return;
3404
3425
  const cfg2 = mountConfig ?? {};
3426
+ const wasTranscript = Boolean(state.cfg.transcript?.length);
3427
+ const isTranscript = Boolean(cfg2.transcript?.length);
3428
+ if (wasTranscript !== isTranscript) {
3429
+ throw new Error(
3430
+ "adaptive-chatbot:chat-bar cannot switch between a read-only transcript and a live chat in update(); unmount and mount again."
3431
+ );
3432
+ }
3433
+ if (isTranscript && cfg2.transcript) {
3434
+ applyPlaceholder(state.bar, cfg2);
3435
+ state.bar.messages = transcriptMessages(cfg2.transcript);
3436
+ state.cfg = cfg2;
3437
+ return;
3438
+ }
3405
3439
  configureTransportIfPossible(cfg2);
3406
3440
  applyPlaceholder(state.bar, cfg2);
3407
3441
  state.cfg = cfg2;