@apteva/apteva-kit 0.1.131 → 0.1.133

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/index.js CHANGED
@@ -4479,6 +4479,7 @@ function useVoiceSession(config) {
4479
4479
  const [state, setState] = _react.useState.call(void 0, "idle");
4480
4480
  const [partialTranscript, setPartialTranscript] = _react.useState.call(void 0, "");
4481
4481
  const [duration, setDuration] = _react.useState.call(void 0, 0);
4482
+ const [muted, setMuted] = _react.useState.call(void 0, false);
4482
4483
  const wsRef = _react.useRef.call(void 0, null);
4483
4484
  const captureCtxRef = _react.useRef.call(void 0, null);
4484
4485
  const playbackCtxRef = _react.useRef.call(void 0, null);
@@ -4487,6 +4488,7 @@ function useVoiceSession(config) {
4487
4488
  const nextPlayTimeRef = _react.useRef.call(void 0, 0);
4488
4489
  const durationIntervalRef = _react.useRef.call(void 0, null);
4489
4490
  const startTimeRef = _react.useRef.call(void 0, 0);
4491
+ const mutedRef = _react.useRef.call(void 0, false);
4490
4492
  const configRef = _react.useRef.call(void 0, config);
4491
4493
  configRef.current = config;
4492
4494
  const cleanup = _react.useCallback.call(void 0, () => {
@@ -4524,6 +4526,8 @@ function useVoiceSession(config) {
4524
4526
  wsRef.current = null;
4525
4527
  }
4526
4528
  nextPlayTimeRef.current = 0;
4529
+ mutedRef.current = false;
4530
+ setMuted(false);
4527
4531
  setPartialTranscript("");
4528
4532
  setDuration(0);
4529
4533
  }, []);
@@ -4551,6 +4555,8 @@ function useVoiceSession(config) {
4551
4555
  source.start(startTime);
4552
4556
  nextPlayTimeRef.current = startTime + audioBuffer.duration;
4553
4557
  }, []);
4558
+ const startCaptureRef = _react.useRef.call(void 0, () => {
4559
+ });
4554
4560
  const handleMessage = _react.useCallback.call(void 0, (msg) => {
4555
4561
  const cfg = configRef.current;
4556
4562
  switch (msg.type) {
@@ -4560,6 +4566,7 @@ function useVoiceSession(config) {
4560
4566
  durationIntervalRef.current = setInterval(() => {
4561
4567
  setDuration(Math.floor((Date.now() - startTimeRef.current) / 1e3));
4562
4568
  }, 1e3);
4569
+ startCaptureRef.current();
4563
4570
  break;
4564
4571
  case "audio_delta":
4565
4572
  if (_optionalChain([msg, 'access', _93 => _93.data, 'optionalAccess', _94 => _94.chunk])) {
@@ -4616,6 +4623,7 @@ function useVoiceSession(config) {
4616
4623
  processorRef.current = captureCtxRef.current.createScriptProcessor(2048, 1, 1);
4617
4624
  processorRef.current.onaudioprocess = (e) => {
4618
4625
  if (!ws || ws.readyState !== WebSocket.OPEN) return;
4626
+ if (mutedRef.current) return;
4619
4627
  const inputData = e.inputBuffer.getChannelData(0);
4620
4628
  const resampledData = resampleAudio(inputData, nativeSampleRate, 16e3);
4621
4629
  const int16Data = float32ToInt16(resampledData);
@@ -4628,16 +4636,24 @@ function useVoiceSession(config) {
4628
4636
  source.connect(processorRef.current);
4629
4637
  processorRef.current.connect(captureCtxRef.current.destination);
4630
4638
  } catch (e) {
4639
+ console.warn("Microphone access denied:", e);
4631
4640
  _optionalChain([configRef, 'access', _103 => _103.current, 'access', _104 => _104.onError, 'optionalCall', _105 => _105(new Error("Microphone access denied"))]);
4632
- cleanup();
4633
- setState("idle");
4634
4641
  }
4635
4642
  }, [cleanup]);
4643
+ startCaptureRef.current = startCapture;
4636
4644
  const start = _react.useCallback.call(void 0, () => {
4637
4645
  if (state !== "idle") return;
4638
4646
  setState("connecting");
4639
- const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
4640
- const wsUrl = `${protocol}//${window.location.host}${config.apiUrl}/voice`;
4647
+ let wsUrl;
4648
+ if (/^https?:\/\//.test(config.apiUrl)) {
4649
+ wsUrl = config.apiUrl.replace(/^http/, "ws") + "/voice";
4650
+ } else {
4651
+ const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
4652
+ wsUrl = `${protocol}//${window.location.host}${config.apiUrl}/voice`;
4653
+ }
4654
+ if (config.apiKey) {
4655
+ wsUrl += `${wsUrl.includes("?") ? "&" : "?"}token=${encodeURIComponent(config.apiKey)}`;
4656
+ }
4641
4657
  const ws = new WebSocket(wsUrl);
4642
4658
  wsRef.current = ws;
4643
4659
  ws.onopen = () => {
@@ -4647,7 +4663,6 @@ function useVoiceSession(config) {
4647
4663
  type: "start",
4648
4664
  data: { provider, voice }
4649
4665
  }));
4650
- startCapture();
4651
4666
  };
4652
4667
  ws.onmessage = (event) => {
4653
4668
  try {
@@ -4664,11 +4679,20 @@ function useVoiceSession(config) {
4664
4679
  cleanup();
4665
4680
  setState("idle");
4666
4681
  };
4667
- }, [state, config.apiUrl, startCapture, handleMessage, cleanup]);
4682
+ }, [state, config.apiUrl, handleMessage, cleanup]);
4668
4683
  const stop = _react.useCallback.call(void 0, () => {
4669
4684
  cleanup();
4670
4685
  setState("idle");
4671
4686
  }, [cleanup]);
4687
+ const toggleMute = _react.useCallback.call(void 0, () => {
4688
+ const next = !mutedRef.current;
4689
+ mutedRef.current = next;
4690
+ setMuted(next);
4691
+ if (mediaStreamRef.current) {
4692
+ const track = mediaStreamRef.current.getAudioTracks()[0];
4693
+ if (track) track.enabled = !next;
4694
+ }
4695
+ }, []);
4672
4696
  const sendText = _react.useCallback.call(void 0, (text) => {
4673
4697
  const ws = wsRef.current;
4674
4698
  if (!ws || ws.readyState !== WebSocket.OPEN) return;
@@ -4677,7 +4701,7 @@ function useVoiceSession(config) {
4677
4701
  data: { content: text }
4678
4702
  }));
4679
4703
  }, []);
4680
- return { state, partialTranscript, duration, start, stop, sendText };
4704
+ return { state, partialTranscript, duration, muted, start, stop, sendText, toggleMute };
4681
4705
  }
4682
4706
 
4683
4707
  // src/components/Chat/Chat.tsx
@@ -4768,6 +4792,7 @@ var Chat = _react.forwardRef.call(void 0, function Chat2({
4768
4792
  }, []);
4769
4793
  const voice = useVoiceSession({
4770
4794
  apiUrl: apiUrl || "",
4795
+ apiKey,
4771
4796
  provider: voiceProvider,
4772
4797
  voice: voiceId,
4773
4798
  onTranscript: handleVoiceTranscript,
@@ -5461,6 +5486,211 @@ ${planToExecute}`;
5461
5486
 
5462
5487
 
5463
5488
 
5489
+ // src/components/Call/Call.tsx
5490
+
5491
+
5492
+ // src/components/Call/CallStatus.tsx
5493
+
5494
+ function formatDuration(seconds) {
5495
+ const m = Math.floor(seconds / 60);
5496
+ const s = seconds % 60;
5497
+ return `${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`;
5498
+ }
5499
+ function CallStatus({ agentName = "Agent", agentAvatarUrl, state, duration }) {
5500
+ const initial = agentName.charAt(0).toUpperCase();
5501
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-call-agent", children: [
5502
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-call-avatar-wrap", children: [
5503
+ agentAvatarUrl ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: agentAvatarUrl, alt: agentName, className: "apteva-call-avatar" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-call-avatar-placeholder", children: initial }),
5504
+ state === "active" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-call-pulse-ring" })
5505
+ ] }),
5506
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-call-agent-name", children: agentName }),
5507
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: `apteva-call-status ${state === "active" ? "apteva-call-status-active" : state === "connecting" ? "apteva-call-status-connecting" : state === "error" ? "apteva-call-status-error" : ""}`, children: [
5508
+ state === "idle" && "Ready",
5509
+ state === "connecting" && "Connecting...",
5510
+ state === "active" && "Connected",
5511
+ state === "error" && "Error"
5512
+ ] }),
5513
+ (state === "active" || state === "connecting") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-call-duration", children: formatDuration(duration) })
5514
+ ] });
5515
+ }
5516
+
5517
+ // src/components/Call/CallTranscript.tsx
5518
+
5519
+
5520
+ function CallTranscript({ entries, partialTranscript }) {
5521
+ const scrollRef = _react.useRef.call(void 0, null);
5522
+ _react.useEffect.call(void 0, () => {
5523
+ if (scrollRef.current) {
5524
+ scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
5525
+ }
5526
+ }, [entries.length, partialTranscript]);
5527
+ if (entries.length === 0 && !partialTranscript) return null;
5528
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-call-transcript", ref: scrollRef, children: [
5529
+ entries.map((entry) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-call-transcript-entry", children: [
5530
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `apteva-call-transcript-role apteva-call-transcript-role-${entry.role}`, children: entry.role === "user" ? "You" : entry.role === "assistant" ? "Agent" : "System" }),
5531
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-call-transcript-content", children: entry.content })
5532
+ ] }, entry.id)),
5533
+ partialTranscript && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-call-transcript-entry", children: [
5534
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-call-transcript-role apteva-call-transcript-role-user", children: "You" }),
5535
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-call-transcript-partial", children: partialTranscript })
5536
+ ] })
5537
+ ] });
5538
+ }
5539
+
5540
+ // src/components/Call/CallControls.tsx
5541
+
5542
+ function CallControls({ state, muted, mediaMode, onStart, onEnd, onToggleMute }) {
5543
+ const isLive = state === "active" || state === "connecting";
5544
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-call-controls", children: isLive ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
5545
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5546
+ "button",
5547
+ {
5548
+ onClick: onToggleMute,
5549
+ className: `apteva-call-btn apteva-call-btn-mute ${muted ? "apteva-call-btn-mute-active" : ""}`,
5550
+ title: muted ? "Unmute" : "Mute",
5551
+ children: muted ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
5552
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "line", { x1: "1", y1: "1", x2: "23", y2: "23" }),
5553
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6" }),
5554
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M17 16.95A7 7 0 0 1 5 12v-2m14 0v2c0 .76-.13 1.49-.35 2.17" }),
5555
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
5556
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "line", { x1: "8", y1: "23", x2: "16", y2: "23" })
5557
+ ] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
5558
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" }),
5559
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
5560
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
5561
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "line", { x1: "8", y1: "23", x2: "16", y2: "23" })
5562
+ ] })
5563
+ }
5564
+ ),
5565
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5566
+ "button",
5567
+ {
5568
+ onClick: onEnd,
5569
+ className: "apteva-call-btn apteva-call-btn-end",
5570
+ title: "End call",
5571
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
5572
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91" }),
5573
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "line", { x1: "23", y1: "1", x2: "1", y2: "23" })
5574
+ ] })
5575
+ }
5576
+ )
5577
+ ] }) : (
5578
+ /* Start call button */
5579
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5580
+ "button",
5581
+ {
5582
+ onClick: onStart,
5583
+ className: "apteva-call-btn apteva-call-btn-start",
5584
+ title: "Start call",
5585
+ disabled: state === "error",
5586
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z" }) })
5587
+ }
5588
+ )
5589
+ ) });
5590
+ }
5591
+
5592
+ // src/components/Call/Call.tsx
5593
+
5594
+ function Call({
5595
+ agentName = "Agent",
5596
+ agentAvatarUrl,
5597
+ apiUrl,
5598
+ apiKey,
5599
+ voiceProvider,
5600
+ voiceId,
5601
+ mediaMode = "voice",
5602
+ autoStart = false,
5603
+ showTranscript = true,
5604
+ maxTranscriptEntries = 50,
5605
+ onCallStart,
5606
+ onCallEnd,
5607
+ onTranscript,
5608
+ onError,
5609
+ onMuteChange,
5610
+ variant = "default",
5611
+ theme,
5612
+ className
5613
+ }) {
5614
+ const [transcripts, setTranscripts] = _react.useState.call(void 0, []);
5615
+ const prevStateRef = _react.useRef.call(void 0, "idle");
5616
+ const durationRef = _react.useRef.call(void 0, 0);
5617
+ const autoStartedRef = _react.useRef.call(void 0, false);
5618
+ const handleTranscript = _react.useCallback.call(void 0, (entry) => {
5619
+ setTranscripts((prev) => {
5620
+ const next = [...prev, entry];
5621
+ return next.length > maxTranscriptEntries ? next.slice(next.length - maxTranscriptEntries) : next;
5622
+ });
5623
+ _optionalChain([onTranscript, 'optionalCall', _136 => _136(entry)]);
5624
+ }, [maxTranscriptEntries, onTranscript]);
5625
+ const voice = useVoiceSession({
5626
+ apiUrl,
5627
+ apiKey,
5628
+ provider: voiceProvider,
5629
+ voice: voiceId,
5630
+ onTranscript: handleTranscript,
5631
+ onError
5632
+ });
5633
+ _react.useEffect.call(void 0, () => {
5634
+ durationRef.current = voice.duration;
5635
+ }, [voice.duration]);
5636
+ _react.useEffect.call(void 0, () => {
5637
+ const prev = prevStateRef.current;
5638
+ if (prev !== "active" && voice.state === "active") {
5639
+ _optionalChain([onCallStart, 'optionalCall', _137 => _137()]);
5640
+ }
5641
+ if (prev === "active" && voice.state === "idle") {
5642
+ _optionalChain([onCallEnd, 'optionalCall', _138 => _138({ duration: durationRef.current, transcripts })]);
5643
+ }
5644
+ prevStateRef.current = voice.state;
5645
+ }, [voice.state, onCallStart, onCallEnd, transcripts]);
5646
+ _react.useEffect.call(void 0, () => {
5647
+ if (autoStart && !autoStartedRef.current && voice.state === "idle") {
5648
+ autoStartedRef.current = true;
5649
+ voice.start();
5650
+ }
5651
+ }, [autoStart, voice.state, voice.start]);
5652
+ _react.useEffect.call(void 0, () => {
5653
+ _optionalChain([onMuteChange, 'optionalCall', _139 => _139(voice.muted)]);
5654
+ }, [voice.muted, onMuteChange]);
5655
+ const cn2 = [
5656
+ "apteva-call",
5657
+ variant !== "default" && `apteva-call-${variant}`,
5658
+ theme === "dark" && "apteva-force-dark",
5659
+ theme === "light" && "apteva-force-light",
5660
+ className
5661
+ ].filter(Boolean).join(" ");
5662
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cn2, children: [
5663
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5664
+ CallStatus,
5665
+ {
5666
+ agentName,
5667
+ agentAvatarUrl,
5668
+ state: voice.state,
5669
+ duration: voice.duration
5670
+ }
5671
+ ),
5672
+ mediaMode === "video" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-call-video-area", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", opacity: "0.4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14" }) }) }),
5673
+ showTranscript && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5674
+ CallTranscript,
5675
+ {
5676
+ entries: transcripts,
5677
+ partialTranscript: voice.partialTranscript
5678
+ }
5679
+ ),
5680
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5681
+ CallControls,
5682
+ {
5683
+ state: voice.state,
5684
+ muted: voice.muted,
5685
+ mediaMode,
5686
+ onStart: voice.start,
5687
+ onEnd: voice.stop,
5688
+ onToggleMute: voice.toggleMute
5689
+ }
5690
+ )
5691
+ ] });
5692
+ }
5693
+
5464
5694
  // src/components/Command/Command.tsx
5465
5695
 
5466
5696
 
@@ -5596,13 +5826,13 @@ ${planningInstruction}` : planningInstruction;
5596
5826
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
5597
5827
  setError(error2);
5598
5828
  setState("error");
5599
- _optionalChain([onError, 'optionalCall', _136 => _136(error2)]);
5829
+ _optionalChain([onError, 'optionalCall', _140 => _140(error2)]);
5600
5830
  });
5601
5831
  } catch (err) {
5602
5832
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
5603
5833
  setError(error2);
5604
5834
  setState("error");
5605
- _optionalChain([onError, 'optionalCall', _137 => _137(error2)]);
5835
+ _optionalChain([onError, 'optionalCall', _141 => _141(error2)]);
5606
5836
  }
5607
5837
  }
5608
5838
  return;
@@ -5613,7 +5843,7 @@ ${planningInstruction}` : planningInstruction;
5613
5843
  setStreamedContent("");
5614
5844
  setCommand("");
5615
5845
  setUploadedFiles([]);
5616
- _optionalChain([onStart, 'optionalCall', _138 => _138()]);
5846
+ _optionalChain([onStart, 'optionalCall', _142 => _142()]);
5617
5847
  try {
5618
5848
  if (useMock) {
5619
5849
  if (enableStreaming) {
@@ -5624,16 +5854,16 @@ ${planningInstruction}` : planningInstruction;
5624
5854
  if (chunk.type === "token" && chunk.content) {
5625
5855
  accumulatedContent += chunk.content;
5626
5856
  setStreamedContent(accumulatedContent);
5627
- _optionalChain([onChunk, 'optionalCall', _139 => _139(chunk.content)]);
5857
+ _optionalChain([onChunk, 'optionalCall', _143 => _143(chunk.content)]);
5628
5858
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
5629
5859
  setProgress(estimatedProgress);
5630
- _optionalChain([onProgress, 'optionalCall', _140 => _140(estimatedProgress)]);
5860
+ _optionalChain([onProgress, 'optionalCall', _144 => _144(estimatedProgress)]);
5631
5861
  } else if (chunk.type === "widget" && chunk.widget) {
5632
5862
  const widget = chunk.widget;
5633
5863
  setResult((prev) => ({
5634
5864
  success: true,
5635
- data: _optionalChain([prev, 'optionalAccess', _141 => _141.data]) || {},
5636
- widgets: [..._optionalChain([prev, 'optionalAccess', _142 => _142.widgets]) || [], widget],
5865
+ data: _optionalChain([prev, 'optionalAccess', _145 => _145.data]) || {},
5866
+ widgets: [..._optionalChain([prev, 'optionalAccess', _146 => _146.widgets]) || [], widget],
5637
5867
  message: accumulatedContent || "Command executed successfully"
5638
5868
  }));
5639
5869
  }
@@ -5653,19 +5883,19 @@ ${planningInstruction}` : planningInstruction;
5653
5883
  setResult(result2);
5654
5884
  setState("success");
5655
5885
  setProgress(100);
5656
- _optionalChain([onComplete, 'optionalCall', _143 => _143(result2)]);
5886
+ _optionalChain([onComplete, 'optionalCall', _147 => _147(result2)]);
5657
5887
  },
5658
5888
  (error2) => {
5659
5889
  setError(error2);
5660
5890
  setState("error");
5661
- _optionalChain([onError, 'optionalCall', _144 => _144(error2)]);
5891
+ _optionalChain([onError, 'optionalCall', _148 => _148(error2)]);
5662
5892
  }
5663
5893
  );
5664
5894
  } else {
5665
5895
  const progressInterval = setInterval(() => {
5666
5896
  setProgress((prev) => {
5667
5897
  const next = Math.min(prev + 10, 90);
5668
- _optionalChain([onProgress, 'optionalCall', _145 => _145(next)]);
5898
+ _optionalChain([onProgress, 'optionalCall', _149 => _149(next)]);
5669
5899
  return next;
5670
5900
  });
5671
5901
  }, 200);
@@ -5689,7 +5919,7 @@ ${planningInstruction}` : planningInstruction;
5689
5919
  setResult(result2);
5690
5920
  setState("success");
5691
5921
  setProgress(100);
5692
- _optionalChain([onComplete, 'optionalCall', _146 => _146(result2)]);
5922
+ _optionalChain([onComplete, 'optionalCall', _150 => _150(result2)]);
5693
5923
  }
5694
5924
  } else {
5695
5925
  if (enableStreaming) {
@@ -5735,16 +5965,16 @@ ${commandInstruction}` : commandInstruction;
5735
5965
  if (chunk.type === "token" && chunk.content) {
5736
5966
  accumulatedContent += chunk.content;
5737
5967
  setStreamedContent(accumulatedContent);
5738
- _optionalChain([onChunk, 'optionalCall', _147 => _147(chunk.content)]);
5968
+ _optionalChain([onChunk, 'optionalCall', _151 => _151(chunk.content)]);
5739
5969
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
5740
5970
  setProgress(estimatedProgress);
5741
- _optionalChain([onProgress, 'optionalCall', _148 => _148(estimatedProgress)]);
5971
+ _optionalChain([onProgress, 'optionalCall', _152 => _152(estimatedProgress)]);
5742
5972
  } else if (chunk.type === "widget" && chunk.widget) {
5743
5973
  const widget = chunk.widget;
5744
5974
  setResult((prev) => ({
5745
5975
  success: true,
5746
- data: _optionalChain([prev, 'optionalAccess', _149 => _149.data]) || {},
5747
- widgets: [..._optionalChain([prev, 'optionalAccess', _150 => _150.widgets]) || [], widget],
5976
+ data: _optionalChain([prev, 'optionalAccess', _153 => _153.data]) || {},
5977
+ widgets: [..._optionalChain([prev, 'optionalAccess', _154 => _154.widgets]) || [], widget],
5748
5978
  message: accumulatedContent || "Command executed successfully"
5749
5979
  }));
5750
5980
  }
@@ -5764,20 +5994,20 @@ ${commandInstruction}` : commandInstruction;
5764
5994
  setResult(result2);
5765
5995
  setState("success");
5766
5996
  setProgress(100);
5767
- _optionalChain([onComplete, 'optionalCall', _151 => _151(result2)]);
5997
+ _optionalChain([onComplete, 'optionalCall', _155 => _155(result2)]);
5768
5998
  },
5769
5999
  (error2) => {
5770
6000
  const err = error2 instanceof Error ? error2 : new Error("Unknown error");
5771
6001
  setError(err);
5772
6002
  setState("error");
5773
- _optionalChain([onError, 'optionalCall', _152 => _152(err)]);
6003
+ _optionalChain([onError, 'optionalCall', _156 => _156(err)]);
5774
6004
  }
5775
6005
  );
5776
6006
  } else {
5777
6007
  const progressInterval = setInterval(() => {
5778
6008
  setProgress((prev) => {
5779
6009
  const next = Math.min(prev + 10, 90);
5780
- _optionalChain([onProgress, 'optionalCall', _153 => _153(next)]);
6010
+ _optionalChain([onProgress, 'optionalCall', _157 => _157(next)]);
5781
6011
  return next;
5782
6012
  });
5783
6013
  }, 200);
@@ -5833,14 +6063,14 @@ ${commandInstruction}` : commandInstruction;
5833
6063
  setResult(result2);
5834
6064
  setState("success");
5835
6065
  setProgress(100);
5836
- _optionalChain([onComplete, 'optionalCall', _154 => _154(result2)]);
6066
+ _optionalChain([onComplete, 'optionalCall', _158 => _158(result2)]);
5837
6067
  }
5838
6068
  }
5839
6069
  } catch (err) {
5840
6070
  const error2 = err instanceof Error ? err : new Error("Unknown error");
5841
6071
  setError(error2);
5842
6072
  setState("error");
5843
- _optionalChain([onError, 'optionalCall', _155 => _155(error2)]);
6073
+ _optionalChain([onError, 'optionalCall', _159 => _159(error2)]);
5844
6074
  }
5845
6075
  };
5846
6076
  const resetCommand = () => {
@@ -5873,14 +6103,14 @@ ${planToExecute}`;
5873
6103
  };
5874
6104
  const handleFileSelect = async (e) => {
5875
6105
  if (e.target.files && e.target.files.length > 0) {
5876
- _optionalChain([onFileUpload, 'optionalCall', _156 => _156(e.target.files)]);
6106
+ _optionalChain([onFileUpload, 'optionalCall', _160 => _160(e.target.files)]);
5877
6107
  const files = [];
5878
6108
  for (let i = 0; i < e.target.files.length; i++) {
5879
6109
  const file = e.target.files[i];
5880
6110
  const reader = new FileReader();
5881
6111
  await new Promise((resolve) => {
5882
6112
  reader.onload = (event) => {
5883
- if (_optionalChain([event, 'access', _157 => _157.target, 'optionalAccess', _158 => _158.result])) {
6113
+ if (_optionalChain([event, 'access', _161 => _161.target, 'optionalAccess', _162 => _162.result])) {
5884
6114
  const fullDataUrl = event.target.result;
5885
6115
  const base64Data = fullDataUrl.split(",")[1];
5886
6116
  if (file.type.startsWith("image/")) {
@@ -5974,7 +6204,7 @@ ${planToExecute}`;
5974
6204
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5975
6205
  "button",
5976
6206
  {
5977
- onClick: () => _optionalChain([fileInputRef, 'access', _159 => _159.current, 'optionalAccess', _160 => _160.click, 'call', _161 => _161()]),
6207
+ onClick: () => _optionalChain([fileInputRef, 'access', _163 => _163.current, 'optionalAccess', _164 => _164.click, 'call', _165 => _165()]),
5978
6208
  className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
5979
6209
  title: "Attach file",
5980
6210
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M8.4 2.8L4.4 6.8C3.736 7.464 3.736 8.536 4.4 9.2C5.064 9.864 6.136 9.864 6.8 9.2L11.6 4.4C12.704 3.296 12.704 1.504 11.6 0.4C10.496 -0.704 8.704 -0.704 7.6 0.4L2.8 5.2C1.256 6.744 1.256 9.256 2.8 10.8C4.344 12.344 6.856 12.344 8.4 10.8L12.4 6.8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(1.6, 2.4)" }) })
@@ -6193,7 +6423,7 @@ ${planToExecute}`;
6193
6423
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-5 h-5 text-red-600 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
6194
6424
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
6195
6425
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
6196
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _162 => _162.message]) })
6426
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _166 => _166.message]) })
6197
6427
  ] })
6198
6428
  ] }) }),
6199
6429
  allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -6221,7 +6451,7 @@ ${planToExecute}`;
6221
6451
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
6222
6452
  ] })
6223
6453
  ] }),
6224
- _optionalChain([result, 'access', _163 => _163.data, 'optionalAccess', _164 => _164.summary]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
6454
+ _optionalChain([result, 'access', _167 => _167.data, 'optionalAccess', _168 => _168.summary]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
6225
6455
  result.widgets && result.widgets.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-3", children: result.widgets.map((widget) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6226
6456
  WidgetRenderer,
6227
6457
  {
@@ -6272,7 +6502,7 @@ ${planToExecute}`;
6272
6502
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6273
6503
  "button",
6274
6504
  {
6275
- onClick: () => _optionalChain([fileInputRef, 'access', _165 => _165.current, 'optionalAccess', _166 => _166.click, 'call', _167 => _167()]),
6505
+ onClick: () => _optionalChain([fileInputRef, 'access', _169 => _169.current, 'optionalAccess', _170 => _170.click, 'call', _171 => _171()]),
6276
6506
  className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
6277
6507
  title: "Attach file",
6278
6508
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M8.4 2.8L4.4 6.8C3.736 7.464 3.736 8.536 4.4 9.2C5.064 9.864 6.136 9.864 6.8 9.2L11.6 4.4C12.704 3.296 12.704 1.504 11.6 0.4C10.496 -0.704 8.704 -0.704 7.6 0.4L2.8 5.2C1.256 6.744 1.256 9.256 2.8 10.8C4.344 12.344 6.856 12.344 8.4 10.8L12.4 6.8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(1.6, 2.4)" }) })
@@ -6458,25 +6688,25 @@ function Prompt({
6458
6688
  const newValue = e.target.value;
6459
6689
  if (!maxLength || newValue.length <= maxLength) {
6460
6690
  setValue(newValue);
6461
- _optionalChain([onChange, 'optionalCall', _168 => _168(newValue)]);
6691
+ _optionalChain([onChange, 'optionalCall', _172 => _172(newValue)]);
6462
6692
  }
6463
6693
  };
6464
6694
  const handleSubmit = async () => {
6465
6695
  if (value.length < minLength) return;
6466
- _optionalChain([onSubmit, 'optionalCall', _169 => _169(value)]);
6696
+ _optionalChain([onSubmit, 'optionalCall', _173 => _173(value)]);
6467
6697
  setIsLoading(true);
6468
6698
  try {
6469
6699
  if (useMock) {
6470
6700
  await new Promise((resolve) => setTimeout(resolve, 1500));
6471
6701
  const mockResult = `Enhanced version: ${value} [AI-generated content]`;
6472
- _optionalChain([onResult, 'optionalCall', _170 => _170(mockResult)]);
6702
+ _optionalChain([onResult, 'optionalCall', _174 => _174(mockResult)]);
6473
6703
  setValue("");
6474
6704
  } else {
6475
6705
  const response = await aptevaClient.chat({
6476
6706
  agent_id: agentId,
6477
6707
  message: value
6478
6708
  });
6479
- _optionalChain([onResult, 'optionalCall', _171 => _171(response.message)]);
6709
+ _optionalChain([onResult, 'optionalCall', _175 => _175(response.message)]);
6480
6710
  setValue("");
6481
6711
  }
6482
6712
  } catch (error) {
@@ -6571,7 +6801,7 @@ function Stream({
6571
6801
  }, [autoStart]);
6572
6802
  const startStreaming = async () => {
6573
6803
  setIsStreaming(true);
6574
- _optionalChain([onStart, 'optionalCall', _172 => _172()]);
6804
+ _optionalChain([onStart, 'optionalCall', _176 => _176()]);
6575
6805
  try {
6576
6806
  if (useMock) {
6577
6807
  const mockText = "This is a simulated streaming response from the AI agent. In a real implementation, this would stream data from your backend API. The text appears word by word to simulate the streaming effect. You can customize the typing speed and styling based on your needs.";
@@ -6579,13 +6809,13 @@ function Stream({
6579
6809
  mockText,
6580
6810
  (chunk) => {
6581
6811
  setText((prev) => prev + chunk);
6582
- _optionalChain([onChunk, 'optionalCall', _173 => _173(chunk)]);
6812
+ _optionalChain([onChunk, 'optionalCall', _177 => _177(chunk)]);
6583
6813
  },
6584
6814
  typingSpeed
6585
6815
  );
6586
6816
  setIsComplete(true);
6587
6817
  setIsStreaming(false);
6588
- _optionalChain([onComplete, 'optionalCall', _174 => _174(text + mockText)]);
6818
+ _optionalChain([onComplete, 'optionalCall', _178 => _178(text + mockText)]);
6589
6819
  } else {
6590
6820
  let accumulatedText = "";
6591
6821
  await aptevaClient.chatStream(
@@ -6598,24 +6828,24 @@ function Stream({
6598
6828
  if (chunk.type === "token" && chunk.content) {
6599
6829
  accumulatedText += chunk.content;
6600
6830
  setText(accumulatedText);
6601
- _optionalChain([onChunk, 'optionalCall', _175 => _175(chunk.content)]);
6831
+ _optionalChain([onChunk, 'optionalCall', _179 => _179(chunk.content)]);
6602
6832
  }
6603
6833
  },
6604
6834
  () => {
6605
6835
  setIsComplete(true);
6606
6836
  setIsStreaming(false);
6607
- _optionalChain([onComplete, 'optionalCall', _176 => _176(accumulatedText)]);
6837
+ _optionalChain([onComplete, 'optionalCall', _180 => _180(accumulatedText)]);
6608
6838
  },
6609
6839
  (error) => {
6610
6840
  const err = error instanceof Error ? error : new Error("Streaming error");
6611
- _optionalChain([onError, 'optionalCall', _177 => _177(err)]);
6841
+ _optionalChain([onError, 'optionalCall', _181 => _181(err)]);
6612
6842
  setIsStreaming(false);
6613
6843
  }
6614
6844
  );
6615
6845
  }
6616
6846
  } catch (error) {
6617
6847
  const err = error instanceof Error ? error : new Error("Streaming error");
6618
- _optionalChain([onError, 'optionalCall', _178 => _178(err)]);
6848
+ _optionalChain([onError, 'optionalCall', _182 => _182(err)]);
6619
6849
  setIsStreaming(false);
6620
6850
  }
6621
6851
  };
@@ -6707,7 +6937,7 @@ function ThreadList({
6707
6937
  }) {
6708
6938
  const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
6709
6939
  const filteredThreads = threads.filter(
6710
- (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _179 => _179.preview, 'optionalAccess', _180 => _180.toLowerCase, 'call', _181 => _181(), 'access', _182 => _182.includes, 'call', _183 => _183(searchQuery.toLowerCase())])
6940
+ (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _183 => _183.preview, 'optionalAccess', _184 => _184.toLowerCase, 'call', _185 => _185(), 'access', _186 => _186.includes, 'call', _187 => _187(searchQuery.toLowerCase())])
6711
6941
  );
6712
6942
  const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
6713
6943
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
@@ -6729,8 +6959,8 @@ function ThreadList({
6729
6959
  {
6730
6960
  thread,
6731
6961
  isActive: thread.id === currentThreadId,
6732
- onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _184 => _184(thread.id)]),
6733
- onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _185 => _185(thread.id)])
6962
+ onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _188 => _188(thread.id)]),
6963
+ onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _189 => _189(thread.id)])
6734
6964
  },
6735
6965
  thread.id
6736
6966
  ))
@@ -6792,7 +7022,7 @@ function Threads({
6792
7022
  threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6793
7023
  "button",
6794
7024
  {
6795
- onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _186 => _186(thread.id)]),
7025
+ onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _190 => _190(thread.id)]),
6796
7026
  className: cn(
6797
7027
  "px-4 py-2 whitespace-nowrap font-medium transition-colors",
6798
7028
  thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"
@@ -6977,7 +7207,7 @@ function TabsLayout({ node, renderNode }) {
6977
7207
  var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
6978
7208
  function normalizeNode(n) {
6979
7209
  let node = { ...n };
6980
- if (node.type === "widget" && _optionalChain([node, 'access', _187 => _187.props, 'optionalAccess', _188 => _188.widget])) {
7210
+ if (node.type === "widget" && _optionalChain([node, 'access', _191 => _191.props, 'optionalAccess', _192 => _192.widget])) {
6981
7211
  node.type = node.props.widget;
6982
7212
  const { widget: _, ...rest } = node.props;
6983
7213
  node.props = rest;
@@ -7115,10 +7345,10 @@ function AutoInterface({
7115
7345
  ].filter(Boolean).join("\n\n");
7116
7346
  const updateInterface = _react.useCallback.call(void 0, (newSpec) => {
7117
7347
  setInterfaceSpec(newSpec);
7118
- _optionalChain([onInterfaceChange, 'optionalCall', _189 => _189(newSpec)]);
7348
+ _optionalChain([onInterfaceChange, 'optionalCall', _193 => _193(newSpec)]);
7119
7349
  }, [onInterfaceChange]);
7120
7350
  const handleAction = _react.useCallback.call(void 0, (action) => {
7121
- _optionalChain([onAction, 'optionalCall', _190 => _190(action)]);
7351
+ _optionalChain([onAction, 'optionalCall', _194 => _194(action)]);
7122
7352
  if (chatRef.current) {
7123
7353
  chatRef.current.sendMessage(
7124
7354
  `[Action: ${action.type} on widget ${action.widgetId || "unknown"}. Payload: ${JSON.stringify(action.payload)}]`
@@ -7126,7 +7356,7 @@ function AutoInterface({
7126
7356
  }
7127
7357
  }, [onAction]);
7128
7358
  const handleMessageComplete = _react.useCallback.call(void 0, (result) => {
7129
- if (!_optionalChain([result, 'optionalAccess', _191 => _191.data])) return;
7359
+ if (!_optionalChain([result, 'optionalAccess', _195 => _195.data])) return;
7130
7360
  const text = typeof result.data === "string" ? result.data : result.data.message || "";
7131
7361
  console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
7132
7362
  const parsed = parseInterfaceFromText(text);
@@ -7166,7 +7396,7 @@ function AutoInterface({
7166
7396
  }).catch((err) => {
7167
7397
  if (cancelled) return;
7168
7398
  console.error("[AutoInterface] Initial generation failed:", err);
7169
- _optionalChain([onError, 'optionalCall', _192 => _192(err instanceof Error ? err : new Error(String(err)))]);
7399
+ _optionalChain([onError, 'optionalCall', _196 => _196(err instanceof Error ? err : new Error(String(err)))]);
7170
7400
  setIsGenerating(false);
7171
7401
  });
7172
7402
  return () => {
@@ -7332,7 +7562,7 @@ function useInterfaceAI({
7332
7562
  }
7333
7563
  const sendMessage = _react.useCallback.call(void 0, async (message) => {
7334
7564
  accumulatedTextRef.current = "";
7335
- _optionalChain([onStreamStart, 'optionalCall', _193 => _193()]);
7565
+ _optionalChain([onStreamStart, 'optionalCall', _197 => _197()]);
7336
7566
  const systemPrompt = [
7337
7567
  generateInterfaceContext(),
7338
7568
  context || ""
@@ -7355,27 +7585,27 @@ function useInterfaceAI({
7355
7585
  accumulatedTextRef.current += chunk.content || "";
7356
7586
  const parsed = parseInterfaceFromText(accumulatedTextRef.current);
7357
7587
  if (parsed) {
7358
- _optionalChain([onInterface, 'optionalCall', _194 => _194(parsed)]);
7588
+ _optionalChain([onInterface, 'optionalCall', _198 => _198(parsed)]);
7359
7589
  }
7360
7590
  const updates = parseUpdatesFromText(accumulatedTextRef.current);
7361
7591
  if (updates.length > 0) {
7362
- _optionalChain([onUpdates, 'optionalCall', _195 => _195(updates)]);
7592
+ _optionalChain([onUpdates, 'optionalCall', _199 => _199(updates)]);
7363
7593
  }
7364
7594
  }
7365
7595
  },
7366
7596
  // onComplete
7367
7597
  () => {
7368
- _optionalChain([onStreamEnd, 'optionalCall', _196 => _196()]);
7598
+ _optionalChain([onStreamEnd, 'optionalCall', _200 => _200()]);
7369
7599
  },
7370
7600
  // onError
7371
7601
  (error) => {
7372
- _optionalChain([onError, 'optionalCall', _197 => _197(error)]);
7373
- _optionalChain([onStreamEnd, 'optionalCall', _198 => _198()]);
7602
+ _optionalChain([onError, 'optionalCall', _201 => _201(error)]);
7603
+ _optionalChain([onStreamEnd, 'optionalCall', _202 => _202()]);
7374
7604
  }
7375
7605
  );
7376
7606
  } catch (error) {
7377
- _optionalChain([onError, 'optionalCall', _199 => _199(error instanceof Error ? error : new Error("Unknown error"))]);
7378
- _optionalChain([onStreamEnd, 'optionalCall', _200 => _200()]);
7607
+ _optionalChain([onError, 'optionalCall', _203 => _203(error instanceof Error ? error : new Error("Unknown error"))]);
7608
+ _optionalChain([onStreamEnd, 'optionalCall', _204 => _204()]);
7379
7609
  }
7380
7610
  }, [agentId, context, onInterface, onUpdates, onError, onStreamStart, onStreamEnd]);
7381
7611
  return {
@@ -7421,5 +7651,6 @@ function useInterfaceAI({
7421
7651
 
7422
7652
 
7423
7653
 
7424
- exports.AptevaClient = AptevaClient; exports.AutoInterface = AutoInterface; exports.Button = Button; exports.Card = Card; exports.Chat = Chat; exports.Command = Command; exports.InterfaceRenderer = InterfaceRenderer; exports.InterfaceSkeleton = InterfaceSkeleton; exports.Kpi = Kpi; exports.LayoutRenderer = LayoutRenderer; exports.List = List; exports.LiveView = LiveView; exports.PersistentWidgetPanel = PersistentWidgetPanel; exports.Prompt = Prompt; exports.Spacer = Spacer; exports.Stream = Stream; exports.TextBlock = TextBlock; exports.Threads = Threads; exports.Widgets = Widgets; exports.applyUpdate = applyUpdate; exports.applyUpdates = applyUpdates; exports.aptevaClient = aptevaClient; exports.cn = cn; exports.containsInterface = containsInterface; exports.convertApiMessages = convertApiMessages; exports.findNode = findNode; exports.generateCompactInterfaceContext = generateCompactInterfaceContext; exports.generateInterfaceContext = generateInterfaceContext; exports.getThemeScript = getThemeScript; exports.mockMessages = mockMessages; exports.mockThreads = mockThreads; exports.mockWidgets = mockWidgets; exports.parseInterfaceFromText = parseInterfaceFromText; exports.parseUpdatesFromText = parseUpdatesFromText; exports.stripInterface = stripInterface; exports.useInterfaceAI = useInterfaceAI; exports.useInterfaceState = useInterfaceState;
7654
+
7655
+ exports.AptevaClient = AptevaClient; exports.AutoInterface = AutoInterface; exports.Button = Button; exports.Call = Call; exports.Card = Card; exports.Chat = Chat; exports.Command = Command; exports.InterfaceRenderer = InterfaceRenderer; exports.InterfaceSkeleton = InterfaceSkeleton; exports.Kpi = Kpi; exports.LayoutRenderer = LayoutRenderer; exports.List = List; exports.LiveView = LiveView; exports.PersistentWidgetPanel = PersistentWidgetPanel; exports.Prompt = Prompt; exports.Spacer = Spacer; exports.Stream = Stream; exports.TextBlock = TextBlock; exports.Threads = Threads; exports.Widgets = Widgets; exports.applyUpdate = applyUpdate; exports.applyUpdates = applyUpdates; exports.aptevaClient = aptevaClient; exports.cn = cn; exports.containsInterface = containsInterface; exports.convertApiMessages = convertApiMessages; exports.findNode = findNode; exports.generateCompactInterfaceContext = generateCompactInterfaceContext; exports.generateInterfaceContext = generateInterfaceContext; exports.getThemeScript = getThemeScript; exports.mockMessages = mockMessages; exports.mockThreads = mockThreads; exports.mockWidgets = mockWidgets; exports.parseInterfaceFromText = parseInterfaceFromText; exports.parseUpdatesFromText = parseUpdatesFromText; exports.stripInterface = stripInterface; exports.useInterfaceAI = useInterfaceAI; exports.useInterfaceState = useInterfaceState;
7425
7656
  //# sourceMappingURL=index.js.map