@apteva/apteva-kit 0.1.112 → 0.1.114

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
@@ -3338,7 +3338,11 @@ function MessageList({
3338
3338
  // src/components/Chat/Composer.tsx
3339
3339
 
3340
3340
 
3341
- function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, isLoading = false, onStop, onFileUpload, onSwitchMode }) {
3341
+ var getSpeechRecognition = () => {
3342
+ if (typeof window === "undefined") return null;
3343
+ return window.SpeechRecognition || window.webkitSpeechRecognition || null;
3344
+ };
3345
+ function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, isLoading = false, onStop, onFileUpload, onSwitchMode, speechToText }) {
3342
3346
  const [text, setText] = _react.useState.call(void 0, "");
3343
3347
  const [showMenu, setShowMenu] = _react.useState.call(void 0, false);
3344
3348
  const [pendingFiles, setPendingFiles] = _react.useState.call(void 0, []);
@@ -3347,6 +3351,190 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
3347
3351
  const textareaRef = _react.useRef.call(void 0, null);
3348
3352
  const fileInputRef = _react.useRef.call(void 0, null);
3349
3353
  const menuButtonRef = _react.useRef.call(void 0, null);
3354
+ const [isRecording, setIsRecording] = _react.useState.call(void 0, false);
3355
+ const [recordingTime, setRecordingTime] = _react.useState.call(void 0, 0);
3356
+ const [transcriptFlash, setTranscriptFlash] = _react.useState.call(void 0, null);
3357
+ const recognitionRef = _react.useRef.call(void 0, null);
3358
+ const mediaStreamRef = _react.useRef.call(void 0, null);
3359
+ const audioContextRef = _react.useRef.call(void 0, null);
3360
+ const analyserRef = _react.useRef.call(void 0, null);
3361
+ const canvasRef = _react.useRef.call(void 0, null);
3362
+ const animFrameRef = _react.useRef.call(void 0, 0);
3363
+ const silenceTimerRef = _react.useRef.call(void 0, null);
3364
+ const recordingTimerRef = _react.useRef.call(void 0, null);
3365
+ const finalTranscriptRef = _react.useRef.call(void 0, "");
3366
+ const manualStopRef = _react.useRef.call(void 0, false);
3367
+ const sttConfig = speechToText ? typeof speechToText === "object" ? speechToText : {} : null;
3368
+ const sttSupported = !!sttConfig && !!getSpeechRecognition();
3369
+ const silenceTimeout = _nullishCoalesce(_optionalChain([sttConfig, 'optionalAccess', _54 => _54.silenceTimeout]), () => ( 2e3));
3370
+ const autoSend = _optionalChain([sttConfig, 'optionalAccess', _55 => _55.autoSend]) !== false;
3371
+ _react.useEffect.call(void 0, () => {
3372
+ return () => {
3373
+ stopRecording(true);
3374
+ };
3375
+ }, []);
3376
+ const drawWaveform = _react.useCallback.call(void 0, () => {
3377
+ const canvas = canvasRef.current;
3378
+ const analyser = analyserRef.current;
3379
+ if (!canvas || !analyser) return;
3380
+ const ctx = canvas.getContext("2d");
3381
+ if (!ctx) return;
3382
+ const bufferLength = analyser.frequencyBinCount;
3383
+ const dataArray = new Uint8Array(bufferLength);
3384
+ const draw = () => {
3385
+ animFrameRef.current = requestAnimationFrame(draw);
3386
+ analyser.getByteTimeDomainData(dataArray);
3387
+ const { width, height } = canvas;
3388
+ ctx.clearRect(0, 0, width, height);
3389
+ const barCount = 32;
3390
+ const barWidth = Math.max(2, (width - (barCount - 1) * 2) / barCount);
3391
+ const gap = 2;
3392
+ const samplesPerBar = Math.floor(bufferLength / barCount);
3393
+ for (let i = 0; i < barCount; i++) {
3394
+ let sum = 0;
3395
+ for (let j = 0; j < samplesPerBar; j++) {
3396
+ const val = dataArray[i * samplesPerBar + j] - 128;
3397
+ sum += Math.abs(val);
3398
+ }
3399
+ const avg = sum / samplesPerBar;
3400
+ const barHeight = Math.max(3, avg / 128 * height * 2.5);
3401
+ const x = i * (barWidth + gap);
3402
+ const y = (height - barHeight) / 2;
3403
+ ctx.fillStyle = "#3b82f6";
3404
+ ctx.beginPath();
3405
+ ctx.roundRect(x, y, barWidth, barHeight, barWidth / 2);
3406
+ ctx.fill();
3407
+ }
3408
+ };
3409
+ draw();
3410
+ }, []);
3411
+ const startRecording = _react.useCallback.call(void 0, async () => {
3412
+ const SpeechRecognitionCtor = getSpeechRecognition();
3413
+ if (!SpeechRecognitionCtor) return;
3414
+ try {
3415
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
3416
+ mediaStreamRef.current = stream;
3417
+ const audioCtx = new AudioContext();
3418
+ audioContextRef.current = audioCtx;
3419
+ const source = audioCtx.createMediaStreamSource(stream);
3420
+ const analyser = audioCtx.createAnalyser();
3421
+ analyser.fftSize = 256;
3422
+ source.connect(analyser);
3423
+ analyserRef.current = analyser;
3424
+ const recognition = new SpeechRecognitionCtor();
3425
+ recognition.continuous = true;
3426
+ recognition.interimResults = true;
3427
+ recognition.lang = _optionalChain([sttConfig, 'optionalAccess', _56 => _56.language]) || navigator.language || "en-US";
3428
+ recognitionRef.current = recognition;
3429
+ finalTranscriptRef.current = "";
3430
+ manualStopRef.current = false;
3431
+ recognition.onresult = (event) => {
3432
+ let final = "";
3433
+ let interim = "";
3434
+ for (let i = 0; i < event.results.length; i++) {
3435
+ const result = event.results[i];
3436
+ if (result.isFinal) {
3437
+ final += result[0].transcript;
3438
+ } else {
3439
+ interim += result[0].transcript;
3440
+ }
3441
+ }
3442
+ finalTranscriptRef.current = final;
3443
+ if (silenceTimerRef.current) {
3444
+ clearTimeout(silenceTimerRef.current);
3445
+ }
3446
+ silenceTimerRef.current = setTimeout(() => {
3447
+ stopRecording(false);
3448
+ }, silenceTimeout);
3449
+ };
3450
+ recognition.onerror = (event) => {
3451
+ if (event.error !== "aborted") {
3452
+ console.warn("Speech recognition error:", event.error);
3453
+ }
3454
+ stopRecording(true);
3455
+ };
3456
+ recognition.onend = () => {
3457
+ if (!manualStopRef.current && isRecording) {
3458
+ finishRecording();
3459
+ }
3460
+ };
3461
+ recognition.start();
3462
+ setIsRecording(true);
3463
+ setRecordingTime(0);
3464
+ recordingTimerRef.current = setInterval(() => {
3465
+ setRecordingTime((t) => t + 1);
3466
+ }, 1e3);
3467
+ requestAnimationFrame(() => drawWaveform());
3468
+ silenceTimerRef.current = setTimeout(() => {
3469
+ stopRecording(false);
3470
+ }, silenceTimeout + 1e3);
3471
+ } catch (err) {
3472
+ console.warn("Microphone access denied or error:", err);
3473
+ setFileError("Microphone access denied");
3474
+ setTimeout(() => setFileError(null), 3e3);
3475
+ }
3476
+ }, [_optionalChain([sttConfig, 'optionalAccess', _57 => _57.language]), silenceTimeout, drawWaveform]);
3477
+ const finishRecording = _react.useCallback.call(void 0, () => {
3478
+ const transcript = finalTranscriptRef.current.trim();
3479
+ setIsRecording(false);
3480
+ setRecordingTime(0);
3481
+ if (transcript) {
3482
+ if (autoSend) {
3483
+ setTranscriptFlash(transcript);
3484
+ setTimeout(() => {
3485
+ setTranscriptFlash(null);
3486
+ onSendMessage(transcript);
3487
+ }, 600);
3488
+ } else {
3489
+ setText((prev) => prev ? `${prev} ${transcript}` : transcript);
3490
+ }
3491
+ }
3492
+ }, [autoSend, onSendMessage]);
3493
+ const stopRecording = _react.useCallback.call(void 0, (isCleanupOnly) => {
3494
+ manualStopRef.current = true;
3495
+ if (silenceTimerRef.current) {
3496
+ clearTimeout(silenceTimerRef.current);
3497
+ silenceTimerRef.current = null;
3498
+ }
3499
+ if (recordingTimerRef.current) {
3500
+ clearInterval(recordingTimerRef.current);
3501
+ recordingTimerRef.current = null;
3502
+ }
3503
+ if (animFrameRef.current) {
3504
+ cancelAnimationFrame(animFrameRef.current);
3505
+ animFrameRef.current = 0;
3506
+ }
3507
+ if (recognitionRef.current) {
3508
+ try {
3509
+ recognitionRef.current.stop();
3510
+ } catch (_e) {
3511
+ }
3512
+ recognitionRef.current = null;
3513
+ }
3514
+ if (mediaStreamRef.current) {
3515
+ mediaStreamRef.current.getTracks().forEach((t) => t.stop());
3516
+ mediaStreamRef.current = null;
3517
+ }
3518
+ if (audioContextRef.current) {
3519
+ try {
3520
+ audioContextRef.current.close();
3521
+ } catch (_e) {
3522
+ }
3523
+ audioContextRef.current = null;
3524
+ }
3525
+ analyserRef.current = null;
3526
+ if (!isCleanupOnly) {
3527
+ finishRecording();
3528
+ } else {
3529
+ setIsRecording(false);
3530
+ setRecordingTime(0);
3531
+ }
3532
+ }, [finishRecording]);
3533
+ const formatTime = (seconds) => {
3534
+ const m = Math.floor(seconds / 60);
3535
+ const s = seconds % 60;
3536
+ return `${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`;
3537
+ };
3350
3538
  const handleKeyDown = (e) => {
3351
3539
  if (e.key === "Enter" && !e.shiftKey) {
3352
3540
  e.preventDefault();
@@ -3406,7 +3594,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
3406
3594
  setFileError(errors.join(", "));
3407
3595
  setTimeout(() => setFileError(null), 5e3);
3408
3596
  }
3409
- _optionalChain([onFileUpload, 'optionalCall', _54 => _54(e.target.files)]);
3597
+ _optionalChain([onFileUpload, 'optionalCall', _58 => _58(e.target.files)]);
3410
3598
  setShowMenu(false);
3411
3599
  e.target.value = "";
3412
3600
  }
@@ -3429,12 +3617,17 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
3429
3617
  }
3430
3618
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) });
3431
3619
  };
3620
+ const hasMic = sttSupported && !isRecording;
3621
+ const gridCols = hasMic ? "auto 1fr auto auto" : "auto 1fr auto";
3622
+ const gridAreas = isRecording ? '"plus waveform waveform stop"' : isMultiLine ? hasMic ? '"textarea textarea textarea textarea" "plus . mic send"' : '"textarea textarea textarea" "plus . send"' : hasMic ? '"plus textarea mic send"' : '"plus textarea send"';
3623
+ const gridColsRecording = "auto 1fr auto";
3432
3624
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "px-4 py-3 relative", children: [
3433
3625
  fileError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-file-error", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-file-error-content", children: [
3434
3626
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", 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" }) }),
3435
3627
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: fileError })
3436
3628
  ] }) }),
3437
- pendingFiles.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-file-preview", children: pendingFiles.map((pf, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-file-item", children: [
3629
+ transcriptFlash && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-transcript-flash", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: transcriptFlash }) }),
3630
+ pendingFiles.length > 0 && !isRecording && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-file-preview", children: pendingFiles.map((pf, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-file-item", children: [
3438
3631
  pf.preview ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { src: pf.preview, alt: pf.file.name, className: "apteva-file-thumb" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-file-icon", children: getFileIcon(pf.file.type) }),
3439
3632
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-file-info", children: [
3440
3633
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-file-name", children: pf.file.name }),
@@ -3455,12 +3648,12 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
3455
3648
  {
3456
3649
  className: "apteva-composer",
3457
3650
  style: {
3458
- gridTemplateColumns: "auto 1fr auto",
3459
- gridTemplateAreas: isMultiLine ? '"textarea textarea textarea" "plus . send"' : '"plus textarea send"',
3651
+ gridTemplateColumns: isRecording ? gridColsRecording : gridCols,
3652
+ gridTemplateAreas: isRecording ? '"plus waveform stop"' : gridAreas,
3460
3653
  alignItems: "end"
3461
3654
  },
3462
3655
  children: [
3463
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative flex-shrink-0 self-end", style: { gridArea: "plus" }, children: [
3656
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "relative flex-shrink-0 self-end", style: { gridArea: "plus" }, children: isRecording ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-composer-rec-dot", title: "Recording...", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {}) }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3464
3657
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3465
3658
  "button",
3466
3659
  {
@@ -3478,15 +3671,15 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
3478
3671
  {
3479
3672
  className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
3480
3673
  style: {
3481
- left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.getBoundingClientRect, 'call', _57 => _57(), 'access', _58 => _58.left]), () => ( 0)),
3482
- bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.getBoundingClientRect, 'call', _61 => _61(), 'access', _62 => _62.top]), () => ( 0))) + 8
3674
+ left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.getBoundingClientRect, 'call', _61 => _61(), 'access', _62 => _62.left]), () => ( 0)),
3675
+ bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.getBoundingClientRect, 'call', _65 => _65(), 'access', _66 => _66.top]), () => ( 0))) + 8
3483
3676
  },
3484
3677
  children: [
3485
3678
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3486
3679
  "button",
3487
3680
  {
3488
3681
  onClick: () => {
3489
- _optionalChain([fileInputRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.click, 'call', _65 => _65()]);
3682
+ _optionalChain([fileInputRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.click, 'call', _69 => _69()]);
3490
3683
  setShowMenu(false);
3491
3684
  },
3492
3685
  className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
@@ -3514,39 +3707,77 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
3514
3707
  }
3515
3708
  )
3516
3709
  ] })
3517
- ] }),
3518
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3519
- "textarea",
3520
- {
3521
- ref: textareaRef,
3522
- value: text,
3523
- onChange: handleChange,
3524
- onKeyDown: handleKeyDown,
3525
- placeholder,
3526
- disabled,
3527
- className: "apteva-composer-textarea resize-none bg-transparent border-none focus:outline-none !text-neutral-900 dark:!text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 py-1 disabled:opacity-50 disabled:cursor-not-allowed overflow-y-auto max-h-[200px]",
3528
- style: { gridArea: "textarea" },
3529
- rows: 1
3530
- }
3531
- ),
3532
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "self-end", style: { gridArea: "send" }, children: isLoading && onStop ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3533
- "button",
3534
- {
3535
- onClick: onStop,
3536
- className: "apteva-composer-stop-btn",
3537
- title: "Stop generation",
3538
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "2", width: "10", height: "10", rx: "1", fill: "currentColor" }) })
3539
- }
3540
- ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3541
- "button",
3542
- {
3543
- onClick: handleSend,
3544
- disabled: !text.trim() && pendingFiles.length === 0 || disabled,
3545
- className: "apteva-composer-send-btn w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all flex-shrink-0 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 !text-neutral-700 dark:!text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed !text-lg",
3546
- title: "Send message",
3547
- 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 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
3548
- }
3549
- ) })
3710
+ ] }) }),
3711
+ isRecording ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3712
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-composer-waveform", style: { gridArea: "waveform" }, children: [
3713
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3714
+ "canvas",
3715
+ {
3716
+ ref: canvasRef,
3717
+ width: 300,
3718
+ height: 36,
3719
+ className: "apteva-composer-waveform-canvas"
3720
+ }
3721
+ ),
3722
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "apteva-composer-recording-timer", children: formatTime(recordingTime) })
3723
+ ] }),
3724
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "self-end", style: { gridArea: "stop" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3725
+ "button",
3726
+ {
3727
+ onClick: () => stopRecording(false),
3728
+ className: "apteva-composer-stop-btn",
3729
+ title: "Stop recording",
3730
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "2", width: "10", height: "10", rx: "1", fill: "currentColor" }) })
3731
+ }
3732
+ ) })
3733
+ ] }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3734
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3735
+ "textarea",
3736
+ {
3737
+ ref: textareaRef,
3738
+ value: text,
3739
+ onChange: handleChange,
3740
+ onKeyDown: handleKeyDown,
3741
+ placeholder,
3742
+ disabled,
3743
+ className: "apteva-composer-textarea resize-none bg-transparent border-none focus:outline-none !text-neutral-900 dark:!text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 py-1 disabled:opacity-50 disabled:cursor-not-allowed overflow-y-auto max-h-[200px]",
3744
+ style: { gridArea: "textarea" },
3745
+ rows: 1
3746
+ }
3747
+ ),
3748
+ sttSupported && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "self-end", style: { gridArea: "mic" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3749
+ "button",
3750
+ {
3751
+ onClick: startRecording,
3752
+ disabled: disabled || isLoading,
3753
+ className: "apteva-composer-mic-btn",
3754
+ title: "Voice input",
3755
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
3756
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M12 1a3 3 0 00-3 3v8a3 3 0 006 0V4a3 3 0 00-3-3z", fill: "currentColor" }),
3757
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M19 10v2a7 7 0 01-14 0v-2", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
3758
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M12 19v4M8 23h8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
3759
+ ] })
3760
+ }
3761
+ ) }),
3762
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "self-end", style: { gridArea: "send" }, children: isLoading && onStop ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3763
+ "button",
3764
+ {
3765
+ onClick: onStop,
3766
+ className: "apteva-composer-stop-btn",
3767
+ title: "Stop generation",
3768
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { x: "2", y: "2", width: "10", height: "10", rx: "1", fill: "currentColor" }) })
3769
+ }
3770
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3771
+ "button",
3772
+ {
3773
+ onClick: handleSend,
3774
+ disabled: !text.trim() && pendingFiles.length === 0 || disabled,
3775
+ className: "apteva-composer-send-btn w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all flex-shrink-0 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 !text-neutral-700 dark:!text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed !text-lg",
3776
+ title: "Send message",
3777
+ 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 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
3778
+ }
3779
+ ) })
3780
+ ] })
3550
3781
  ]
3551
3782
  }
3552
3783
  ),
@@ -3607,8 +3838,8 @@ function CommandComposer({
3607
3838
  }
3608
3839
  };
3609
3840
  const handleNewCommand = () => {
3610
- _optionalChain([onReset, 'optionalCall', _66 => _66()]);
3611
- _optionalChain([inputRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.focus, 'call', _69 => _69()]);
3841
+ _optionalChain([onReset, 'optionalCall', _70 => _70()]);
3842
+ _optionalChain([inputRef, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.focus, 'call', _73 => _73()]);
3612
3843
  };
3613
3844
  const handleInputChange = (value) => {
3614
3845
  setInput(value);
@@ -3722,15 +3953,15 @@ function CommandComposer({
3722
3953
  {
3723
3954
  className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
3724
3955
  style: {
3725
- left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _70 => _70.current, 'optionalAccess', _71 => _71.getBoundingClientRect, 'call', _72 => _72(), 'access', _73 => _73.left]), () => ( 0)),
3726
- top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _74 => _74.current, 'optionalAccess', _75 => _75.getBoundingClientRect, 'call', _76 => _76(), 'access', _77 => _77.bottom]), () => ( 0))) + 8
3956
+ left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _74 => _74.current, 'optionalAccess', _75 => _75.getBoundingClientRect, 'call', _76 => _76(), 'access', _77 => _77.left]), () => ( 0)),
3957
+ top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _78 => _78.current, 'optionalAccess', _79 => _79.getBoundingClientRect, 'call', _80 => _80(), 'access', _81 => _81.bottom]), () => ( 0))) + 8
3727
3958
  },
3728
3959
  children: [
3729
3960
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3730
3961
  "button",
3731
3962
  {
3732
3963
  onClick: () => {
3733
- _optionalChain([fileInputRef, 'access', _78 => _78.current, 'optionalAccess', _79 => _79.click, 'call', _80 => _80()]);
3964
+ _optionalChain([fileInputRef, 'access', _82 => _82.current, 'optionalAccess', _83 => _83.click, 'call', _84 => _84()]);
3734
3965
  setShowMenu(false);
3735
3966
  },
3736
3967
  className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
@@ -3883,8 +4114,8 @@ var AptevaClient = class {
3883
4114
  constructor(config) {
3884
4115
  __publicField(this, "config");
3885
4116
  this.config = {
3886
- apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _81 => _81.apiUrl]), () => ( "")),
3887
- apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _82 => _82.apiKey]), () => ( ""))
4117
+ apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _85 => _85.apiUrl]), () => ( "")),
4118
+ apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _86 => _86.apiKey]), () => ( ""))
3888
4119
  };
3889
4120
  }
3890
4121
  /**
@@ -3961,7 +4192,7 @@ var AptevaClient = class {
3961
4192
  const error = await response.json().catch(() => ({ error: "Request failed" }));
3962
4193
  throw new Error(error.error || `Request failed with status ${response.status}`);
3963
4194
  }
3964
- const reader = _optionalChain([response, 'access', _83 => _83.body, 'optionalAccess', _84 => _84.getReader, 'call', _85 => _85()]);
4195
+ const reader = _optionalChain([response, 'access', _87 => _87.body, 'optionalAccess', _88 => _88.getReader, 'call', _89 => _89()]);
3965
4196
  if (!reader) {
3966
4197
  throw new Error("Response body is not readable");
3967
4198
  }
@@ -3979,7 +4210,7 @@ var AptevaClient = class {
3979
4210
  if (line.startsWith("data: ")) {
3980
4211
  const data = line.slice(6);
3981
4212
  if (data === "[DONE]") {
3982
- _optionalChain([onComplete, 'optionalCall', _86 => _86(threadId)]);
4213
+ _optionalChain([onComplete, 'optionalCall', _90 => _90(threadId)]);
3983
4214
  return;
3984
4215
  }
3985
4216
  try {
@@ -3994,10 +4225,10 @@ var AptevaClient = class {
3994
4225
  }
3995
4226
  }
3996
4227
  }
3997
- _optionalChain([onComplete, 'optionalCall', _87 => _87(threadId)]);
4228
+ _optionalChain([onComplete, 'optionalCall', _91 => _91(threadId)]);
3998
4229
  } catch (error) {
3999
4230
  const err = error instanceof Error ? error : new Error("Unknown error");
4000
- _optionalChain([onError, 'optionalCall', _88 => _88(err)]);
4231
+ _optionalChain([onError, 'optionalCall', _92 => _92(err)]);
4001
4232
  throw err;
4002
4233
  }
4003
4234
  }
@@ -4145,6 +4376,8 @@ var Chat = _react.forwardRef.call(void 0, function Chat2({
4145
4376
  availableWidgets,
4146
4377
  compactWidgetContext = false,
4147
4378
  onWidgetRender,
4379
+ // Speech to text
4380
+ speechToText,
4148
4381
  className
4149
4382
  }, ref) {
4150
4383
  const [messages, setMessages] = _react.useState.call(void 0, initialMessages);
@@ -4220,7 +4453,7 @@ ${widgetContext}` : widgetContext;
4220
4453
  }, [apiUrl, apiKey]);
4221
4454
  _react.useEffect.call(void 0, () => {
4222
4455
  if (threadId) {
4223
- _optionalChain([onThreadChange, 'optionalCall', _89 => _89(threadId)]);
4456
+ _optionalChain([onThreadChange, 'optionalCall', _93 => _93(threadId)]);
4224
4457
  }
4225
4458
  }, [threadId, onThreadChange]);
4226
4459
  _react.useEffect.call(void 0, () => {
@@ -4238,7 +4471,7 @@ ${widgetContext}` : widgetContext;
4238
4471
  }, [showSettingsMenu]);
4239
4472
  const handleModeChange = (newMode) => {
4240
4473
  setMode(newMode);
4241
- _optionalChain([onModeChange, 'optionalCall', _90 => _90(newMode)]);
4474
+ _optionalChain([onModeChange, 'optionalCall', _94 => _94(newMode)]);
4242
4475
  if (newMode === "command") {
4243
4476
  setCommandState("idle");
4244
4477
  setCommandResult(null);
@@ -4247,8 +4480,8 @@ ${widgetContext}` : widgetContext;
4247
4480
  };
4248
4481
  const defaultPlaceholder = mode === "chat" ? "Type a message..." : "Enter your command...";
4249
4482
  const handleWidgetAction = _react.useCallback.call(void 0, (action) => {
4250
- _optionalChain([onAction, 'optionalCall', _91 => _91(action)]);
4251
- if (action.type === "submit" && _optionalChain([action, 'access', _92 => _92.payload, 'optionalAccess', _93 => _93.formData])) {
4483
+ _optionalChain([onAction, 'optionalCall', _95 => _95(action)]);
4484
+ if (action.type === "submit" && _optionalChain([action, 'access', _96 => _96.payload, 'optionalAccess', _97 => _97.formData])) {
4252
4485
  const formData = action.payload.formData;
4253
4486
  const lines = [];
4254
4487
  for (const [key, value] of Object.entries(formData)) {
@@ -4287,7 +4520,7 @@ ${widgetContext}` : widgetContext;
4287
4520
  metadata: hasFiles ? { attachments } : void 0
4288
4521
  };
4289
4522
  setMessages((prev) => [...prev, userMessage]);
4290
- _optionalChain([onMessageSent, 'optionalCall', _94 => _94(userMessage)]);
4523
+ _optionalChain([onMessageSent, 'optionalCall', _98 => _98(userMessage)]);
4291
4524
  }
4292
4525
  setIsLoading(true);
4293
4526
  try {
@@ -4355,7 +4588,7 @@ ${widgetContext}` : widgetContext;
4355
4588
  responseThreadId = chunk.thread_id;
4356
4589
  if (!currentThreadId) {
4357
4590
  setCurrentThreadId(chunk.thread_id);
4358
- _optionalChain([onThreadChange, 'optionalCall', _95 => _95(chunk.thread_id)]);
4591
+ _optionalChain([onThreadChange, 'optionalCall', _99 => _99(chunk.thread_id)]);
4359
4592
  }
4360
4593
  }
4361
4594
  break;
@@ -4387,7 +4620,7 @@ ${widgetContext}` : widgetContext;
4387
4620
  contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
4388
4621
  toolInputBuffers[chunk.tool_id] = "";
4389
4622
  setChatToolName(displayName);
4390
- _optionalChain([onToolCall, 'optionalCall', _96 => _96(chunk.tool_name, chunk.tool_id)]);
4623
+ _optionalChain([onToolCall, 'optionalCall', _100 => _100(chunk.tool_name, chunk.tool_id)]);
4391
4624
  updateMessage();
4392
4625
  }
4393
4626
  break;
@@ -4447,7 +4680,7 @@ ${widgetContext}` : widgetContext;
4447
4680
  toolSegment.result = chunk.content;
4448
4681
  toolSegment.status = "completed";
4449
4682
  toolSegment.isReceiving = false;
4450
- _optionalChain([onToolResult, 'optionalCall', _97 => _97(toolSegment.name, chunk.content)]);
4683
+ _optionalChain([onToolResult, 'optionalCall', _101 => _101(toolSegment.name, chunk.content)]);
4451
4684
  }
4452
4685
  setChatToolName(null);
4453
4686
  updateMessage();
@@ -4491,7 +4724,7 @@ ${widgetContext}` : widgetContext;
4491
4724
  });
4492
4725
  if (threadId2 && threadId2 !== currentThreadId) {
4493
4726
  setCurrentThreadId(threadId2);
4494
- _optionalChain([onThreadChange, 'optionalCall', _98 => _98(threadId2)]);
4727
+ _optionalChain([onThreadChange, 'optionalCall', _102 => _102(threadId2)]);
4495
4728
  }
4496
4729
  setIsLoading(false);
4497
4730
  setCurrentRequestId(null);
@@ -4515,7 +4748,7 @@ ${widgetContext}` : widgetContext;
4515
4748
  setIsLoading(false);
4516
4749
  setCurrentRequestId(null);
4517
4750
  setChatToolName(null);
4518
- _optionalChain([onError, 'optionalCall', _99 => _99(error)]);
4751
+ _optionalChain([onError, 'optionalCall', _103 => _103(error)]);
4519
4752
  }
4520
4753
  );
4521
4754
  }
@@ -4528,7 +4761,7 @@ ${widgetContext}` : widgetContext;
4528
4761
  metadata: { error: true }
4529
4762
  };
4530
4763
  setMessages((prev) => [...prev, errorMessage]);
4531
- _optionalChain([onError, 'optionalCall', _100 => _100(error instanceof Error ? error : new Error("Unknown error"))]);
4764
+ _optionalChain([onError, 'optionalCall', _104 => _104(error instanceof Error ? error : new Error("Unknown error"))]);
4532
4765
  } finally {
4533
4766
  setIsLoading(false);
4534
4767
  }
@@ -4574,7 +4807,7 @@ ${planningInstruction}` : planningInstruction;
4574
4807
  const error = err instanceof Error ? err : new Error("Failed to generate plan");
4575
4808
  setCommandError(error);
4576
4809
  setCommandState("error");
4577
- _optionalChain([onError, 'optionalCall', _101 => _101(error)]);
4810
+ _optionalChain([onError, 'optionalCall', _105 => _105(error)]);
4578
4811
  }
4579
4812
  }
4580
4813
  return;
@@ -4607,12 +4840,12 @@ ${planningInstruction}` : planningInstruction;
4607
4840
  setCommandResult(result);
4608
4841
  setCommandState("success");
4609
4842
  setProgress(100);
4610
- _optionalChain([onComplete, 'optionalCall', _102 => _102(result)]);
4843
+ _optionalChain([onComplete, 'optionalCall', _106 => _106(result)]);
4611
4844
  },
4612
4845
  (error) => {
4613
4846
  setCommandError(error);
4614
4847
  setCommandState("error");
4615
- _optionalChain([onError, 'optionalCall', _103 => _103(error)]);
4848
+ _optionalChain([onError, 'optionalCall', _107 => _107(error)]);
4616
4849
  }
4617
4850
  );
4618
4851
  } else {
@@ -4625,7 +4858,7 @@ ${planningInstruction}` : planningInstruction;
4625
4858
  setCommandResult(result);
4626
4859
  setCommandState("success");
4627
4860
  setProgress(100);
4628
- _optionalChain([onComplete, 'optionalCall', _104 => _104(result)]);
4861
+ _optionalChain([onComplete, 'optionalCall', _108 => _108(result)]);
4629
4862
  }
4630
4863
  } else {
4631
4864
  const commandInstruction = `CRITICAL COMMAND MODE: Maximum 10 words per response. Execute the command immediately. Make reasonable assumptions based on context. Use sensible defaults for missing details. DO NOT ask questions unless something is truly impossible without user input (e.g., missing required password). State what you're doing or the result. Examples: "Analyzing customer data from last quarter..." or "Created 5 new database entries successfully" or "Search complete: found 12 matching results". NO greetings, NO filler words, NO clarification requests. Action/result only.`;
@@ -4655,16 +4888,16 @@ ${commandInstruction}` : commandInstruction;
4655
4888
  const displayName = chunk.tool_display_name || chunk.tool_name;
4656
4889
  lastToolName = chunk.tool_name;
4657
4890
  setCurrentToolName(displayName);
4658
- _optionalChain([onToolCall, 'optionalCall', _105 => _105(chunk.tool_name, chunk.tool_id || "")]);
4891
+ _optionalChain([onToolCall, 'optionalCall', _109 => _109(chunk.tool_name, chunk.tool_id || "")]);
4659
4892
  accumulatedContent = "";
4660
4893
  setStreamedContent("");
4661
4894
  } else if (chunk.type === "tool_result") {
4662
- _optionalChain([onToolResult, 'optionalCall', _106 => _106(lastToolName, chunk.content)]);
4895
+ _optionalChain([onToolResult, 'optionalCall', _110 => _110(lastToolName, chunk.content)]);
4663
4896
  setCurrentToolName(null);
4664
4897
  } else if (chunk.type === "thread_id" && chunk.thread_id) {
4665
4898
  if (!currentThreadId) {
4666
4899
  setCurrentThreadId(chunk.thread_id);
4667
- _optionalChain([onThreadChange, 'optionalCall', _107 => _107(chunk.thread_id)]);
4900
+ _optionalChain([onThreadChange, 'optionalCall', _111 => _111(chunk.thread_id)]);
4668
4901
  }
4669
4902
  } else if (chunk.type === "request_id" && chunk.request_id) {
4670
4903
  setCurrentRequestId(chunk.request_id);
@@ -4680,13 +4913,13 @@ ${commandInstruction}` : commandInstruction;
4680
4913
  setCommandState("success");
4681
4914
  setProgress(100);
4682
4915
  setCurrentRequestId(null);
4683
- _optionalChain([onComplete, 'optionalCall', _108 => _108(result)]);
4916
+ _optionalChain([onComplete, 'optionalCall', _112 => _112(result)]);
4684
4917
  },
4685
4918
  (error) => {
4686
4919
  setCommandError(error);
4687
4920
  setCommandState("error");
4688
4921
  setCurrentRequestId(null);
4689
- _optionalChain([onError, 'optionalCall', _109 => _109(error)]);
4922
+ _optionalChain([onError, 'optionalCall', _113 => _113(error)]);
4690
4923
  }
4691
4924
  );
4692
4925
  } else {
@@ -4706,14 +4939,14 @@ ${commandInstruction}` : commandInstruction;
4706
4939
  setCommandResult(result);
4707
4940
  setCommandState("success");
4708
4941
  setProgress(100);
4709
- _optionalChain([onComplete, 'optionalCall', _110 => _110(result)]);
4942
+ _optionalChain([onComplete, 'optionalCall', _114 => _114(result)]);
4710
4943
  }
4711
4944
  }
4712
4945
  } catch (err) {
4713
4946
  const error = err instanceof Error ? err : new Error("Unknown error");
4714
4947
  setCommandError(error);
4715
4948
  setCommandState("error");
4716
- _optionalChain([onError, 'optionalCall', _111 => _111(error)]);
4949
+ _optionalChain([onError, 'optionalCall', _115 => _115(error)]);
4717
4950
  }
4718
4951
  };
4719
4952
  const resetCommand = () => {
@@ -4800,7 +5033,8 @@ ${planToExecute}`;
4800
5033
  isLoading,
4801
5034
  onStop: handleStop,
4802
5035
  onFileUpload,
4803
- onSwitchMode: showModeToggle ? () => handleModeChange("command") : void 0
5036
+ onSwitchMode: showModeToggle ? () => handleModeChange("command") : void 0,
5037
+ speechToText
4804
5038
  }
4805
5039
  )
4806
5040
  ] }),
@@ -4812,8 +5046,8 @@ ${planToExecute}`;
4812
5046
  executeCommand(text, files);
4813
5047
  },
4814
5048
  state: commandState,
4815
- response: _optionalChain([commandResult, 'optionalAccess', _112 => _112.data, 'optionalAccess', _113 => _113.summary]) || _optionalChain([commandResult, 'optionalAccess', _114 => _114.message]),
4816
- error: _optionalChain([commandError, 'optionalAccess', _115 => _115.message]),
5049
+ response: _optionalChain([commandResult, 'optionalAccess', _116 => _116.data, 'optionalAccess', _117 => _117.summary]) || _optionalChain([commandResult, 'optionalAccess', _118 => _118.message]),
5050
+ error: _optionalChain([commandError, 'optionalAccess', _119 => _119.message]),
4817
5051
  plan,
4818
5052
  streamedContent,
4819
5053
  toolName: currentToolName,
@@ -4981,13 +5215,13 @@ ${planningInstruction}` : planningInstruction;
4981
5215
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
4982
5216
  setError(error2);
4983
5217
  setState("error");
4984
- _optionalChain([onError, 'optionalCall', _116 => _116(error2)]);
5218
+ _optionalChain([onError, 'optionalCall', _120 => _120(error2)]);
4985
5219
  });
4986
5220
  } catch (err) {
4987
5221
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
4988
5222
  setError(error2);
4989
5223
  setState("error");
4990
- _optionalChain([onError, 'optionalCall', _117 => _117(error2)]);
5224
+ _optionalChain([onError, 'optionalCall', _121 => _121(error2)]);
4991
5225
  }
4992
5226
  }
4993
5227
  return;
@@ -4998,7 +5232,7 @@ ${planningInstruction}` : planningInstruction;
4998
5232
  setStreamedContent("");
4999
5233
  setCommand("");
5000
5234
  setUploadedFiles([]);
5001
- _optionalChain([onStart, 'optionalCall', _118 => _118()]);
5235
+ _optionalChain([onStart, 'optionalCall', _122 => _122()]);
5002
5236
  try {
5003
5237
  if (useMock) {
5004
5238
  if (enableStreaming) {
@@ -5009,16 +5243,16 @@ ${planningInstruction}` : planningInstruction;
5009
5243
  if (chunk.type === "token" && chunk.content) {
5010
5244
  accumulatedContent += chunk.content;
5011
5245
  setStreamedContent(accumulatedContent);
5012
- _optionalChain([onChunk, 'optionalCall', _119 => _119(chunk.content)]);
5246
+ _optionalChain([onChunk, 'optionalCall', _123 => _123(chunk.content)]);
5013
5247
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
5014
5248
  setProgress(estimatedProgress);
5015
- _optionalChain([onProgress, 'optionalCall', _120 => _120(estimatedProgress)]);
5249
+ _optionalChain([onProgress, 'optionalCall', _124 => _124(estimatedProgress)]);
5016
5250
  } else if (chunk.type === "widget" && chunk.widget) {
5017
5251
  const widget = chunk.widget;
5018
5252
  setResult((prev) => ({
5019
5253
  success: true,
5020
- data: _optionalChain([prev, 'optionalAccess', _121 => _121.data]) || {},
5021
- widgets: [..._optionalChain([prev, 'optionalAccess', _122 => _122.widgets]) || [], widget],
5254
+ data: _optionalChain([prev, 'optionalAccess', _125 => _125.data]) || {},
5255
+ widgets: [..._optionalChain([prev, 'optionalAccess', _126 => _126.widgets]) || [], widget],
5022
5256
  message: accumulatedContent || "Command executed successfully"
5023
5257
  }));
5024
5258
  }
@@ -5038,19 +5272,19 @@ ${planningInstruction}` : planningInstruction;
5038
5272
  setResult(result2);
5039
5273
  setState("success");
5040
5274
  setProgress(100);
5041
- _optionalChain([onComplete, 'optionalCall', _123 => _123(result2)]);
5275
+ _optionalChain([onComplete, 'optionalCall', _127 => _127(result2)]);
5042
5276
  },
5043
5277
  (error2) => {
5044
5278
  setError(error2);
5045
5279
  setState("error");
5046
- _optionalChain([onError, 'optionalCall', _124 => _124(error2)]);
5280
+ _optionalChain([onError, 'optionalCall', _128 => _128(error2)]);
5047
5281
  }
5048
5282
  );
5049
5283
  } else {
5050
5284
  const progressInterval = setInterval(() => {
5051
5285
  setProgress((prev) => {
5052
5286
  const next = Math.min(prev + 10, 90);
5053
- _optionalChain([onProgress, 'optionalCall', _125 => _125(next)]);
5287
+ _optionalChain([onProgress, 'optionalCall', _129 => _129(next)]);
5054
5288
  return next;
5055
5289
  });
5056
5290
  }, 200);
@@ -5074,7 +5308,7 @@ ${planningInstruction}` : planningInstruction;
5074
5308
  setResult(result2);
5075
5309
  setState("success");
5076
5310
  setProgress(100);
5077
- _optionalChain([onComplete, 'optionalCall', _126 => _126(result2)]);
5311
+ _optionalChain([onComplete, 'optionalCall', _130 => _130(result2)]);
5078
5312
  }
5079
5313
  } else {
5080
5314
  if (enableStreaming) {
@@ -5120,16 +5354,16 @@ ${commandInstruction}` : commandInstruction;
5120
5354
  if (chunk.type === "token" && chunk.content) {
5121
5355
  accumulatedContent += chunk.content;
5122
5356
  setStreamedContent(accumulatedContent);
5123
- _optionalChain([onChunk, 'optionalCall', _127 => _127(chunk.content)]);
5357
+ _optionalChain([onChunk, 'optionalCall', _131 => _131(chunk.content)]);
5124
5358
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
5125
5359
  setProgress(estimatedProgress);
5126
- _optionalChain([onProgress, 'optionalCall', _128 => _128(estimatedProgress)]);
5360
+ _optionalChain([onProgress, 'optionalCall', _132 => _132(estimatedProgress)]);
5127
5361
  } else if (chunk.type === "widget" && chunk.widget) {
5128
5362
  const widget = chunk.widget;
5129
5363
  setResult((prev) => ({
5130
5364
  success: true,
5131
- data: _optionalChain([prev, 'optionalAccess', _129 => _129.data]) || {},
5132
- widgets: [..._optionalChain([prev, 'optionalAccess', _130 => _130.widgets]) || [], widget],
5365
+ data: _optionalChain([prev, 'optionalAccess', _133 => _133.data]) || {},
5366
+ widgets: [..._optionalChain([prev, 'optionalAccess', _134 => _134.widgets]) || [], widget],
5133
5367
  message: accumulatedContent || "Command executed successfully"
5134
5368
  }));
5135
5369
  }
@@ -5149,20 +5383,20 @@ ${commandInstruction}` : commandInstruction;
5149
5383
  setResult(result2);
5150
5384
  setState("success");
5151
5385
  setProgress(100);
5152
- _optionalChain([onComplete, 'optionalCall', _131 => _131(result2)]);
5386
+ _optionalChain([onComplete, 'optionalCall', _135 => _135(result2)]);
5153
5387
  },
5154
5388
  (error2) => {
5155
5389
  const err = error2 instanceof Error ? error2 : new Error("Unknown error");
5156
5390
  setError(err);
5157
5391
  setState("error");
5158
- _optionalChain([onError, 'optionalCall', _132 => _132(err)]);
5392
+ _optionalChain([onError, 'optionalCall', _136 => _136(err)]);
5159
5393
  }
5160
5394
  );
5161
5395
  } else {
5162
5396
  const progressInterval = setInterval(() => {
5163
5397
  setProgress((prev) => {
5164
5398
  const next = Math.min(prev + 10, 90);
5165
- _optionalChain([onProgress, 'optionalCall', _133 => _133(next)]);
5399
+ _optionalChain([onProgress, 'optionalCall', _137 => _137(next)]);
5166
5400
  return next;
5167
5401
  });
5168
5402
  }, 200);
@@ -5218,14 +5452,14 @@ ${commandInstruction}` : commandInstruction;
5218
5452
  setResult(result2);
5219
5453
  setState("success");
5220
5454
  setProgress(100);
5221
- _optionalChain([onComplete, 'optionalCall', _134 => _134(result2)]);
5455
+ _optionalChain([onComplete, 'optionalCall', _138 => _138(result2)]);
5222
5456
  }
5223
5457
  }
5224
5458
  } catch (err) {
5225
5459
  const error2 = err instanceof Error ? err : new Error("Unknown error");
5226
5460
  setError(error2);
5227
5461
  setState("error");
5228
- _optionalChain([onError, 'optionalCall', _135 => _135(error2)]);
5462
+ _optionalChain([onError, 'optionalCall', _139 => _139(error2)]);
5229
5463
  }
5230
5464
  };
5231
5465
  const resetCommand = () => {
@@ -5258,14 +5492,14 @@ ${planToExecute}`;
5258
5492
  };
5259
5493
  const handleFileSelect = async (e) => {
5260
5494
  if (e.target.files && e.target.files.length > 0) {
5261
- _optionalChain([onFileUpload, 'optionalCall', _136 => _136(e.target.files)]);
5495
+ _optionalChain([onFileUpload, 'optionalCall', _140 => _140(e.target.files)]);
5262
5496
  const files = [];
5263
5497
  for (let i = 0; i < e.target.files.length; i++) {
5264
5498
  const file = e.target.files[i];
5265
5499
  const reader = new FileReader();
5266
5500
  await new Promise((resolve) => {
5267
5501
  reader.onload = (event) => {
5268
- if (_optionalChain([event, 'access', _137 => _137.target, 'optionalAccess', _138 => _138.result])) {
5502
+ if (_optionalChain([event, 'access', _141 => _141.target, 'optionalAccess', _142 => _142.result])) {
5269
5503
  const fullDataUrl = event.target.result;
5270
5504
  const base64Data = fullDataUrl.split(",")[1];
5271
5505
  if (file.type.startsWith("image/")) {
@@ -5359,7 +5593,7 @@ ${planToExecute}`;
5359
5593
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5360
5594
  "button",
5361
5595
  {
5362
- onClick: () => _optionalChain([fileInputRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.click, 'call', _141 => _141()]),
5596
+ onClick: () => _optionalChain([fileInputRef, 'access', _143 => _143.current, 'optionalAccess', _144 => _144.click, 'call', _145 => _145()]),
5363
5597
  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",
5364
5598
  title: "Attach file",
5365
5599
  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)" }) })
@@ -5578,7 +5812,7 @@ ${planToExecute}`;
5578
5812
  /* @__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" }) }),
5579
5813
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
5580
5814
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
5581
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _142 => _142.message]) })
5815
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _146 => _146.message]) })
5582
5816
  ] })
5583
5817
  ] }) }),
5584
5818
  allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -5606,7 +5840,7 @@ ${planToExecute}`;
5606
5840
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
5607
5841
  ] })
5608
5842
  ] }),
5609
- _optionalChain([result, 'access', _143 => _143.data, 'optionalAccess', _144 => _144.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 }),
5843
+ _optionalChain([result, 'access', _147 => _147.data, 'optionalAccess', _148 => _148.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 }),
5610
5844
  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,
5611
5845
  WidgetRenderer,
5612
5846
  {
@@ -5657,7 +5891,7 @@ ${planToExecute}`;
5657
5891
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5658
5892
  "button",
5659
5893
  {
5660
- onClick: () => _optionalChain([fileInputRef, 'access', _145 => _145.current, 'optionalAccess', _146 => _146.click, 'call', _147 => _147()]),
5894
+ onClick: () => _optionalChain([fileInputRef, 'access', _149 => _149.current, 'optionalAccess', _150 => _150.click, 'call', _151 => _151()]),
5661
5895
  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",
5662
5896
  title: "Attach file",
5663
5897
  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)" }) })
@@ -5843,25 +6077,25 @@ function Prompt({
5843
6077
  const newValue = e.target.value;
5844
6078
  if (!maxLength || newValue.length <= maxLength) {
5845
6079
  setValue(newValue);
5846
- _optionalChain([onChange, 'optionalCall', _148 => _148(newValue)]);
6080
+ _optionalChain([onChange, 'optionalCall', _152 => _152(newValue)]);
5847
6081
  }
5848
6082
  };
5849
6083
  const handleSubmit = async () => {
5850
6084
  if (value.length < minLength) return;
5851
- _optionalChain([onSubmit, 'optionalCall', _149 => _149(value)]);
6085
+ _optionalChain([onSubmit, 'optionalCall', _153 => _153(value)]);
5852
6086
  setIsLoading(true);
5853
6087
  try {
5854
6088
  if (useMock) {
5855
6089
  await new Promise((resolve) => setTimeout(resolve, 1500));
5856
6090
  const mockResult = `Enhanced version: ${value} [AI-generated content]`;
5857
- _optionalChain([onResult, 'optionalCall', _150 => _150(mockResult)]);
6091
+ _optionalChain([onResult, 'optionalCall', _154 => _154(mockResult)]);
5858
6092
  setValue("");
5859
6093
  } else {
5860
6094
  const response = await aptevaClient.chat({
5861
6095
  agent_id: agentId,
5862
6096
  message: value
5863
6097
  });
5864
- _optionalChain([onResult, 'optionalCall', _151 => _151(response.message)]);
6098
+ _optionalChain([onResult, 'optionalCall', _155 => _155(response.message)]);
5865
6099
  setValue("");
5866
6100
  }
5867
6101
  } catch (error) {
@@ -5956,7 +6190,7 @@ function Stream({
5956
6190
  }, [autoStart]);
5957
6191
  const startStreaming = async () => {
5958
6192
  setIsStreaming(true);
5959
- _optionalChain([onStart, 'optionalCall', _152 => _152()]);
6193
+ _optionalChain([onStart, 'optionalCall', _156 => _156()]);
5960
6194
  try {
5961
6195
  if (useMock) {
5962
6196
  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.";
@@ -5964,13 +6198,13 @@ function Stream({
5964
6198
  mockText,
5965
6199
  (chunk) => {
5966
6200
  setText((prev) => prev + chunk);
5967
- _optionalChain([onChunk, 'optionalCall', _153 => _153(chunk)]);
6201
+ _optionalChain([onChunk, 'optionalCall', _157 => _157(chunk)]);
5968
6202
  },
5969
6203
  typingSpeed
5970
6204
  );
5971
6205
  setIsComplete(true);
5972
6206
  setIsStreaming(false);
5973
- _optionalChain([onComplete, 'optionalCall', _154 => _154(text + mockText)]);
6207
+ _optionalChain([onComplete, 'optionalCall', _158 => _158(text + mockText)]);
5974
6208
  } else {
5975
6209
  let accumulatedText = "";
5976
6210
  await aptevaClient.chatStream(
@@ -5983,24 +6217,24 @@ function Stream({
5983
6217
  if (chunk.type === "token" && chunk.content) {
5984
6218
  accumulatedText += chunk.content;
5985
6219
  setText(accumulatedText);
5986
- _optionalChain([onChunk, 'optionalCall', _155 => _155(chunk.content)]);
6220
+ _optionalChain([onChunk, 'optionalCall', _159 => _159(chunk.content)]);
5987
6221
  }
5988
6222
  },
5989
6223
  () => {
5990
6224
  setIsComplete(true);
5991
6225
  setIsStreaming(false);
5992
- _optionalChain([onComplete, 'optionalCall', _156 => _156(accumulatedText)]);
6226
+ _optionalChain([onComplete, 'optionalCall', _160 => _160(accumulatedText)]);
5993
6227
  },
5994
6228
  (error) => {
5995
6229
  const err = error instanceof Error ? error : new Error("Streaming error");
5996
- _optionalChain([onError, 'optionalCall', _157 => _157(err)]);
6230
+ _optionalChain([onError, 'optionalCall', _161 => _161(err)]);
5997
6231
  setIsStreaming(false);
5998
6232
  }
5999
6233
  );
6000
6234
  }
6001
6235
  } catch (error) {
6002
6236
  const err = error instanceof Error ? error : new Error("Streaming error");
6003
- _optionalChain([onError, 'optionalCall', _158 => _158(err)]);
6237
+ _optionalChain([onError, 'optionalCall', _162 => _162(err)]);
6004
6238
  setIsStreaming(false);
6005
6239
  }
6006
6240
  };
@@ -6092,7 +6326,7 @@ function ThreadList({
6092
6326
  }) {
6093
6327
  const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
6094
6328
  const filteredThreads = threads.filter(
6095
- (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _159 => _159.preview, 'optionalAccess', _160 => _160.toLowerCase, 'call', _161 => _161(), 'access', _162 => _162.includes, 'call', _163 => _163(searchQuery.toLowerCase())])
6329
+ (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _163 => _163.preview, 'optionalAccess', _164 => _164.toLowerCase, 'call', _165 => _165(), 'access', _166 => _166.includes, 'call', _167 => _167(searchQuery.toLowerCase())])
6096
6330
  );
6097
6331
  const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
6098
6332
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
@@ -6114,8 +6348,8 @@ function ThreadList({
6114
6348
  {
6115
6349
  thread,
6116
6350
  isActive: thread.id === currentThreadId,
6117
- onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _164 => _164(thread.id)]),
6118
- onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _165 => _165(thread.id)])
6351
+ onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _168 => _168(thread.id)]),
6352
+ onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _169 => _169(thread.id)])
6119
6353
  },
6120
6354
  thread.id
6121
6355
  ))
@@ -6177,7 +6411,7 @@ function Threads({
6177
6411
  threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6178
6412
  "button",
6179
6413
  {
6180
- onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _166 => _166(thread.id)]),
6414
+ onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _170 => _170(thread.id)]),
6181
6415
  className: cn(
6182
6416
  "px-4 py-2 whitespace-nowrap font-medium transition-colors",
6183
6417
  thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"
@@ -6362,7 +6596,7 @@ function TabsLayout({ node, renderNode }) {
6362
6596
  var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
6363
6597
  function normalizeNode(n) {
6364
6598
  let node = { ...n };
6365
- if (node.type === "widget" && _optionalChain([node, 'access', _167 => _167.props, 'optionalAccess', _168 => _168.widget])) {
6599
+ if (node.type === "widget" && _optionalChain([node, 'access', _171 => _171.props, 'optionalAccess', _172 => _172.widget])) {
6366
6600
  node.type = node.props.widget;
6367
6601
  const { widget: _, ...rest } = node.props;
6368
6602
  node.props = rest;
@@ -6500,10 +6734,10 @@ function AutoInterface({
6500
6734
  ].filter(Boolean).join("\n\n");
6501
6735
  const updateInterface = _react.useCallback.call(void 0, (newSpec) => {
6502
6736
  setInterfaceSpec(newSpec);
6503
- _optionalChain([onInterfaceChange, 'optionalCall', _169 => _169(newSpec)]);
6737
+ _optionalChain([onInterfaceChange, 'optionalCall', _173 => _173(newSpec)]);
6504
6738
  }, [onInterfaceChange]);
6505
6739
  const handleAction = _react.useCallback.call(void 0, (action) => {
6506
- _optionalChain([onAction, 'optionalCall', _170 => _170(action)]);
6740
+ _optionalChain([onAction, 'optionalCall', _174 => _174(action)]);
6507
6741
  if (chatRef.current) {
6508
6742
  chatRef.current.sendMessage(
6509
6743
  `[Action: ${action.type} on widget ${action.widgetId || "unknown"}. Payload: ${JSON.stringify(action.payload)}]`
@@ -6511,7 +6745,7 @@ function AutoInterface({
6511
6745
  }
6512
6746
  }, [onAction]);
6513
6747
  const handleMessageComplete = _react.useCallback.call(void 0, (result) => {
6514
- if (!_optionalChain([result, 'optionalAccess', _171 => _171.data])) return;
6748
+ if (!_optionalChain([result, 'optionalAccess', _175 => _175.data])) return;
6515
6749
  const text = typeof result.data === "string" ? result.data : result.data.message || "";
6516
6750
  console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
6517
6751
  const parsed = parseInterfaceFromText(text);
@@ -6551,7 +6785,7 @@ function AutoInterface({
6551
6785
  }).catch((err) => {
6552
6786
  if (cancelled) return;
6553
6787
  console.error("[AutoInterface] Initial generation failed:", err);
6554
- _optionalChain([onError, 'optionalCall', _172 => _172(err instanceof Error ? err : new Error(String(err)))]);
6788
+ _optionalChain([onError, 'optionalCall', _176 => _176(err instanceof Error ? err : new Error(String(err)))]);
6555
6789
  setIsGenerating(false);
6556
6790
  });
6557
6791
  return () => {
@@ -6717,7 +6951,7 @@ function useInterfaceAI({
6717
6951
  }
6718
6952
  const sendMessage = _react.useCallback.call(void 0, async (message) => {
6719
6953
  accumulatedTextRef.current = "";
6720
- _optionalChain([onStreamStart, 'optionalCall', _173 => _173()]);
6954
+ _optionalChain([onStreamStart, 'optionalCall', _177 => _177()]);
6721
6955
  const systemPrompt = [
6722
6956
  generateInterfaceContext(),
6723
6957
  context || ""
@@ -6740,27 +6974,27 @@ function useInterfaceAI({
6740
6974
  accumulatedTextRef.current += chunk.content || "";
6741
6975
  const parsed = parseInterfaceFromText(accumulatedTextRef.current);
6742
6976
  if (parsed) {
6743
- _optionalChain([onInterface, 'optionalCall', _174 => _174(parsed)]);
6977
+ _optionalChain([onInterface, 'optionalCall', _178 => _178(parsed)]);
6744
6978
  }
6745
6979
  const updates = parseUpdatesFromText(accumulatedTextRef.current);
6746
6980
  if (updates.length > 0) {
6747
- _optionalChain([onUpdates, 'optionalCall', _175 => _175(updates)]);
6981
+ _optionalChain([onUpdates, 'optionalCall', _179 => _179(updates)]);
6748
6982
  }
6749
6983
  }
6750
6984
  },
6751
6985
  // onComplete
6752
6986
  () => {
6753
- _optionalChain([onStreamEnd, 'optionalCall', _176 => _176()]);
6987
+ _optionalChain([onStreamEnd, 'optionalCall', _180 => _180()]);
6754
6988
  },
6755
6989
  // onError
6756
6990
  (error) => {
6757
- _optionalChain([onError, 'optionalCall', _177 => _177(error)]);
6758
- _optionalChain([onStreamEnd, 'optionalCall', _178 => _178()]);
6991
+ _optionalChain([onError, 'optionalCall', _181 => _181(error)]);
6992
+ _optionalChain([onStreamEnd, 'optionalCall', _182 => _182()]);
6759
6993
  }
6760
6994
  );
6761
6995
  } catch (error) {
6762
- _optionalChain([onError, 'optionalCall', _179 => _179(error instanceof Error ? error : new Error("Unknown error"))]);
6763
- _optionalChain([onStreamEnd, 'optionalCall', _180 => _180()]);
6996
+ _optionalChain([onError, 'optionalCall', _183 => _183(error instanceof Error ? error : new Error("Unknown error"))]);
6997
+ _optionalChain([onStreamEnd, 'optionalCall', _184 => _184()]);
6764
6998
  }
6765
6999
  }, [agentId, context, onInterface, onUpdates, onError, onStreamStart, onStreamEnd]);
6766
7000
  return {