@apteva/apteva-kit 0.1.17 → 0.1.22
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.d.mts +81 -3
- package/dist/index.d.ts +81 -3
- package/dist/index.js +733 -109
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1005 -381
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,10 +4,13 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
|
|
6
6
|
// src/components/Chat/Chat.tsx
|
|
7
|
-
import { useState as useState3, useEffect as
|
|
7
|
+
import { useState as useState3, useEffect as useEffect4, useRef as useRef5, useMemo as useMemo2 } from "react";
|
|
8
8
|
|
|
9
9
|
// src/components/Chat/MessageList.tsx
|
|
10
|
-
import { useEffect as
|
|
10
|
+
import { useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
11
|
+
|
|
12
|
+
// src/components/Chat/Message.tsx
|
|
13
|
+
import { useEffect as useEffect2, useRef, useMemo } from "react";
|
|
11
14
|
|
|
12
15
|
// src/utils/cn.ts
|
|
13
16
|
import { clsx } from "clsx";
|
|
@@ -498,6 +501,246 @@ function validateFile(file) {
|
|
|
498
501
|
return { valid: true };
|
|
499
502
|
}
|
|
500
503
|
|
|
504
|
+
// src/utils/widget-parser.ts
|
|
505
|
+
function simpleHash(str) {
|
|
506
|
+
let hash = 0;
|
|
507
|
+
for (let i = 0; i < str.length; i++) {
|
|
508
|
+
const char = str.charCodeAt(i);
|
|
509
|
+
hash = (hash << 5) - hash + char;
|
|
510
|
+
hash = hash & hash;
|
|
511
|
+
}
|
|
512
|
+
return Math.abs(hash).toString(36);
|
|
513
|
+
}
|
|
514
|
+
function findMatchingBracket(text, startIndex) {
|
|
515
|
+
let depth = 0;
|
|
516
|
+
let inString = false;
|
|
517
|
+
let escapeNext = false;
|
|
518
|
+
for (let i = startIndex; i < text.length; i++) {
|
|
519
|
+
const char = text[i];
|
|
520
|
+
if (escapeNext) {
|
|
521
|
+
escapeNext = false;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (char === "\\" && inString) {
|
|
525
|
+
escapeNext = true;
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
if (char === '"') {
|
|
529
|
+
inString = !inString;
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
if (inString) continue;
|
|
533
|
+
if (char === "[" || char === "{") {
|
|
534
|
+
depth++;
|
|
535
|
+
} else if (char === "]" || char === "}") {
|
|
536
|
+
depth--;
|
|
537
|
+
if (depth === 0) {
|
|
538
|
+
return i;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return -1;
|
|
543
|
+
}
|
|
544
|
+
function parseWidgetsFromText(text) {
|
|
545
|
+
const segments = [];
|
|
546
|
+
let hasWidgets = false;
|
|
547
|
+
let hasPendingWidget = false;
|
|
548
|
+
let currentIndex = 0;
|
|
549
|
+
let pendingWidgetType = null;
|
|
550
|
+
let processText = text;
|
|
551
|
+
const lastWidgetStart = text.lastIndexOf("@ui:");
|
|
552
|
+
if (lastWidgetStart !== -1) {
|
|
553
|
+
const afterStart = text.slice(lastWidgetStart);
|
|
554
|
+
const typeMatch = afterStart.match(/^@ui:(\w+)/);
|
|
555
|
+
if (typeMatch) {
|
|
556
|
+
const widgetType = typeMatch[1];
|
|
557
|
+
const bracketOpenIndex = afterStart.indexOf("[");
|
|
558
|
+
if (bracketOpenIndex === -1) {
|
|
559
|
+
processText = text.slice(0, lastWidgetStart);
|
|
560
|
+
pendingWidgetType = widgetType;
|
|
561
|
+
hasPendingWidget = true;
|
|
562
|
+
} else {
|
|
563
|
+
const fullBracketStart = lastWidgetStart + bracketOpenIndex;
|
|
564
|
+
const bracketEnd = findMatchingBracket(text, fullBracketStart);
|
|
565
|
+
if (bracketEnd === -1) {
|
|
566
|
+
processText = text.slice(0, lastWidgetStart);
|
|
567
|
+
pendingWidgetType = widgetType;
|
|
568
|
+
hasPendingWidget = true;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
if (hasPendingWidget) {
|
|
574
|
+
processText = processText.replace(/[\s:;\-–—\.]+$/g, "");
|
|
575
|
+
}
|
|
576
|
+
const startPattern = /@ui:(\w+)\[/g;
|
|
577
|
+
let match;
|
|
578
|
+
while ((match = startPattern.exec(processText)) !== null) {
|
|
579
|
+
const widgetType = match[1];
|
|
580
|
+
const bracketStart = match.index + match[0].length - 1;
|
|
581
|
+
const bracketEnd = findMatchingBracket(processText, bracketStart);
|
|
582
|
+
if (bracketEnd === -1) {
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
const jsonContent = processText.slice(bracketStart + 1, bracketEnd);
|
|
586
|
+
if (match.index > currentIndex) {
|
|
587
|
+
const textContent = processText.slice(currentIndex, match.index).trim();
|
|
588
|
+
if (textContent) {
|
|
589
|
+
segments.push({
|
|
590
|
+
type: "text",
|
|
591
|
+
content: textContent
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
try {
|
|
596
|
+
const trimmedJson = jsonContent.trim();
|
|
597
|
+
const props = JSON.parse(trimmedJson);
|
|
598
|
+
const widgetId = `widget-${widgetType}-${simpleHash(trimmedJson)}`;
|
|
599
|
+
segments.push({
|
|
600
|
+
type: "widget",
|
|
601
|
+
widget: {
|
|
602
|
+
type: widgetType,
|
|
603
|
+
id: widgetId,
|
|
604
|
+
props
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
hasWidgets = true;
|
|
608
|
+
} catch (e) {
|
|
609
|
+
}
|
|
610
|
+
currentIndex = bracketEnd + 1;
|
|
611
|
+
startPattern.lastIndex = currentIndex;
|
|
612
|
+
}
|
|
613
|
+
if (currentIndex < processText.length) {
|
|
614
|
+
const remainingText = processText.slice(currentIndex).trim();
|
|
615
|
+
if (remainingText) {
|
|
616
|
+
segments.push({
|
|
617
|
+
type: "text",
|
|
618
|
+
content: remainingText
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (segments.length === 0 && processText.trim()) {
|
|
623
|
+
segments.push({
|
|
624
|
+
type: "text",
|
|
625
|
+
content: processText.trim()
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
if (pendingWidgetType) {
|
|
629
|
+
segments.push({
|
|
630
|
+
type: "widget_pending",
|
|
631
|
+
pendingType: pendingWidgetType
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
return { segments, hasWidgets, hasPendingWidget };
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// src/utils/widget-context.ts
|
|
638
|
+
var WIDGET_DEFINITIONS = {
|
|
639
|
+
card: {
|
|
640
|
+
description: "Displays a card with title and optional description, image, footer",
|
|
641
|
+
schema: '{"title": "string", "description?": "string", "image?": "url", "footer?": "string"}',
|
|
642
|
+
example: '@ui:card[{"title": "Summary", "description": "Key findings from the analysis"}]'
|
|
643
|
+
},
|
|
644
|
+
list: {
|
|
645
|
+
description: "Displays a list of items with title, subtitle, and optional description",
|
|
646
|
+
schema: '{"items": [{"id": "string", "title": "string", "subtitle?": "string", "description?": "string", "image?": "url"}]}',
|
|
647
|
+
example: '@ui:list[{"items": [{"id": "1", "title": "First item", "subtitle": "Details"}]}]'
|
|
648
|
+
},
|
|
649
|
+
button_group: {
|
|
650
|
+
description: "Displays action buttons. User clicks are sent back to you with the button id",
|
|
651
|
+
schema: '{"buttons": [{"id": "string", "label": "string", "variant?": "primary|secondary|outline"}], "layout?": "horizontal|vertical"}',
|
|
652
|
+
example: '@ui:button_group[{"buttons": [{"id": "confirm", "label": "Confirm", "variant": "primary"}, {"id": "cancel", "label": "Cancel"}]}]'
|
|
653
|
+
},
|
|
654
|
+
form: {
|
|
655
|
+
description: "Displays an input form. Submitted data is sent back to you",
|
|
656
|
+
schema: '{"title?": "string", "fields": [{"name": "string", "type": "text|number|select|checkbox|textarea|date", "label": "string", "required?": boolean, "placeholder?": "string", "options?": [{"label": "string", "value": "string"}]}]}',
|
|
657
|
+
example: '@ui:form[{"title": "Contact", "fields": [{"name": "email", "type": "text", "label": "Email", "required": true}]}]'
|
|
658
|
+
},
|
|
659
|
+
image: {
|
|
660
|
+
description: "Displays a single image with optional caption",
|
|
661
|
+
schema: '{"src": "url", "alt": "string", "caption?": "string"}',
|
|
662
|
+
example: '@ui:image[{"src": "https://example.com/img.png", "alt": "Description", "caption": "Figure 1"}]'
|
|
663
|
+
},
|
|
664
|
+
gallery: {
|
|
665
|
+
description: "Displays multiple images in a grid or carousel layout",
|
|
666
|
+
schema: '{"images": [{"id": "string", "src": "url", "alt": "string", "caption?": "string"}], "layout?": "grid|carousel"}',
|
|
667
|
+
example: '@ui:gallery[{"images": [{"id": "1", "src": "https://example.com/1.png", "alt": "Image 1"}], "layout": "grid"}]'
|
|
668
|
+
},
|
|
669
|
+
chart: {
|
|
670
|
+
description: "Displays a chart visualization (line, bar, pie, doughnut)",
|
|
671
|
+
schema: '{"chartType": "line|bar|pie|doughnut", "title?": "string", "data": {"labels": ["string"], "datasets": [{"label": "string", "data": [number], "backgroundColor?": "string|string[]"}]}}',
|
|
672
|
+
example: '@ui:chart[{"chartType": "bar", "title": "Sales", "data": {"labels": ["Q1", "Q2"], "datasets": [{"label": "Revenue", "data": [100, 150]}]}}]'
|
|
673
|
+
},
|
|
674
|
+
map: {
|
|
675
|
+
description: "Displays an interactive map with optional markers",
|
|
676
|
+
schema: '{"center": {"lat": number, "lng": number}, "zoom?": number, "markers?": [{"id": "string", "position": {"lat": number, "lng": number}, "title": "string"}]}',
|
|
677
|
+
example: '@ui:map[{"center": {"lat": 40.7128, "lng": -74.0060}, "zoom": 12, "markers": [{"id": "1", "position": {"lat": 40.7128, "lng": -74.0060}, "title": "NYC"}]}]'
|
|
678
|
+
},
|
|
679
|
+
table: {
|
|
680
|
+
description: "Displays structured data in rows and columns",
|
|
681
|
+
schema: '{"columns": [{"key": "string", "label": "string", "align?": "left|center|right"}], "rows": [{"id?": "string", ...}], "caption?": "string", "compact?": boolean, "striped?": boolean}',
|
|
682
|
+
example: '@ui:table[{"columns": [{"key": "name", "label": "Name"}, {"key": "status", "label": "Status"}], "rows": [{"name": "Item 1", "status": "Active"}, {"name": "Item 2", "status": "Pending"}]}]'
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
var ALL_WIDGET_TYPES = Object.keys(WIDGET_DEFINITIONS);
|
|
686
|
+
function generateWidgetContext(enabledWidgets) {
|
|
687
|
+
const widgets = enabledWidgets || ALL_WIDGET_TYPES;
|
|
688
|
+
let context = `
|
|
689
|
+
## Available UI Widgets
|
|
690
|
+
|
|
691
|
+
`;
|
|
692
|
+
context += `You can render rich UI components in your responses using this syntax: @ui:type[{json_props}]
|
|
693
|
+
|
|
694
|
+
`;
|
|
695
|
+
context += `The widget syntax will be automatically converted to interactive UI. Users see the rendered widget, not the raw syntax.
|
|
696
|
+
|
|
697
|
+
`;
|
|
698
|
+
context += `### Available widgets:
|
|
699
|
+
|
|
700
|
+
`;
|
|
701
|
+
for (const type of widgets) {
|
|
702
|
+
const def = WIDGET_DEFINITIONS[type];
|
|
703
|
+
if (!def) continue;
|
|
704
|
+
context += `**${type}** - ${def.description}
|
|
705
|
+
`;
|
|
706
|
+
context += `Schema: \`${def.schema}\`
|
|
707
|
+
`;
|
|
708
|
+
context += `Example: \`${def.example}\`
|
|
709
|
+
|
|
710
|
+
`;
|
|
711
|
+
}
|
|
712
|
+
context += `### Important notes:
|
|
713
|
+
`;
|
|
714
|
+
context += `- JSON must be valid (use double quotes for strings)
|
|
715
|
+
`;
|
|
716
|
+
context += `- Widget actions (button clicks, form submissions) are sent back to you
|
|
717
|
+
`;
|
|
718
|
+
context += `- You can include multiple widgets in a single response
|
|
719
|
+
`;
|
|
720
|
+
context += `- Combine widgets with regular text for context
|
|
721
|
+
`;
|
|
722
|
+
return context;
|
|
723
|
+
}
|
|
724
|
+
function generateCompactWidgetContext(enabledWidgets) {
|
|
725
|
+
const widgets = enabledWidgets || ALL_WIDGET_TYPES;
|
|
726
|
+
let context = `
|
|
727
|
+
UI Widgets: Use @ui:type[{props}] syntax.
|
|
728
|
+
`;
|
|
729
|
+
context += `Available: ${widgets.join(", ")}
|
|
730
|
+
`;
|
|
731
|
+
context += `Examples:
|
|
732
|
+
`;
|
|
733
|
+
const examples = ["card", "list", "button_group"].filter((w) => widgets.includes(w));
|
|
734
|
+
for (const type of examples) {
|
|
735
|
+
const def = WIDGET_DEFINITIONS[type];
|
|
736
|
+
if (def) {
|
|
737
|
+
context += `${def.example}
|
|
738
|
+
`;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
return context;
|
|
742
|
+
}
|
|
743
|
+
|
|
501
744
|
// src/components/Widgets/Widgets.tsx
|
|
502
745
|
import { useEffect } from "react";
|
|
503
746
|
|
|
@@ -642,31 +885,109 @@ function ButtonGroup({ widget, onAction }) {
|
|
|
642
885
|
);
|
|
643
886
|
}
|
|
644
887
|
|
|
645
|
-
// src/components/Widgets/
|
|
888
|
+
// src/components/Widgets/widget-library/Table.tsx
|
|
646
889
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
890
|
+
function Table({ widget, onAction }) {
|
|
891
|
+
const { columns, rows, caption, compact = false, striped = false } = widget.props;
|
|
892
|
+
const getAlignment = (align) => {
|
|
893
|
+
switch (align) {
|
|
894
|
+
case "center":
|
|
895
|
+
return "text-center";
|
|
896
|
+
case "right":
|
|
897
|
+
return "text-right";
|
|
898
|
+
default:
|
|
899
|
+
return "text-left";
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
return /* @__PURE__ */ jsx5("div", { className: "border border-gray-200 dark:border-gray-700 rounded-xl bg-white dark:bg-gray-900 overflow-hidden", children: /* @__PURE__ */ jsx5("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs3("table", { className: "w-full", children: [
|
|
903
|
+
caption && /* @__PURE__ */ jsx5("caption", { className: "px-4 py-2 text-sm text-gray-600 dark:text-gray-400 text-left bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700", children: caption }),
|
|
904
|
+
/* @__PURE__ */ jsx5("thead", { children: /* @__PURE__ */ jsx5("tr", { className: "bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700", children: columns.map((column) => /* @__PURE__ */ jsx5(
|
|
905
|
+
"th",
|
|
906
|
+
{
|
|
907
|
+
className: cn(
|
|
908
|
+
"font-semibold text-gray-900 dark:text-white",
|
|
909
|
+
compact ? "px-3 py-2 text-xs" : "px-4 py-3 text-sm",
|
|
910
|
+
getAlignment(column.align)
|
|
911
|
+
),
|
|
912
|
+
style: column.width ? { width: column.width } : void 0,
|
|
913
|
+
children: column.label
|
|
914
|
+
},
|
|
915
|
+
column.key
|
|
916
|
+
)) }) }),
|
|
917
|
+
/* @__PURE__ */ jsxs3("tbody", { children: [
|
|
918
|
+
rows.map((row, rowIndex) => /* @__PURE__ */ jsx5(
|
|
919
|
+
"tr",
|
|
920
|
+
{
|
|
921
|
+
className: cn(
|
|
922
|
+
"border-b border-gray-200 dark:border-gray-700 last:border-b-0",
|
|
923
|
+
"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800",
|
|
924
|
+
striped && rowIndex % 2 === 1 && "bg-gray-50/50 dark:bg-gray-800/50"
|
|
925
|
+
),
|
|
926
|
+
onClick: () => {
|
|
927
|
+
if (widget.actions && widget.actions.length > 0) {
|
|
928
|
+
onAction?.({
|
|
929
|
+
type: widget.actions[0].type,
|
|
930
|
+
payload: row,
|
|
931
|
+
widgetId: widget.id,
|
|
932
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
},
|
|
936
|
+
style: { cursor: widget.actions?.length ? "pointer" : "default" },
|
|
937
|
+
children: columns.map((column) => /* @__PURE__ */ jsx5(
|
|
938
|
+
"td",
|
|
939
|
+
{
|
|
940
|
+
className: cn(
|
|
941
|
+
"text-gray-700 dark:text-gray-300",
|
|
942
|
+
compact ? "px-3 py-2 text-xs" : "px-4 py-3 text-sm",
|
|
943
|
+
getAlignment(column.align)
|
|
944
|
+
),
|
|
945
|
+
children: row[column.key] ?? "\u2014"
|
|
946
|
+
},
|
|
947
|
+
column.key
|
|
948
|
+
))
|
|
949
|
+
},
|
|
950
|
+
row.id || rowIndex
|
|
951
|
+
)),
|
|
952
|
+
rows.length === 0 && /* @__PURE__ */ jsx5("tr", { children: /* @__PURE__ */ jsx5(
|
|
953
|
+
"td",
|
|
954
|
+
{
|
|
955
|
+
colSpan: columns.length,
|
|
956
|
+
className: "px-4 py-8 text-center text-sm text-gray-500 dark:text-gray-400",
|
|
957
|
+
children: "No data available"
|
|
958
|
+
}
|
|
959
|
+
) })
|
|
960
|
+
] })
|
|
961
|
+
] }) }) });
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// src/components/Widgets/WidgetRenderer.tsx
|
|
965
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
647
966
|
function WidgetRenderer({ widget, onAction }) {
|
|
648
967
|
switch (widget.type) {
|
|
649
968
|
case "card":
|
|
650
|
-
return /* @__PURE__ */
|
|
969
|
+
return /* @__PURE__ */ jsx6(Card, { widget, onAction });
|
|
651
970
|
case "list":
|
|
652
|
-
return /* @__PURE__ */
|
|
971
|
+
return /* @__PURE__ */ jsx6(List, { widget, onAction });
|
|
653
972
|
case "button":
|
|
654
|
-
return /* @__PURE__ */
|
|
973
|
+
return /* @__PURE__ */ jsx6(Button, { widget, onAction });
|
|
655
974
|
case "button_group":
|
|
656
|
-
return /* @__PURE__ */
|
|
975
|
+
return /* @__PURE__ */ jsx6(ButtonGroup, { widget, onAction });
|
|
976
|
+
case "table":
|
|
977
|
+
return /* @__PURE__ */ jsx6(Table, { widget, onAction });
|
|
657
978
|
default:
|
|
658
|
-
return /* @__PURE__ */
|
|
659
|
-
/* @__PURE__ */
|
|
979
|
+
return /* @__PURE__ */ jsxs4("div", { className: "p-4 border border-yellow-300 bg-yellow-50 rounded-lg", children: [
|
|
980
|
+
/* @__PURE__ */ jsxs4("p", { className: "text-sm text-yellow-800", children: [
|
|
660
981
|
"Unknown widget type: ",
|
|
661
982
|
widget.type
|
|
662
983
|
] }),
|
|
663
|
-
/* @__PURE__ */
|
|
984
|
+
/* @__PURE__ */ jsx6("pre", { className: "text-xs mt-2 overflow-auto", children: JSON.stringify(widget, null, 2) })
|
|
664
985
|
] });
|
|
665
986
|
}
|
|
666
987
|
}
|
|
667
988
|
|
|
668
989
|
// src/components/Widgets/Widgets.tsx
|
|
669
|
-
import { jsx as
|
|
990
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
670
991
|
function Widgets({
|
|
671
992
|
widgets,
|
|
672
993
|
onAction,
|
|
@@ -691,22 +1012,150 @@ function Widgets({
|
|
|
691
1012
|
normal: "gap-4",
|
|
692
1013
|
loose: "gap-6"
|
|
693
1014
|
};
|
|
694
|
-
return /* @__PURE__ */
|
|
1015
|
+
return /* @__PURE__ */ jsx7("div", { className: cn(layoutClasses[layout], spacingClasses[spacing], className), children: widgets.map((widget) => /* @__PURE__ */ jsx7(WidgetRenderer, { widget, onAction }, widget.id)) });
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// src/components/Widgets/WidgetSkeleton.tsx
|
|
1019
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1020
|
+
function WidgetSkeleton({ type, className }) {
|
|
1021
|
+
switch (type) {
|
|
1022
|
+
case "card":
|
|
1023
|
+
return /* @__PURE__ */ jsx8("div", { className: cn("animate-pulse rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden", className), children: /* @__PURE__ */ jsxs5("div", { className: "p-4 space-y-3", children: [
|
|
1024
|
+
/* @__PURE__ */ jsx8("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4" }),
|
|
1025
|
+
/* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-full" }),
|
|
1026
|
+
/* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-5/6" })
|
|
1027
|
+
] }) });
|
|
1028
|
+
case "list":
|
|
1029
|
+
return /* @__PURE__ */ jsx8("div", { className: cn("animate-pulse space-y-2", className), children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 p-3 rounded-lg border border-gray-200 dark:border-gray-700", children: [
|
|
1030
|
+
/* @__PURE__ */ jsx8("div", { className: "w-10 h-10 bg-gray-200 dark:bg-gray-700 rounded-full flex-shrink-0" }),
|
|
1031
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex-1 space-y-2", children: [
|
|
1032
|
+
/* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-1/2" }),
|
|
1033
|
+
/* @__PURE__ */ jsx8("div", { className: "h-2 bg-gray-200 dark:bg-gray-700 rounded w-3/4" })
|
|
1034
|
+
] })
|
|
1035
|
+
] }, i)) });
|
|
1036
|
+
case "button_group":
|
|
1037
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("animate-pulse flex gap-2", className), children: [
|
|
1038
|
+
/* @__PURE__ */ jsx8("div", { className: "h-9 bg-gray-200 dark:bg-gray-700 rounded-lg w-20" }),
|
|
1039
|
+
/* @__PURE__ */ jsx8("div", { className: "h-9 bg-gray-200 dark:bg-gray-700 rounded-lg w-20" }),
|
|
1040
|
+
/* @__PURE__ */ jsx8("div", { className: "h-9 bg-gray-200 dark:bg-gray-700 rounded-lg w-20" })
|
|
1041
|
+
] });
|
|
1042
|
+
case "form":
|
|
1043
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("animate-pulse rounded-lg border border-gray-200 dark:border-gray-700 p-4 space-y-4", className), children: [
|
|
1044
|
+
/* @__PURE__ */ jsx8("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/3" }),
|
|
1045
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-3", children: [
|
|
1046
|
+
/* @__PURE__ */ jsx8("div", { className: "h-10 bg-gray-200 dark:bg-gray-700 rounded" }),
|
|
1047
|
+
/* @__PURE__ */ jsx8("div", { className: "h-10 bg-gray-200 dark:bg-gray-700 rounded" })
|
|
1048
|
+
] }),
|
|
1049
|
+
/* @__PURE__ */ jsx8("div", { className: "h-9 bg-gray-200 dark:bg-gray-700 rounded w-24" })
|
|
1050
|
+
] });
|
|
1051
|
+
case "chart":
|
|
1052
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("animate-pulse rounded-lg border border-gray-200 dark:border-gray-700 p-4", className), children: [
|
|
1053
|
+
/* @__PURE__ */ jsx8("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/4 mb-4" }),
|
|
1054
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-end gap-2 h-32", children: [
|
|
1055
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-1/2" }),
|
|
1056
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-3/4" }),
|
|
1057
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-1/3" }),
|
|
1058
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-full" }),
|
|
1059
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-2/3" })
|
|
1060
|
+
] })
|
|
1061
|
+
] });
|
|
1062
|
+
case "image":
|
|
1063
|
+
return /* @__PURE__ */ jsx8("div", { className: cn("animate-pulse", className), children: /* @__PURE__ */ jsx8("div", { className: "aspect-video bg-gray-200 dark:bg-gray-700 rounded-lg" }) });
|
|
1064
|
+
case "gallery":
|
|
1065
|
+
return /* @__PURE__ */ jsx8("div", { className: cn("animate-pulse grid grid-cols-3 gap-2", className), children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx8("div", { className: "aspect-square bg-gray-200 dark:bg-gray-700 rounded-lg" }, i)) });
|
|
1066
|
+
case "map":
|
|
1067
|
+
return /* @__PURE__ */ jsx8("div", { className: cn("animate-pulse", className), children: /* @__PURE__ */ jsx8("div", { className: "h-48 bg-gray-200 dark:bg-gray-700 rounded-lg flex items-center justify-center", children: /* @__PURE__ */ jsxs5("svg", { className: "w-8 h-8 text-gray-300 dark:text-gray-600", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: [
|
|
1068
|
+
/* @__PURE__ */ jsx8("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" }),
|
|
1069
|
+
/* @__PURE__ */ jsx8("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z" })
|
|
1070
|
+
] }) }) });
|
|
1071
|
+
case "table":
|
|
1072
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("animate-pulse rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden", className), children: [
|
|
1073
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex bg-gray-100 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700", children: [
|
|
1074
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-300 dark:bg-gray-600 rounded w-16" }) }),
|
|
1075
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-300 dark:bg-gray-600 rounded w-20" }) }),
|
|
1076
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-300 dark:bg-gray-600 rounded w-14" }) })
|
|
1077
|
+
] }),
|
|
1078
|
+
[1, 2, 3].map((i) => /* @__PURE__ */ jsxs5("div", { className: "flex border-b border-gray-200 dark:border-gray-700 last:border-b-0", children: [
|
|
1079
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-24" }) }),
|
|
1080
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-16" }) }),
|
|
1081
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-20" }) })
|
|
1082
|
+
] }, i))
|
|
1083
|
+
] });
|
|
1084
|
+
default:
|
|
1085
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("animate-pulse rounded-lg border border-gray-200 dark:border-gray-700 p-4", className), children: [
|
|
1086
|
+
/* @__PURE__ */ jsx8("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/2 mb-2" }),
|
|
1087
|
+
/* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-full" })
|
|
1088
|
+
] });
|
|
1089
|
+
}
|
|
695
1090
|
}
|
|
696
1091
|
|
|
697
1092
|
// src/components/Chat/MarkdownContent.tsx
|
|
698
|
-
import { jsx as
|
|
1093
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1094
|
+
function isImageUrl(url) {
|
|
1095
|
+
const imageExtensions = /\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)(\?.*)?$/i;
|
|
1096
|
+
return imageExtensions.test(url);
|
|
1097
|
+
}
|
|
699
1098
|
function parseInlineMarkdown(text, keyPrefix = "") {
|
|
700
1099
|
const result = [];
|
|
701
|
-
const
|
|
1100
|
+
const inlineRegex = /!\[([^\]]*)\]\(([^)]+)\)|\[([^\]]+)\]\(([^)]+)\)|(\*\*|__)(.+?)\5|`([^`]+)`/g;
|
|
702
1101
|
let lastIndex = 0;
|
|
703
1102
|
let match;
|
|
704
1103
|
let key = 0;
|
|
705
|
-
while ((match =
|
|
1104
|
+
while ((match = inlineRegex.exec(text)) !== null) {
|
|
706
1105
|
if (match.index > lastIndex) {
|
|
707
1106
|
result.push(text.slice(lastIndex, match.index));
|
|
708
1107
|
}
|
|
709
|
-
|
|
1108
|
+
if (match[1] !== void 0 || match[2] !== void 0) {
|
|
1109
|
+
const alt = match[1] || "";
|
|
1110
|
+
const src = match[2];
|
|
1111
|
+
result.push(
|
|
1112
|
+
/* @__PURE__ */ jsx9(
|
|
1113
|
+
"img",
|
|
1114
|
+
{
|
|
1115
|
+
src,
|
|
1116
|
+
alt,
|
|
1117
|
+
className: "apteva-md-img"
|
|
1118
|
+
},
|
|
1119
|
+
`${keyPrefix}img${key++}`
|
|
1120
|
+
)
|
|
1121
|
+
);
|
|
1122
|
+
} else if (match[3] !== void 0 || match[4] !== void 0) {
|
|
1123
|
+
const linkText = match[3];
|
|
1124
|
+
const href = match[4];
|
|
1125
|
+
if (isImageUrl(href)) {
|
|
1126
|
+
result.push(
|
|
1127
|
+
/* @__PURE__ */ jsx9(
|
|
1128
|
+
"img",
|
|
1129
|
+
{
|
|
1130
|
+
src: href,
|
|
1131
|
+
alt: linkText,
|
|
1132
|
+
className: "apteva-md-img"
|
|
1133
|
+
},
|
|
1134
|
+
`${keyPrefix}img${key++}`
|
|
1135
|
+
)
|
|
1136
|
+
);
|
|
1137
|
+
} else {
|
|
1138
|
+
result.push(
|
|
1139
|
+
/* @__PURE__ */ jsx9(
|
|
1140
|
+
"a",
|
|
1141
|
+
{
|
|
1142
|
+
href,
|
|
1143
|
+
target: "_blank",
|
|
1144
|
+
rel: "noopener noreferrer",
|
|
1145
|
+
className: "apteva-md-link",
|
|
1146
|
+
children: linkText
|
|
1147
|
+
},
|
|
1148
|
+
`${keyPrefix}a${key++}`
|
|
1149
|
+
)
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
} else if (match[5] !== void 0) {
|
|
1153
|
+
result.push(/* @__PURE__ */ jsx9("strong", { children: match[6] }, `${keyPrefix}b${key++}`));
|
|
1154
|
+
} else if (match[7] !== void 0) {
|
|
1155
|
+
result.push(
|
|
1156
|
+
/* @__PURE__ */ jsx9("code", { className: "apteva-md-inline-code", children: match[7] }, `${keyPrefix}code${key++}`)
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
710
1159
|
lastIndex = match.index + match[0].length;
|
|
711
1160
|
}
|
|
712
1161
|
if (lastIndex < text.length) {
|
|
@@ -724,7 +1173,7 @@ function parseMarkdown(content) {
|
|
|
724
1173
|
const h2Match = line.match(/^##\s+(.*)$/);
|
|
725
1174
|
if (h2Match) {
|
|
726
1175
|
result.push(
|
|
727
|
-
/* @__PURE__ */
|
|
1176
|
+
/* @__PURE__ */ jsx9("h2", { className: "apteva-md-h2", children: parseInlineMarkdown(h2Match[1], `${key}`) }, `h2${key++}`)
|
|
728
1177
|
);
|
|
729
1178
|
i++;
|
|
730
1179
|
continue;
|
|
@@ -732,7 +1181,7 @@ function parseMarkdown(content) {
|
|
|
732
1181
|
const h3Match = line.match(/^###\s+(.*)$/);
|
|
733
1182
|
if (h3Match) {
|
|
734
1183
|
result.push(
|
|
735
|
-
/* @__PURE__ */
|
|
1184
|
+
/* @__PURE__ */ jsx9("h3", { className: "apteva-md-h3", children: parseInlineMarkdown(h3Match[1], `${key}`) }, `h3${key++}`)
|
|
736
1185
|
);
|
|
737
1186
|
i++;
|
|
738
1187
|
continue;
|
|
@@ -745,7 +1194,7 @@ function parseMarkdown(content) {
|
|
|
745
1194
|
const itemMatch = lines[i].match(/^(\s*)([-*+])\s+(.*)$/);
|
|
746
1195
|
if (itemMatch && itemMatch[1].length === indent) {
|
|
747
1196
|
listItems.push(
|
|
748
|
-
/* @__PURE__ */
|
|
1197
|
+
/* @__PURE__ */ jsx9("li", { className: "apteva-md-li", children: parseInlineMarkdown(itemMatch[3], `${key}`) }, `li${key++}`)
|
|
749
1198
|
);
|
|
750
1199
|
i++;
|
|
751
1200
|
} else {
|
|
@@ -753,7 +1202,7 @@ function parseMarkdown(content) {
|
|
|
753
1202
|
}
|
|
754
1203
|
}
|
|
755
1204
|
result.push(
|
|
756
|
-
/* @__PURE__ */
|
|
1205
|
+
/* @__PURE__ */ jsx9("ul", { className: "apteva-md-ul", children: listItems }, `ul${key++}`)
|
|
757
1206
|
);
|
|
758
1207
|
continue;
|
|
759
1208
|
}
|
|
@@ -765,7 +1214,7 @@ function parseMarkdown(content) {
|
|
|
765
1214
|
const itemMatch = lines[i].match(/^(\s*)(\d+)\.\s+(.*)$/);
|
|
766
1215
|
if (itemMatch && itemMatch[1].length === indent) {
|
|
767
1216
|
listItems.push(
|
|
768
|
-
/* @__PURE__ */
|
|
1217
|
+
/* @__PURE__ */ jsx9("li", { className: "apteva-md-li", children: parseInlineMarkdown(itemMatch[3], `${key}`) }, `li${key++}`)
|
|
769
1218
|
);
|
|
770
1219
|
i++;
|
|
771
1220
|
} else {
|
|
@@ -773,14 +1222,14 @@ function parseMarkdown(content) {
|
|
|
773
1222
|
}
|
|
774
1223
|
}
|
|
775
1224
|
result.push(
|
|
776
|
-
/* @__PURE__ */
|
|
1225
|
+
/* @__PURE__ */ jsx9("ol", { className: "apteva-md-ol", children: listItems }, `ol${key++}`)
|
|
777
1226
|
);
|
|
778
1227
|
continue;
|
|
779
1228
|
}
|
|
780
1229
|
const tableMatch = line.match(/^\|(.+)\|$/);
|
|
781
1230
|
if (tableMatch && i + 1 < lines.length) {
|
|
782
1231
|
const separatorLine = lines[i + 1];
|
|
783
|
-
const separatorMatch = separatorLine.match(/^\|[\s:-]
|
|
1232
|
+
const separatorMatch = separatorLine.match(/^\|([\s:-]+\|)+$/);
|
|
784
1233
|
if (separatorMatch) {
|
|
785
1234
|
const headerCells = line.split("|").filter((cell) => cell.trim() !== "").map((cell) => cell.trim());
|
|
786
1235
|
i += 2;
|
|
@@ -796,19 +1245,19 @@ function parseMarkdown(content) {
|
|
|
796
1245
|
}
|
|
797
1246
|
}
|
|
798
1247
|
result.push(
|
|
799
|
-
/* @__PURE__ */
|
|
800
|
-
/* @__PURE__ */
|
|
801
|
-
/* @__PURE__ */
|
|
1248
|
+
/* @__PURE__ */ jsx9("div", { className: "apteva-md-table-wrapper", children: /* @__PURE__ */ jsxs6("table", { className: "apteva-md-table", children: [
|
|
1249
|
+
/* @__PURE__ */ jsx9("thead", { children: /* @__PURE__ */ jsx9("tr", { children: headerCells.map((cell, idx) => /* @__PURE__ */ jsx9("th", { className: "apteva-md-th", children: parseInlineMarkdown(cell, `th${key}${idx}`) }, `th${idx}`)) }) }),
|
|
1250
|
+
/* @__PURE__ */ jsx9("tbody", { children: bodyRows.map((row, rowIdx) => /* @__PURE__ */ jsx9("tr", { children: row.map((cell, cellIdx) => /* @__PURE__ */ jsx9("td", { className: "apteva-md-td", children: parseInlineMarkdown(cell, `td${key}${rowIdx}${cellIdx}`) }, `td${cellIdx}`)) }, `tr${rowIdx}`)) })
|
|
802
1251
|
] }) }, `table-wrapper${key++}`)
|
|
803
1252
|
);
|
|
804
1253
|
continue;
|
|
805
1254
|
}
|
|
806
1255
|
}
|
|
807
1256
|
if (line === "") {
|
|
808
|
-
result.push(/* @__PURE__ */
|
|
1257
|
+
result.push(/* @__PURE__ */ jsx9("br", {}, `br${key++}`));
|
|
809
1258
|
} else {
|
|
810
1259
|
result.push(
|
|
811
|
-
/* @__PURE__ */
|
|
1260
|
+
/* @__PURE__ */ jsxs6("span", { children: [
|
|
812
1261
|
parseInlineMarkdown(line, `${key}`),
|
|
813
1262
|
i < lines.length - 1 ? "\n" : ""
|
|
814
1263
|
] }, `p${key++}`)
|
|
@@ -819,38 +1268,116 @@ function parseMarkdown(content) {
|
|
|
819
1268
|
return result;
|
|
820
1269
|
}
|
|
821
1270
|
function MarkdownContent({ content, className = "" }) {
|
|
822
|
-
return /* @__PURE__ */
|
|
1271
|
+
return /* @__PURE__ */ jsx9("div", { className: `apteva-md ${className}`, children: parseMarkdown(content) });
|
|
823
1272
|
}
|
|
824
1273
|
|
|
825
1274
|
// src/components/Chat/ToolCall.tsx
|
|
826
|
-
import { jsx as
|
|
1275
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
827
1276
|
function ToolCall({ name, status }) {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1277
|
+
if (status === "running") {
|
|
1278
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2 px-3 py-2 rounded-xl bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700 !text-blue-700 dark:!text-blue-300 text-sm", children: [
|
|
1279
|
+
/* @__PURE__ */ jsxs7("svg", { className: "w-4 h-4 animate-spin", fill: "none", viewBox: "0 0 24 24", children: [
|
|
1280
|
+
/* @__PURE__ */ jsx10("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
1281
|
+
/* @__PURE__ */ jsx10("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
1282
|
+
] }),
|
|
1283
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
1284
|
+
"Calling ",
|
|
1285
|
+
/* @__PURE__ */ jsx10("strong", { children: name }),
|
|
1286
|
+
"..."
|
|
1287
|
+
] })
|
|
1288
|
+
] });
|
|
1289
|
+
}
|
|
1290
|
+
if (status === "completed") {
|
|
1291
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2 px-3 py-2 rounded-xl bg-green-50 dark:bg-green-900/30 border border-green-200 dark:border-green-700 !text-green-700 dark:!text-green-300 text-sm", children: [
|
|
1292
|
+
/* @__PURE__ */ jsx10("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx10("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }),
|
|
1293
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
1294
|
+
"Tool completed: ",
|
|
1295
|
+
/* @__PURE__ */ jsx10("strong", { children: name })
|
|
1296
|
+
] })
|
|
1297
|
+
] });
|
|
1298
|
+
}
|
|
1299
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2 px-3 py-2 rounded-xl bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 !text-red-700 dark:!text-red-300 text-sm", children: [
|
|
1300
|
+
/* @__PURE__ */ jsx10("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx10("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }),
|
|
1301
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
1302
|
+
"Tool failed: ",
|
|
1303
|
+
/* @__PURE__ */ jsx10("strong", { children: name })
|
|
1304
|
+
] })
|
|
836
1305
|
] });
|
|
837
1306
|
}
|
|
838
1307
|
|
|
839
1308
|
// src/components/Chat/Message.tsx
|
|
840
|
-
import { jsx as
|
|
841
|
-
function Message({ message, onAction }) {
|
|
1309
|
+
import { Fragment, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1310
|
+
function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
842
1311
|
const isUser = message.role === "user";
|
|
843
1312
|
const contentSegments = message.metadata?.content_segments;
|
|
1313
|
+
const isStreaming = message.metadata?.isStreaming === true;
|
|
1314
|
+
const hasContent = message.content || contentSegments && contentSegments.length > 0;
|
|
1315
|
+
const reportedWidgetsRef = useRef(/* @__PURE__ */ new Set());
|
|
1316
|
+
const parsedWidgets = useMemo(() => {
|
|
1317
|
+
if (!enableWidgets || isUser || !message.content) {
|
|
1318
|
+
return [];
|
|
1319
|
+
}
|
|
1320
|
+
const parsed = parseWidgetsFromText(message.content);
|
|
1321
|
+
return parsed.segments.filter((seg) => seg.type === "widget" && !!seg.widget).map((seg) => seg.widget);
|
|
1322
|
+
}, [enableWidgets, isUser, message.content]);
|
|
1323
|
+
useEffect2(() => {
|
|
1324
|
+
if (onWidgetRender && message.widgets) {
|
|
1325
|
+
for (const widget of message.widgets) {
|
|
1326
|
+
if (!reportedWidgetsRef.current.has(widget.id)) {
|
|
1327
|
+
reportedWidgetsRef.current.add(widget.id);
|
|
1328
|
+
onWidgetRender(widget);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
}, [message.widgets, onWidgetRender]);
|
|
1333
|
+
useEffect2(() => {
|
|
1334
|
+
if (onWidgetRender && parsedWidgets.length > 0) {
|
|
1335
|
+
for (const widget of parsedWidgets) {
|
|
1336
|
+
if (!reportedWidgetsRef.current.has(widget.id)) {
|
|
1337
|
+
reportedWidgetsRef.current.add(widget.id);
|
|
1338
|
+
onWidgetRender(widget);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
}, [parsedWidgets, onWidgetRender]);
|
|
1343
|
+
const renderTextContent = (text) => {
|
|
1344
|
+
if (!enableWidgets || isUser) {
|
|
1345
|
+
return /* @__PURE__ */ jsx11(MarkdownContent, { content: text });
|
|
1346
|
+
}
|
|
1347
|
+
const parsed = parseWidgetsFromText(text);
|
|
1348
|
+
if (parsed.segments.length === 0) {
|
|
1349
|
+
return null;
|
|
1350
|
+
}
|
|
1351
|
+
return /* @__PURE__ */ jsx11(Fragment, { children: parsed.segments.map((segment, index) => {
|
|
1352
|
+
if (segment.type === "text" && segment.content) {
|
|
1353
|
+
return /* @__PURE__ */ jsx11(MarkdownContent, { content: segment.content }, `text-${index}`);
|
|
1354
|
+
}
|
|
1355
|
+
if (segment.type === "widget" && segment.widget) {
|
|
1356
|
+
return /* @__PURE__ */ jsx11("div", { className: "my-3", children: /* @__PURE__ */ jsx11(WidgetRenderer, { widget: segment.widget, onAction }) }, `widget-${index}`);
|
|
1357
|
+
}
|
|
1358
|
+
if (segment.type === "widget_pending" && segment.pendingType) {
|
|
1359
|
+
return /* @__PURE__ */ jsx11("div", { className: "my-3", children: /* @__PURE__ */ jsx11(WidgetSkeleton, { type: segment.pendingType }) }, `pending-${index}`);
|
|
1360
|
+
}
|
|
1361
|
+
return null;
|
|
1362
|
+
}) });
|
|
1363
|
+
};
|
|
844
1364
|
const renderContent = () => {
|
|
845
1365
|
if (isUser) {
|
|
846
|
-
return /* @__PURE__ */
|
|
1366
|
+
return /* @__PURE__ */ jsx11("div", { className: "whitespace-pre-wrap !text-sm leading-relaxed", children: message.content });
|
|
1367
|
+
}
|
|
1368
|
+
if (isStreaming && !hasContent) {
|
|
1369
|
+
return /* @__PURE__ */ jsxs8("div", { className: "apteva-typing-indicator !text-gray-400", children: [
|
|
1370
|
+
/* @__PURE__ */ jsx11("span", {}),
|
|
1371
|
+
/* @__PURE__ */ jsx11("span", {}),
|
|
1372
|
+
/* @__PURE__ */ jsx11("span", {})
|
|
1373
|
+
] });
|
|
847
1374
|
}
|
|
848
1375
|
if (contentSegments && contentSegments.length > 0) {
|
|
849
|
-
return /* @__PURE__ */
|
|
1376
|
+
return /* @__PURE__ */ jsx11("div", { children: contentSegments.map((segment, index) => {
|
|
850
1377
|
if (segment.type === "text") {
|
|
851
|
-
return segment.content ? /* @__PURE__ */
|
|
1378
|
+
return segment.content ? /* @__PURE__ */ jsx11("div", { children: renderTextContent(segment.content) }, `text-${index}`) : null;
|
|
852
1379
|
} else if (segment.type === "tool") {
|
|
853
|
-
return /* @__PURE__ */
|
|
1380
|
+
return /* @__PURE__ */ jsx11("div", { className: "my-2", children: /* @__PURE__ */ jsx11(
|
|
854
1381
|
ToolCall,
|
|
855
1382
|
{
|
|
856
1383
|
name: segment.name,
|
|
@@ -861,27 +1388,27 @@ function Message({ message, onAction }) {
|
|
|
861
1388
|
return null;
|
|
862
1389
|
}) });
|
|
863
1390
|
}
|
|
864
|
-
return
|
|
1391
|
+
return renderTextContent(message.content);
|
|
865
1392
|
};
|
|
866
|
-
return /* @__PURE__ */
|
|
1393
|
+
return /* @__PURE__ */ jsxs8(
|
|
867
1394
|
"div",
|
|
868
1395
|
{
|
|
869
1396
|
className: cn(
|
|
870
|
-
"max-w-[80%]",
|
|
871
|
-
isUser ? "
|
|
1397
|
+
"max-w-[80%] px-4 py-2.5 rounded-2xl",
|
|
1398
|
+
isUser ? "bg-blue-600 !text-white rounded-br-md" : "bg-gray-100 dark:bg-gray-800 !text-gray-900 dark:!text-gray-100 rounded-bl-md"
|
|
872
1399
|
),
|
|
873
1400
|
children: [
|
|
874
1401
|
renderContent(),
|
|
875
|
-
message.widgets && message.widgets.length > 0 && /* @__PURE__ */
|
|
876
|
-
/* @__PURE__ */
|
|
1402
|
+
message.widgets && message.widgets.length > 0 && /* @__PURE__ */ jsx11("div", { className: cn(isUser ? "mt-3" : "mt-2"), children: /* @__PURE__ */ jsx11(Widgets, { widgets: message.widgets, onAction, layout: "stack" }) }),
|
|
1403
|
+
/* @__PURE__ */ jsx11("div", { className: cn("!text-xs mt-1.5", isUser ? "!text-blue-200" : "!text-gray-500 dark:!text-gray-400"), suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
877
1404
|
]
|
|
878
1405
|
}
|
|
879
1406
|
);
|
|
880
1407
|
}
|
|
881
1408
|
|
|
882
1409
|
// src/components/Chat/WelcomeScreen.tsx
|
|
883
|
-
import { jsx as
|
|
884
|
-
var DefaultIcon = () => /* @__PURE__ */
|
|
1410
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1411
|
+
var DefaultIcon = () => /* @__PURE__ */ jsx12("svg", { className: "w-12 h-12 sm:w-16 sm:h-16", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx12(
|
|
885
1412
|
"path",
|
|
886
1413
|
{
|
|
887
1414
|
strokeLinecap: "round",
|
|
@@ -890,7 +1417,7 @@ var DefaultIcon = () => /* @__PURE__ */ jsx10("svg", { className: "w-12 h-12 sm:
|
|
|
890
1417
|
d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"
|
|
891
1418
|
}
|
|
892
1419
|
) });
|
|
893
|
-
var ArrowIcon = () => /* @__PURE__ */
|
|
1420
|
+
var ArrowIcon = () => /* @__PURE__ */ jsx12("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx12("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 7l5 5m0 0l-5 5m5-5H6" }) });
|
|
894
1421
|
function WelcomeScreen({
|
|
895
1422
|
title,
|
|
896
1423
|
subtitle,
|
|
@@ -905,18 +1432,18 @@ function WelcomeScreen({
|
|
|
905
1432
|
const hasPrompts = normalizedPrompts.length > 0;
|
|
906
1433
|
const hasHeader = title || subtitle || icon;
|
|
907
1434
|
if (!hasHeader && !hasPrompts) {
|
|
908
|
-
return /* @__PURE__ */
|
|
909
|
-
/* @__PURE__ */
|
|
910
|
-
/* @__PURE__ */
|
|
1435
|
+
return /* @__PURE__ */ jsx12("div", { className: "flex items-center justify-center h-full !text-gray-500 dark:!text-gray-400", children: /* @__PURE__ */ jsxs9("div", { className: "text-center space-y-2", children: [
|
|
1436
|
+
/* @__PURE__ */ jsx12("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx12(DefaultIcon, {}) }),
|
|
1437
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm", children: "No messages yet. Start a conversation!" })
|
|
911
1438
|
] }) });
|
|
912
1439
|
}
|
|
913
1440
|
if (variant === "minimal") {
|
|
914
|
-
return /* @__PURE__ */
|
|
915
|
-
hasHeader && /* @__PURE__ */
|
|
916
|
-
title && /* @__PURE__ */
|
|
917
|
-
subtitle && /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex flex-col h-full px-4 py-4", children: [
|
|
1442
|
+
hasHeader && /* @__PURE__ */ jsxs9("div", { className: "mb-4", children: [
|
|
1443
|
+
title && /* @__PURE__ */ jsx12("h2", { className: "text-lg font-semibold !text-gray-900 dark:!text-white", children: title }),
|
|
1444
|
+
subtitle && /* @__PURE__ */ jsx12("p", { className: "text-sm !text-gray-500 dark:!text-gray-400 mt-1", children: subtitle })
|
|
918
1445
|
] }),
|
|
919
|
-
hasPrompts && /* @__PURE__ */
|
|
1446
|
+
hasPrompts && /* @__PURE__ */ jsx12("div", { className: "flex-1 space-y-2", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx12(
|
|
920
1447
|
"button",
|
|
921
1448
|
{
|
|
922
1449
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -929,11 +1456,11 @@ function WelcomeScreen({
|
|
|
929
1456
|
"transition-all duration-200",
|
|
930
1457
|
"group"
|
|
931
1458
|
),
|
|
932
|
-
children: /* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
935
|
-
/* @__PURE__ */
|
|
936
|
-
prompt.description && /* @__PURE__ */
|
|
1459
|
+
children: /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-3", children: [
|
|
1460
|
+
/* @__PURE__ */ jsx12("div", { className: "flex-shrink-0 !text-gray-400 dark:!text-gray-500 group-hover:!text-blue-500 dark:group-hover:!text-blue-400 transition-colors", children: prompt.icon || /* @__PURE__ */ jsx12(ArrowIcon, {}) }),
|
|
1461
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex-1 min-w-0", children: [
|
|
1462
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm font-medium !text-gray-900 dark:!text-white truncate", children: prompt.text }),
|
|
1463
|
+
prompt.description && /* @__PURE__ */ jsx12("p", { className: "text-xs !text-gray-500 dark:!text-gray-400 mt-0.5 truncate", children: prompt.description })
|
|
937
1464
|
] })
|
|
938
1465
|
] })
|
|
939
1466
|
},
|
|
@@ -941,14 +1468,14 @@ function WelcomeScreen({
|
|
|
941
1468
|
)) })
|
|
942
1469
|
] });
|
|
943
1470
|
}
|
|
944
|
-
return /* @__PURE__ */
|
|
945
|
-
/* @__PURE__ */
|
|
946
|
-
/* @__PURE__ */
|
|
947
|
-
title && /* @__PURE__ */
|
|
948
|
-
subtitle && /* @__PURE__ */
|
|
1471
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex flex-col items-center justify-center h-full px-4 py-6 sm:py-8", children: [
|
|
1472
|
+
/* @__PURE__ */ jsxs9("div", { className: "text-center mb-6 sm:mb-8 max-w-md", children: [
|
|
1473
|
+
/* @__PURE__ */ jsx12("div", { className: "mb-4 !text-gray-400 dark:!text-gray-500 flex justify-center", children: icon || /* @__PURE__ */ jsx12(DefaultIcon, {}) }),
|
|
1474
|
+
title && /* @__PURE__ */ jsx12("h1", { className: "text-xl sm:text-2xl font-semibold !text-gray-900 dark:!text-white mb-2", children: title }),
|
|
1475
|
+
subtitle && /* @__PURE__ */ jsx12("p", { className: "text-sm sm:text-base !text-gray-500 dark:!text-gray-400", children: subtitle })
|
|
949
1476
|
] }),
|
|
950
|
-
hasPrompts && /* @__PURE__ */
|
|
951
|
-
/* @__PURE__ */
|
|
1477
|
+
hasPrompts && /* @__PURE__ */ jsxs9("div", { className: "w-full max-w-2xl", children: [
|
|
1478
|
+
/* @__PURE__ */ jsx12("div", { className: "sm:hidden space-y-2", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx12(
|
|
952
1479
|
"button",
|
|
953
1480
|
{
|
|
954
1481
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -963,20 +1490,20 @@ function WelcomeScreen({
|
|
|
963
1490
|
"shadow-sm hover:shadow",
|
|
964
1491
|
"group"
|
|
965
1492
|
),
|
|
966
|
-
children: /* @__PURE__ */
|
|
967
|
-
/* @__PURE__ */
|
|
968
|
-
/* @__PURE__ */
|
|
969
|
-
/* @__PURE__ */
|
|
970
|
-
prompt.description && /* @__PURE__ */
|
|
1493
|
+
children: /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-3", children: [
|
|
1494
|
+
/* @__PURE__ */ jsx12("div", { className: "flex-shrink-0 w-8 h-8 rounded-lg bg-gray-100 dark:bg-gray-700 flex items-center justify-center !text-gray-500 dark:!text-gray-400 group-hover:bg-blue-100 dark:group-hover:bg-blue-900/30 group-hover:!text-blue-600 dark:group-hover:!text-blue-400 transition-colors", children: prompt.icon || /* @__PURE__ */ jsx12(ArrowIcon, {}) }),
|
|
1495
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex-1 min-w-0", children: [
|
|
1496
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm font-medium !text-gray-900 dark:!text-white", children: prompt.text }),
|
|
1497
|
+
prompt.description && /* @__PURE__ */ jsx12("p", { className: "text-xs !text-gray-500 dark:!text-gray-400 mt-0.5 line-clamp-1", children: prompt.description })
|
|
971
1498
|
] }),
|
|
972
|
-
/* @__PURE__ */
|
|
1499
|
+
/* @__PURE__ */ jsx12(
|
|
973
1500
|
"svg",
|
|
974
1501
|
{
|
|
975
1502
|
className: "w-4 h-4 !text-gray-400 group-hover:!text-blue-500 transition-colors flex-shrink-0",
|
|
976
1503
|
fill: "none",
|
|
977
1504
|
stroke: "currentColor",
|
|
978
1505
|
viewBox: "0 0 24 24",
|
|
979
|
-
children: /* @__PURE__ */
|
|
1506
|
+
children: /* @__PURE__ */ jsx12(
|
|
980
1507
|
"path",
|
|
981
1508
|
{
|
|
982
1509
|
strokeLinecap: "round",
|
|
@@ -991,7 +1518,7 @@ function WelcomeScreen({
|
|
|
991
1518
|
},
|
|
992
1519
|
index
|
|
993
1520
|
)) }),
|
|
994
|
-
/* @__PURE__ */
|
|
1521
|
+
/* @__PURE__ */ jsx12("div", { className: "hidden sm:grid sm:grid-cols-2 gap-3", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx12(
|
|
995
1522
|
"button",
|
|
996
1523
|
{
|
|
997
1524
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -1006,11 +1533,11 @@ function WelcomeScreen({
|
|
|
1006
1533
|
"transition-all duration-200",
|
|
1007
1534
|
"group"
|
|
1008
1535
|
),
|
|
1009
|
-
children: /* @__PURE__ */
|
|
1010
|
-
/* @__PURE__ */
|
|
1011
|
-
/* @__PURE__ */
|
|
1012
|
-
/* @__PURE__ */
|
|
1013
|
-
prompt.description && /* @__PURE__ */
|
|
1536
|
+
children: /* @__PURE__ */ jsxs9("div", { className: "flex items-start gap-3", children: [
|
|
1537
|
+
/* @__PURE__ */ jsx12("div", { className: "flex-shrink-0 w-9 h-9 rounded-lg bg-gray-100 dark:bg-gray-700 flex items-center justify-center !text-gray-500 dark:!text-gray-400 group-hover:bg-blue-100 dark:group-hover:bg-blue-900/30 group-hover:!text-blue-600 dark:group-hover:!text-blue-400 transition-colors", children: prompt.icon || /* @__PURE__ */ jsx12(ArrowIcon, {}) }),
|
|
1538
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex-1 min-w-0", children: [
|
|
1539
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm font-medium !text-gray-900 dark:!text-white leading-snug", children: prompt.text }),
|
|
1540
|
+
prompt.description && /* @__PURE__ */ jsx12("p", { className: "text-xs !text-gray-500 dark:!text-gray-400 mt-1 line-clamp-2", children: prompt.description })
|
|
1014
1541
|
] })
|
|
1015
1542
|
] })
|
|
1016
1543
|
},
|
|
@@ -1021,7 +1548,7 @@ function WelcomeScreen({
|
|
|
1021
1548
|
}
|
|
1022
1549
|
|
|
1023
1550
|
// src/components/Chat/MessageList.tsx
|
|
1024
|
-
import { jsx as
|
|
1551
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1025
1552
|
function MessageList({
|
|
1026
1553
|
messages,
|
|
1027
1554
|
onAction,
|
|
@@ -1030,15 +1557,17 @@ function MessageList({
|
|
|
1030
1557
|
welcomeIcon,
|
|
1031
1558
|
suggestedPrompts,
|
|
1032
1559
|
welcomeVariant,
|
|
1033
|
-
onPromptClick
|
|
1560
|
+
onPromptClick,
|
|
1561
|
+
enableWidgets,
|
|
1562
|
+
onWidgetRender
|
|
1034
1563
|
}) {
|
|
1035
|
-
const listRef =
|
|
1036
|
-
|
|
1564
|
+
const listRef = useRef2(null);
|
|
1565
|
+
useEffect3(() => {
|
|
1037
1566
|
if (listRef.current) {
|
|
1038
1567
|
listRef.current.scrollTop = listRef.current.scrollHeight;
|
|
1039
1568
|
}
|
|
1040
1569
|
}, [messages]);
|
|
1041
|
-
return /* @__PURE__ */
|
|
1570
|
+
return /* @__PURE__ */ jsx13("div", { ref: listRef, className: "flex-1 overflow-y-auto px-4 py-4 space-y-3 apteva-scrollbar-hidden", children: messages.length === 0 ? /* @__PURE__ */ jsx13(
|
|
1042
1571
|
WelcomeScreen,
|
|
1043
1572
|
{
|
|
1044
1573
|
title: welcomeTitle,
|
|
@@ -1049,20 +1578,20 @@ function MessageList({
|
|
|
1049
1578
|
onPromptClick: onPromptClick || (() => {
|
|
1050
1579
|
})
|
|
1051
1580
|
}
|
|
1052
|
-
) : messages.map((message) => /* @__PURE__ */
|
|
1581
|
+
) : messages.map((message) => /* @__PURE__ */ jsx13("div", { className: `flex ${message.role === "user" ? "justify-end" : "justify-start"}`, children: /* @__PURE__ */ jsx13(Message, { message, onAction, enableWidgets, onWidgetRender }) }, message.id)) });
|
|
1053
1582
|
}
|
|
1054
1583
|
|
|
1055
1584
|
// src/components/Chat/Composer.tsx
|
|
1056
|
-
import { useState, useRef as
|
|
1057
|
-
import { Fragment, jsx as
|
|
1058
|
-
function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, onFileUpload, onSwitchMode }) {
|
|
1585
|
+
import { useState, useRef as useRef3 } from "react";
|
|
1586
|
+
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1587
|
+
function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, isLoading = false, onStop, onFileUpload, onSwitchMode }) {
|
|
1059
1588
|
const [text, setText] = useState("");
|
|
1060
1589
|
const [showMenu, setShowMenu] = useState(false);
|
|
1061
1590
|
const [pendingFiles, setPendingFiles] = useState([]);
|
|
1062
1591
|
const [fileError, setFileError] = useState(null);
|
|
1063
|
-
const textareaRef =
|
|
1064
|
-
const fileInputRef =
|
|
1065
|
-
const menuButtonRef =
|
|
1592
|
+
const textareaRef = useRef3(null);
|
|
1593
|
+
const fileInputRef = useRef3(null);
|
|
1594
|
+
const menuButtonRef = useRef3(null);
|
|
1066
1595
|
const handleKeyDown = (e) => {
|
|
1067
1596
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
1068
1597
|
e.preventDefault();
|
|
@@ -1128,56 +1657,56 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1128
1657
|
};
|
|
1129
1658
|
const getFileIcon = (mimeType) => {
|
|
1130
1659
|
if (mimeType.startsWith("image/")) {
|
|
1131
|
-
return /* @__PURE__ */
|
|
1660
|
+
return /* @__PURE__ */ jsx14("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx14("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) });
|
|
1132
1661
|
}
|
|
1133
1662
|
if (mimeType === "application/pdf") {
|
|
1134
|
-
return /* @__PURE__ */
|
|
1663
|
+
return /* @__PURE__ */ jsx14("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx14("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" }) });
|
|
1135
1664
|
}
|
|
1136
|
-
return /* @__PURE__ */
|
|
1665
|
+
return /* @__PURE__ */ jsx14("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx14("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" }) });
|
|
1137
1666
|
};
|
|
1138
|
-
return /* @__PURE__ */
|
|
1139
|
-
fileError && /* @__PURE__ */
|
|
1140
|
-
/* @__PURE__ */
|
|
1141
|
-
/* @__PURE__ */
|
|
1667
|
+
return /* @__PURE__ */ jsxs10("div", { className: "px-4 py-3 relative", children: [
|
|
1668
|
+
fileError && /* @__PURE__ */ jsx14("div", { className: "absolute bottom-full left-4 right-4 mb-2 p-3 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded-lg z-20", children: /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2 !text-red-700 dark:!text-red-300 text-sm", children: [
|
|
1669
|
+
/* @__PURE__ */ jsx14("svg", { className: "w-4 h-4 flex-shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx14("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
1670
|
+
/* @__PURE__ */ jsx14("span", { children: fileError })
|
|
1142
1671
|
] }) }),
|
|
1143
|
-
pendingFiles.length > 0 && /* @__PURE__ */
|
|
1672
|
+
pendingFiles.length > 0 && /* @__PURE__ */ jsx14("div", { className: "mb-2 flex flex-wrap gap-2", children: pendingFiles.map((pf, index) => /* @__PURE__ */ jsxs10(
|
|
1144
1673
|
"div",
|
|
1145
1674
|
{
|
|
1146
1675
|
className: "relative group flex items-center gap-2 px-3 py-2 bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg",
|
|
1147
1676
|
children: [
|
|
1148
|
-
pf.preview ? /* @__PURE__ */
|
|
1149
|
-
/* @__PURE__ */
|
|
1150
|
-
/* @__PURE__ */
|
|
1151
|
-
/* @__PURE__ */
|
|
1677
|
+
pf.preview ? /* @__PURE__ */ jsx14("img", { src: pf.preview, alt: pf.file.name, className: "w-8 h-8 object-cover rounded" }) : /* @__PURE__ */ jsx14("div", { className: "w-8 h-8 flex items-center justify-center bg-gray-200 dark:bg-gray-700 rounded !text-gray-500 dark:!text-gray-400", children: getFileIcon(pf.file.type) }),
|
|
1678
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-col min-w-0", children: [
|
|
1679
|
+
/* @__PURE__ */ jsx14("span", { className: "text-xs font-medium !text-gray-700 dark:!text-gray-300 truncate max-w-[120px]", children: pf.file.name }),
|
|
1680
|
+
/* @__PURE__ */ jsx14("span", { className: "text-xs !text-gray-500 dark:!text-gray-400", children: formatFileSize(pf.file.size) })
|
|
1152
1681
|
] }),
|
|
1153
|
-
/* @__PURE__ */
|
|
1682
|
+
/* @__PURE__ */ jsx14(
|
|
1154
1683
|
"button",
|
|
1155
1684
|
{
|
|
1156
1685
|
onClick: () => removeFile(index),
|
|
1157
1686
|
className: "absolute -top-1.5 -right-1.5 w-5 h-5 bg-gray-500 hover:bg-red-500 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",
|
|
1158
1687
|
title: "Remove file",
|
|
1159
|
-
children: /* @__PURE__ */
|
|
1688
|
+
children: /* @__PURE__ */ jsx14("svg", { className: "w-3 h-3", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx14("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
1160
1689
|
}
|
|
1161
1690
|
)
|
|
1162
1691
|
]
|
|
1163
1692
|
},
|
|
1164
1693
|
index
|
|
1165
1694
|
)) }),
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1695
|
+
/* @__PURE__ */ jsxs10("div", { className: "apteva-composer relative border-2 border-gray-300 dark:border-gray-700 bg-white dark:bg-gray-900 transition-all duration-300 flex items-center px-3 py-2 gap-3", children: [
|
|
1696
|
+
/* @__PURE__ */ jsxs10("div", { className: "relative flex-shrink-0", children: [
|
|
1697
|
+
/* @__PURE__ */ jsx14(
|
|
1169
1698
|
"button",
|
|
1170
1699
|
{
|
|
1171
1700
|
ref: menuButtonRef,
|
|
1172
1701
|
onClick: () => setShowMenu(!showMenu),
|
|
1173
1702
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all !text-gray-700 dark:!text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
1174
1703
|
title: "More options",
|
|
1175
|
-
children: /* @__PURE__ */
|
|
1704
|
+
children: /* @__PURE__ */ jsx14("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx14("path", { d: "M10 5v10M5 10h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
1176
1705
|
}
|
|
1177
1706
|
),
|
|
1178
|
-
showMenu && /* @__PURE__ */
|
|
1179
|
-
/* @__PURE__ */
|
|
1180
|
-
/* @__PURE__ */
|
|
1707
|
+
showMenu && /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
1708
|
+
/* @__PURE__ */ jsx14("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
1709
|
+
/* @__PURE__ */ jsxs10(
|
|
1181
1710
|
"div",
|
|
1182
1711
|
{
|
|
1183
1712
|
className: "fixed bg-gray-800 dark:bg-gray-700 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
@@ -1186,7 +1715,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1186
1715
|
top: (menuButtonRef.current?.getBoundingClientRect().bottom ?? 0) + 8
|
|
1187
1716
|
},
|
|
1188
1717
|
children: [
|
|
1189
|
-
/* @__PURE__ */
|
|
1718
|
+
/* @__PURE__ */ jsxs10(
|
|
1190
1719
|
"button",
|
|
1191
1720
|
{
|
|
1192
1721
|
onClick: () => {
|
|
@@ -1195,12 +1724,12 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1195
1724
|
},
|
|
1196
1725
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-gray-700 dark:hover:bg-gray-600 transition-colors !text-white text-left",
|
|
1197
1726
|
children: [
|
|
1198
|
-
/* @__PURE__ */
|
|
1199
|
-
/* @__PURE__ */
|
|
1727
|
+
/* @__PURE__ */ jsx14("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx14("path", { d: "M10.5 3.5L5.5 8.5C4.67157 9.32843 4.67157 10.6716 5.5 11.5C6.32843 12.3284 7.67157 12.3284 8.5 11.5L14.5 5.5C15.8807 4.11929 15.8807 1.88071 14.5 0.5C13.1193 -0.880711 10.8807 -0.880711 9.5 0.5L3.5 6.5C1.56846 8.43154 1.56846 11.5685 3.5 13.5C5.43154 15.4315 8.56846 15.4315 10.5 13.5L15.5 8.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(2, 3)" }) }),
|
|
1728
|
+
/* @__PURE__ */ jsx14("span", { className: "!text-sm font-medium", children: "Add photos & files" })
|
|
1200
1729
|
]
|
|
1201
1730
|
}
|
|
1202
1731
|
),
|
|
1203
|
-
onSwitchMode && /* @__PURE__ */
|
|
1732
|
+
onSwitchMode && /* @__PURE__ */ jsxs10(
|
|
1204
1733
|
"button",
|
|
1205
1734
|
{
|
|
1206
1735
|
onClick: () => {
|
|
@@ -1209,8 +1738,8 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1209
1738
|
},
|
|
1210
1739
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-gray-700 dark:hover:bg-gray-600 transition-colors !text-white text-left border-t border-gray-700 dark:border-gray-600",
|
|
1211
1740
|
children: [
|
|
1212
|
-
/* @__PURE__ */
|
|
1213
|
-
/* @__PURE__ */
|
|
1741
|
+
/* @__PURE__ */ jsx14("svg", { className: "w-4.5 h-4.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx14("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }),
|
|
1742
|
+
/* @__PURE__ */ jsx14("span", { className: "!text-sm font-medium", children: "Switch to command mode" })
|
|
1214
1743
|
]
|
|
1215
1744
|
}
|
|
1216
1745
|
)
|
|
@@ -1219,7 +1748,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1219
1748
|
)
|
|
1220
1749
|
] })
|
|
1221
1750
|
] }),
|
|
1222
|
-
/* @__PURE__ */
|
|
1751
|
+
/* @__PURE__ */ jsx14(
|
|
1223
1752
|
"textarea",
|
|
1224
1753
|
{
|
|
1225
1754
|
ref: textareaRef,
|
|
@@ -1233,18 +1762,26 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1233
1762
|
style: { maxHeight: "120px" }
|
|
1234
1763
|
}
|
|
1235
1764
|
),
|
|
1236
|
-
/* @__PURE__ */
|
|
1765
|
+
isLoading && onStop ? /* @__PURE__ */ jsx14(
|
|
1766
|
+
"button",
|
|
1767
|
+
{
|
|
1768
|
+
onClick: onStop,
|
|
1769
|
+
className: "w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all flex-shrink-0 border border-red-400 dark:border-red-500 bg-red-50 dark:bg-red-900/30 !text-red-600 dark:!text-red-400 hover:bg-red-100 dark:hover:bg-red-900/50",
|
|
1770
|
+
title: "Stop generation",
|
|
1771
|
+
children: /* @__PURE__ */ jsx14("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx14("rect", { x: "2", y: "2", width: "10", height: "10", rx: "1", fill: "currentColor" }) })
|
|
1772
|
+
}
|
|
1773
|
+
) : /* @__PURE__ */ jsx14(
|
|
1237
1774
|
"button",
|
|
1238
1775
|
{
|
|
1239
1776
|
onClick: handleSend,
|
|
1240
1777
|
disabled: !text.trim() && pendingFiles.length === 0 || disabled,
|
|
1241
1778
|
className: "w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all flex-shrink-0 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 !text-gray-700 dark:!text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed !text-lg",
|
|
1242
1779
|
title: "Send message",
|
|
1243
|
-
children: /* @__PURE__ */
|
|
1780
|
+
children: /* @__PURE__ */ jsx14("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx14("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
1244
1781
|
}
|
|
1245
1782
|
)
|
|
1246
1783
|
] }),
|
|
1247
|
-
/* @__PURE__ */
|
|
1784
|
+
/* @__PURE__ */ jsx14(
|
|
1248
1785
|
"input",
|
|
1249
1786
|
{
|
|
1250
1787
|
ref: fileInputRef,
|
|
@@ -1259,8 +1796,8 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1259
1796
|
}
|
|
1260
1797
|
|
|
1261
1798
|
// src/components/Chat/CommandComposer.tsx
|
|
1262
|
-
import { useState as useState2, useRef as
|
|
1263
|
-
import { Fragment as
|
|
1799
|
+
import { useState as useState2, useRef as useRef4 } from "react";
|
|
1800
|
+
import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1264
1801
|
function CommandComposer({
|
|
1265
1802
|
onExecute,
|
|
1266
1803
|
state,
|
|
@@ -1272,6 +1809,7 @@ function CommandComposer({
|
|
|
1272
1809
|
onApprove,
|
|
1273
1810
|
onReject,
|
|
1274
1811
|
onReset,
|
|
1812
|
+
onStop,
|
|
1275
1813
|
onExpand,
|
|
1276
1814
|
placeholder = "Enter your command...",
|
|
1277
1815
|
disabled = false
|
|
@@ -1280,9 +1818,9 @@ function CommandComposer({
|
|
|
1280
1818
|
const [pendingFiles, setPendingFiles] = useState2([]);
|
|
1281
1819
|
const [fileError, setFileError] = useState2(null);
|
|
1282
1820
|
const [showMenu, setShowMenu] = useState2(false);
|
|
1283
|
-
const inputRef =
|
|
1284
|
-
const fileInputRef =
|
|
1285
|
-
const menuButtonRef =
|
|
1821
|
+
const inputRef = useRef4(null);
|
|
1822
|
+
const fileInputRef = useRef4(null);
|
|
1823
|
+
const menuButtonRef = useRef4(null);
|
|
1286
1824
|
const handleSubmit = () => {
|
|
1287
1825
|
const hasText = input.trim();
|
|
1288
1826
|
const hasFiles = pendingFiles.length > 0;
|
|
@@ -1349,12 +1887,12 @@ function CommandComposer({
|
|
|
1349
1887
|
};
|
|
1350
1888
|
const getFileIcon = (mimeType) => {
|
|
1351
1889
|
if (mimeType.startsWith("image/")) {
|
|
1352
|
-
return /* @__PURE__ */
|
|
1890
|
+
return /* @__PURE__ */ jsx15("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) });
|
|
1353
1891
|
}
|
|
1354
1892
|
if (mimeType === "application/pdf") {
|
|
1355
|
-
return /* @__PURE__ */
|
|
1893
|
+
return /* @__PURE__ */ jsx15("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" }) });
|
|
1356
1894
|
}
|
|
1357
|
-
return /* @__PURE__ */
|
|
1895
|
+
return /* @__PURE__ */ jsx15("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx15("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" }) });
|
|
1358
1896
|
};
|
|
1359
1897
|
const getDisplayContent = () => {
|
|
1360
1898
|
if (state === "loading") {
|
|
@@ -1379,12 +1917,12 @@ function CommandComposer({
|
|
|
1379
1917
|
};
|
|
1380
1918
|
const isShowingResult = state !== "idle";
|
|
1381
1919
|
const { text: displayContent, isToolCall } = getDisplayContent();
|
|
1382
|
-
return /* @__PURE__ */
|
|
1383
|
-
fileError && /* @__PURE__ */
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
/* @__PURE__ */
|
|
1920
|
+
return /* @__PURE__ */ jsxs11("div", { className: "w-full relative", children: [
|
|
1921
|
+
fileError && /* @__PURE__ */ jsx15("div", { className: "absolute -top-12 left-0 right-0 mx-3 p-2 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded-lg z-30", children: /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 !text-red-700 dark:!text-red-300 text-xs", children: [
|
|
1922
|
+
/* @__PURE__ */ jsx15("svg", { className: "w-3 h-3 flex-shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
1923
|
+
/* @__PURE__ */ jsx15("span", { children: fileError })
|
|
1386
1924
|
] }) }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1925
|
+
/* @__PURE__ */ jsxs11(
|
|
1388
1926
|
"div",
|
|
1389
1927
|
{
|
|
1390
1928
|
className: cn(
|
|
@@ -1396,21 +1934,21 @@ function CommandComposer({
|
|
|
1396
1934
|
state === "error" && "border-red-400 dark:border-red-500"
|
|
1397
1935
|
),
|
|
1398
1936
|
children: [
|
|
1399
|
-
/* @__PURE__ */
|
|
1400
|
-
state === "idle" && /* @__PURE__ */
|
|
1401
|
-
/* @__PURE__ */
|
|
1937
|
+
/* @__PURE__ */ jsxs11("div", { className: "w-8 h-8 flex items-center justify-center flex-shrink-0", children: [
|
|
1938
|
+
state === "idle" && /* @__PURE__ */ jsxs11("div", { className: "relative", children: [
|
|
1939
|
+
/* @__PURE__ */ jsx15(
|
|
1402
1940
|
"button",
|
|
1403
1941
|
{
|
|
1404
1942
|
ref: menuButtonRef,
|
|
1405
1943
|
onClick: () => setShowMenu(!showMenu),
|
|
1406
1944
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all !text-gray-500 dark:!text-gray-400 hover:!text-gray-700 dark:hover:!text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
1407
1945
|
title: "More options",
|
|
1408
|
-
children: /* @__PURE__ */
|
|
1946
|
+
children: /* @__PURE__ */ jsx15("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx15("path", { d: "M10 5v10M5 10h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
1409
1947
|
}
|
|
1410
1948
|
),
|
|
1411
|
-
showMenu && /* @__PURE__ */
|
|
1412
|
-
/* @__PURE__ */
|
|
1413
|
-
/* @__PURE__ */
|
|
1949
|
+
showMenu && /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
1950
|
+
/* @__PURE__ */ jsx15("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
1951
|
+
/* @__PURE__ */ jsxs11(
|
|
1414
1952
|
"div",
|
|
1415
1953
|
{
|
|
1416
1954
|
className: "fixed bg-gray-800 dark:bg-gray-700 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
@@ -1419,7 +1957,7 @@ function CommandComposer({
|
|
|
1419
1957
|
top: (menuButtonRef.current?.getBoundingClientRect().bottom ?? 0) + 8
|
|
1420
1958
|
},
|
|
1421
1959
|
children: [
|
|
1422
|
-
/* @__PURE__ */
|
|
1960
|
+
/* @__PURE__ */ jsxs11(
|
|
1423
1961
|
"button",
|
|
1424
1962
|
{
|
|
1425
1963
|
onClick: () => {
|
|
@@ -1428,12 +1966,12 @@ function CommandComposer({
|
|
|
1428
1966
|
},
|
|
1429
1967
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-gray-700 dark:hover:bg-gray-600 transition-colors !text-white text-left",
|
|
1430
1968
|
children: [
|
|
1431
|
-
/* @__PURE__ */
|
|
1432
|
-
/* @__PURE__ */
|
|
1969
|
+
/* @__PURE__ */ jsx15("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx15("path", { d: "M10.5 3.5L5.5 8.5C4.67157 9.32843 4.67157 10.6716 5.5 11.5C6.32843 12.3284 7.67157 12.3284 8.5 11.5L14.5 5.5C15.8807 4.11929 15.8807 1.88071 14.5 0.5C13.1193 -0.880711 10.8807 -0.880711 9.5 0.5L3.5 6.5C1.56846 8.43154 1.56846 11.5685 3.5 13.5C5.43154 15.4315 8.56846 15.4315 10.5 13.5L15.5 8.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(2, 3)" }) }),
|
|
1970
|
+
/* @__PURE__ */ jsx15("span", { className: "!text-sm font-medium", children: "Add photos & files" })
|
|
1433
1971
|
]
|
|
1434
1972
|
}
|
|
1435
1973
|
),
|
|
1436
|
-
onExpand && /* @__PURE__ */
|
|
1974
|
+
onExpand && /* @__PURE__ */ jsxs11(
|
|
1437
1975
|
"button",
|
|
1438
1976
|
{
|
|
1439
1977
|
onClick: () => {
|
|
@@ -1442,8 +1980,8 @@ function CommandComposer({
|
|
|
1442
1980
|
},
|
|
1443
1981
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-gray-700 dark:hover:bg-gray-600 transition-colors !text-white text-left border-t border-gray-700 dark:border-gray-600",
|
|
1444
1982
|
children: [
|
|
1445
|
-
/* @__PURE__ */
|
|
1446
|
-
/* @__PURE__ */
|
|
1983
|
+
/* @__PURE__ */ jsx15("svg", { className: "w-4.5 h-4.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }),
|
|
1984
|
+
/* @__PURE__ */ jsx15("span", { className: "!text-sm font-medium", children: "Expand to chat" })
|
|
1447
1985
|
]
|
|
1448
1986
|
}
|
|
1449
1987
|
)
|
|
@@ -1452,30 +1990,30 @@ function CommandComposer({
|
|
|
1452
1990
|
)
|
|
1453
1991
|
] })
|
|
1454
1992
|
] }),
|
|
1455
|
-
state === "loading" && !toolName && /* @__PURE__ */
|
|
1456
|
-
state === "loading" && toolName && /* @__PURE__ */
|
|
1993
|
+
state === "loading" && !toolName && /* @__PURE__ */ jsx15("div", { className: "w-4 h-4 border-2 border-blue-200 border-t-blue-500 rounded-full animate-spin" }),
|
|
1994
|
+
state === "loading" && toolName && /* @__PURE__ */ jsx15("div", { className: "w-2 h-2 rounded-full bg-blue-500 animate-pulse" })
|
|
1457
1995
|
] }),
|
|
1458
|
-
pendingFiles.length > 0 && state === "idle" && /* @__PURE__ */
|
|
1996
|
+
pendingFiles.length > 0 && state === "idle" && /* @__PURE__ */ jsx15("div", { className: "flex items-center gap-1 flex-shrink-0", children: pendingFiles.map((pf, index) => /* @__PURE__ */ jsxs11(
|
|
1459
1997
|
"div",
|
|
1460
1998
|
{
|
|
1461
1999
|
className: "relative group flex items-center justify-center w-6 h-6 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",
|
|
1462
2000
|
title: pf.file.name,
|
|
1463
2001
|
children: [
|
|
1464
|
-
pf.preview ? /* @__PURE__ */
|
|
1465
|
-
/* @__PURE__ */
|
|
2002
|
+
pf.preview ? /* @__PURE__ */ jsx15("img", { src: pf.preview, alt: pf.file.name, className: "w-6 h-6 object-cover" }) : /* @__PURE__ */ jsx15("span", { className: "text-xs !text-gray-500 dark:!text-gray-400", children: getFileIcon(pf.file.type) }),
|
|
2003
|
+
/* @__PURE__ */ jsx15(
|
|
1466
2004
|
"button",
|
|
1467
2005
|
{
|
|
1468
2006
|
onClick: () => removeFile(index),
|
|
1469
2007
|
className: "absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 flex items-center justify-center transition-opacity",
|
|
1470
2008
|
title: "Remove",
|
|
1471
|
-
children: /* @__PURE__ */
|
|
2009
|
+
children: /* @__PURE__ */ jsx15("svg", { className: "w-3 h-3 text-white", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
1472
2010
|
}
|
|
1473
2011
|
)
|
|
1474
2012
|
]
|
|
1475
2013
|
},
|
|
1476
2014
|
index
|
|
1477
2015
|
)) }),
|
|
1478
|
-
state === "idle" ? /* @__PURE__ */
|
|
2016
|
+
state === "idle" ? /* @__PURE__ */ jsx15(
|
|
1479
2017
|
"textarea",
|
|
1480
2018
|
{
|
|
1481
2019
|
ref: inputRef,
|
|
@@ -1493,7 +2031,7 @@ function CommandComposer({
|
|
|
1493
2031
|
),
|
|
1494
2032
|
style: { minHeight: "24px", maxHeight: "120px" }
|
|
1495
2033
|
}
|
|
1496
|
-
) : /* @__PURE__ */
|
|
2034
|
+
) : /* @__PURE__ */ jsx15(
|
|
1497
2035
|
"div",
|
|
1498
2036
|
{
|
|
1499
2037
|
className: cn(
|
|
@@ -1504,14 +2042,14 @@ function CommandComposer({
|
|
|
1504
2042
|
state === "error" && "!text-red-600 dark:!text-red-400",
|
|
1505
2043
|
state === "plan-pending" && "!text-amber-700 dark:!text-amber-300"
|
|
1506
2044
|
),
|
|
1507
|
-
children: isToolCall ? /* @__PURE__ */
|
|
1508
|
-
/* @__PURE__ */
|
|
1509
|
-
/* @__PURE__ */
|
|
2045
|
+
children: isToolCall ? /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
2046
|
+
/* @__PURE__ */ jsx15("span", { className: "font-mono", children: displayContent }),
|
|
2047
|
+
/* @__PURE__ */ jsx15("span", { className: "text-gray-400 dark:text-gray-500", children: "Running..." })
|
|
1510
2048
|
] }) : displayContent
|
|
1511
2049
|
}
|
|
1512
2050
|
),
|
|
1513
|
-
/* @__PURE__ */
|
|
1514
|
-
/* @__PURE__ */
|
|
2051
|
+
/* @__PURE__ */ jsx15("div", { className: "w-8 h-8 flex items-center justify-center flex-shrink-0", children: state === "plan-pending" ? /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
|
|
2052
|
+
/* @__PURE__ */ jsx15(
|
|
1515
2053
|
"button",
|
|
1516
2054
|
{
|
|
1517
2055
|
onClick: onApprove,
|
|
@@ -1519,7 +2057,7 @@ function CommandComposer({
|
|
|
1519
2057
|
children: "Approve"
|
|
1520
2058
|
}
|
|
1521
2059
|
),
|
|
1522
|
-
/* @__PURE__ */
|
|
2060
|
+
/* @__PURE__ */ jsx15(
|
|
1523
2061
|
"button",
|
|
1524
2062
|
{
|
|
1525
2063
|
onClick: onReject,
|
|
@@ -1527,17 +2065,26 @@ function CommandComposer({
|
|
|
1527
2065
|
children: "Modify"
|
|
1528
2066
|
}
|
|
1529
2067
|
)
|
|
1530
|
-
] }) : /* @__PURE__ */
|
|
1531
|
-
|
|
2068
|
+
] }) : /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
2069
|
+
state === "loading" && onStop && /* @__PURE__ */ jsx15(
|
|
2070
|
+
"button",
|
|
2071
|
+
{
|
|
2072
|
+
onClick: onStop,
|
|
2073
|
+
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all border border-red-400 dark:border-red-500 bg-red-50 dark:bg-red-900/30 !text-red-600 dark:!text-red-400 hover:bg-red-100 dark:hover:bg-red-900/50",
|
|
2074
|
+
title: "Stop generation",
|
|
2075
|
+
children: /* @__PURE__ */ jsx15("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx15("rect", { x: "2", y: "2", width: "10", height: "10", rx: "1", fill: "currentColor" }) })
|
|
2076
|
+
}
|
|
2077
|
+
),
|
|
2078
|
+
(state === "success" || state === "error") && /* @__PURE__ */ jsx15(
|
|
1532
2079
|
"button",
|
|
1533
2080
|
{
|
|
1534
2081
|
onClick: handleNewCommand,
|
|
1535
2082
|
className: "w-8 h-8 rounded-lg flex items-center justify-center !text-gray-400 hover:!text-gray-600 dark:hover:!text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",
|
|
1536
2083
|
title: "New command",
|
|
1537
|
-
children: /* @__PURE__ */
|
|
2084
|
+
children: /* @__PURE__ */ jsx15("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
1538
2085
|
}
|
|
1539
2086
|
),
|
|
1540
|
-
state === "idle" && /* @__PURE__ */
|
|
2087
|
+
state === "idle" && /* @__PURE__ */ jsx15(
|
|
1541
2088
|
"button",
|
|
1542
2089
|
{
|
|
1543
2090
|
onClick: handleSubmit,
|
|
@@ -1549,14 +2096,14 @@ function CommandComposer({
|
|
|
1549
2096
|
input.trim() || pendingFiles.length > 0 ? "bg-gray-900 dark:bg-white !text-white dark:!text-gray-900 border-gray-900 dark:border-white" : "bg-white dark:bg-gray-800 !text-gray-400"
|
|
1550
2097
|
),
|
|
1551
2098
|
title: "Execute command",
|
|
1552
|
-
children: /* @__PURE__ */
|
|
2099
|
+
children: /* @__PURE__ */ jsx15("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 12h14M12 5l7 7-7 7" }) })
|
|
1553
2100
|
}
|
|
1554
2101
|
)
|
|
1555
2102
|
] }) })
|
|
1556
2103
|
]
|
|
1557
2104
|
}
|
|
1558
2105
|
),
|
|
1559
|
-
/* @__PURE__ */
|
|
2106
|
+
/* @__PURE__ */ jsx15(
|
|
1560
2107
|
"input",
|
|
1561
2108
|
{
|
|
1562
2109
|
ref: fileInputRef,
|
|
@@ -1731,11 +2278,32 @@ var AptevaClient = class {
|
|
|
1731
2278
|
const data = await response.json();
|
|
1732
2279
|
return data.messages;
|
|
1733
2280
|
}
|
|
2281
|
+
/**
|
|
2282
|
+
* Cancel an in-progress request
|
|
2283
|
+
*/
|
|
2284
|
+
async cancelRequest(agentId, requestId) {
|
|
2285
|
+
try {
|
|
2286
|
+
const response = await fetch(`${this.config.apiUrl}/agents/${agentId}/requests/${requestId}/cancel`, {
|
|
2287
|
+
method: "POST",
|
|
2288
|
+
headers: {
|
|
2289
|
+
"Content-Type": "application/json",
|
|
2290
|
+
"X-API-Key": this.config.apiKey
|
|
2291
|
+
}
|
|
2292
|
+
});
|
|
2293
|
+
if (!response.ok) {
|
|
2294
|
+
const error = await response.json().catch(() => ({ error: "Cancel request failed" }));
|
|
2295
|
+
throw new Error(error.error || `Cancel request failed with status ${response.status}`);
|
|
2296
|
+
}
|
|
2297
|
+
} catch (error) {
|
|
2298
|
+
console.error("[AptevaClient] Cancel request error:", error);
|
|
2299
|
+
throw error;
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
1734
2302
|
};
|
|
1735
2303
|
var aptevaClient = new AptevaClient();
|
|
1736
2304
|
|
|
1737
2305
|
// src/components/Chat/Chat.tsx
|
|
1738
|
-
import { Fragment as
|
|
2306
|
+
import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1739
2307
|
function Chat({
|
|
1740
2308
|
agentId,
|
|
1741
2309
|
threadId,
|
|
@@ -1773,12 +2341,18 @@ function Chat({
|
|
|
1773
2341
|
placeholder,
|
|
1774
2342
|
showHeader = true,
|
|
1775
2343
|
headerTitle = "Chat",
|
|
2344
|
+
// Widget detection
|
|
2345
|
+
enableWidgets = false,
|
|
2346
|
+
availableWidgets,
|
|
2347
|
+
compactWidgetContext = false,
|
|
2348
|
+
onWidgetRender,
|
|
1776
2349
|
className
|
|
1777
2350
|
}) {
|
|
1778
2351
|
const [messages, setMessages] = useState3(initialMessages);
|
|
1779
2352
|
const [isLoading, setIsLoading] = useState3(false);
|
|
1780
2353
|
const [currentThreadId, setCurrentThreadId] = useState3(threadId || null);
|
|
1781
2354
|
const [mode, setMode] = useState3(initialMode);
|
|
2355
|
+
const [chatToolName, setChatToolName] = useState3(null);
|
|
1782
2356
|
const [commandState, setCommandState] = useState3("idle");
|
|
1783
2357
|
const [commandResult, setCommandResult] = useState3(null);
|
|
1784
2358
|
const [commandError, setCommandError] = useState3(null);
|
|
@@ -1786,12 +2360,19 @@ function Chat({
|
|
|
1786
2360
|
const [commandInput, setCommandInput] = useState3("");
|
|
1787
2361
|
const [streamedContent, setStreamedContent] = useState3("");
|
|
1788
2362
|
const [currentToolName, setCurrentToolName] = useState3(null);
|
|
2363
|
+
const [currentRequestId, setCurrentRequestId] = useState3(null);
|
|
1789
2364
|
const [plan, setPlan] = useState3("");
|
|
1790
2365
|
const [pendingCommand, setPendingCommand] = useState3("");
|
|
1791
2366
|
const [internalPlanMode, setInternalPlanMode] = useState3(planMode);
|
|
1792
2367
|
const [showSettingsMenu, setShowSettingsMenu] = useState3(false);
|
|
1793
|
-
const fileInputRef =
|
|
1794
|
-
|
|
2368
|
+
const fileInputRef = useRef5(null);
|
|
2369
|
+
const effectiveContext = useMemo2(() => {
|
|
2370
|
+
if (!enableWidgets) return context;
|
|
2371
|
+
const widgetContext = compactWidgetContext ? generateCompactWidgetContext(availableWidgets) : generateWidgetContext(availableWidgets);
|
|
2372
|
+
return context ? `${context}
|
|
2373
|
+
${widgetContext}` : widgetContext;
|
|
2374
|
+
}, [context, enableWidgets, availableWidgets, compactWidgetContext]);
|
|
2375
|
+
useEffect4(() => {
|
|
1795
2376
|
if (apiUrl || apiKey) {
|
|
1796
2377
|
aptevaClient.configure({
|
|
1797
2378
|
...apiUrl && { apiUrl },
|
|
@@ -1799,15 +2380,15 @@ function Chat({
|
|
|
1799
2380
|
});
|
|
1800
2381
|
}
|
|
1801
2382
|
}, [apiUrl, apiKey]);
|
|
1802
|
-
|
|
2383
|
+
useEffect4(() => {
|
|
1803
2384
|
if (threadId) {
|
|
1804
2385
|
onThreadChange?.(threadId);
|
|
1805
2386
|
}
|
|
1806
2387
|
}, [threadId, onThreadChange]);
|
|
1807
|
-
|
|
2388
|
+
useEffect4(() => {
|
|
1808
2389
|
setInternalPlanMode(planMode);
|
|
1809
2390
|
}, [planMode]);
|
|
1810
|
-
|
|
2391
|
+
useEffect4(() => {
|
|
1811
2392
|
const handleClickOutside = (event) => {
|
|
1812
2393
|
const target = event.target;
|
|
1813
2394
|
if (showSettingsMenu && !target.closest(".settings-menu-container")) {
|
|
@@ -1852,6 +2433,7 @@ function Chat({
|
|
|
1852
2433
|
let accumulatedWidgets = [];
|
|
1853
2434
|
let responseThreadId = currentThreadId;
|
|
1854
2435
|
let toolInputBuffer = "";
|
|
2436
|
+
const streamingMessageId = `msg-${Date.now()}`;
|
|
1855
2437
|
const updateMessage = () => {
|
|
1856
2438
|
const segments = [...contentSegments];
|
|
1857
2439
|
if (currentTextBuffer) {
|
|
@@ -1871,19 +2453,19 @@ function Chat({
|
|
|
1871
2453
|
...lastMessage,
|
|
1872
2454
|
content: currentTextBuffer,
|
|
1873
2455
|
widgets: accumulatedWidgets.length > 0 ? accumulatedWidgets : void 0,
|
|
1874
|
-
metadata: { ...lastMessage.metadata, content_segments: segments }
|
|
2456
|
+
metadata: { ...lastMessage.metadata, content_segments: segments, isStreaming: true }
|
|
1875
2457
|
}
|
|
1876
2458
|
];
|
|
1877
2459
|
} else {
|
|
1878
2460
|
return [
|
|
1879
2461
|
...prev,
|
|
1880
2462
|
{
|
|
1881
|
-
id:
|
|
2463
|
+
id: streamingMessageId,
|
|
1882
2464
|
role: "assistant",
|
|
1883
2465
|
content: currentTextBuffer,
|
|
1884
2466
|
widgets: accumulatedWidgets.length > 0 ? accumulatedWidgets : void 0,
|
|
1885
2467
|
timestamp: /* @__PURE__ */ new Date(),
|
|
1886
|
-
metadata: { content_segments: segments }
|
|
2468
|
+
metadata: { content_segments: segments, isStreaming: true }
|
|
1887
2469
|
}
|
|
1888
2470
|
];
|
|
1889
2471
|
}
|
|
@@ -1895,7 +2477,7 @@ function Chat({
|
|
|
1895
2477
|
message: messagePayload,
|
|
1896
2478
|
stream: true,
|
|
1897
2479
|
...currentThreadId && { thread_id: currentThreadId },
|
|
1898
|
-
...
|
|
2480
|
+
...effectiveContext && { system: effectiveContext }
|
|
1899
2481
|
},
|
|
1900
2482
|
(chunk) => {
|
|
1901
2483
|
switch (chunk.type) {
|
|
@@ -1908,6 +2490,11 @@ function Chat({
|
|
|
1908
2490
|
}
|
|
1909
2491
|
}
|
|
1910
2492
|
break;
|
|
2493
|
+
case "request_id":
|
|
2494
|
+
if (chunk.request_id) {
|
|
2495
|
+
setCurrentRequestId(chunk.request_id);
|
|
2496
|
+
}
|
|
2497
|
+
break;
|
|
1911
2498
|
case "content":
|
|
1912
2499
|
case "token":
|
|
1913
2500
|
if (chunk.content) {
|
|
@@ -1923,6 +2510,7 @@ function Chat({
|
|
|
1923
2510
|
}
|
|
1924
2511
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: chunk.tool_name });
|
|
1925
2512
|
toolInputBuffer = "";
|
|
2513
|
+
setChatToolName(chunk.tool_name);
|
|
1926
2514
|
updateMessage();
|
|
1927
2515
|
}
|
|
1928
2516
|
break;
|
|
@@ -1938,6 +2526,7 @@ function Chat({
|
|
|
1938
2526
|
toolSegment.result = chunk.content;
|
|
1939
2527
|
onToolResult?.(toolSegment.name, chunk.content);
|
|
1940
2528
|
}
|
|
2529
|
+
setChatToolName(null);
|
|
1941
2530
|
updateMessage();
|
|
1942
2531
|
}
|
|
1943
2532
|
break;
|
|
@@ -1967,10 +2556,10 @@ function Chat({
|
|
|
1967
2556
|
...prev.slice(0, -1),
|
|
1968
2557
|
{
|
|
1969
2558
|
...lastMessage,
|
|
1970
|
-
|
|
2559
|
+
// Keep the same ID to avoid React remounting the component
|
|
1971
2560
|
content: currentTextBuffer || "Response received",
|
|
1972
2561
|
widgets: accumulatedWidgets.length > 0 ? accumulatedWidgets : void 0,
|
|
1973
|
-
metadata: { thread_id: threadId2, content_segments: contentSegments }
|
|
2562
|
+
metadata: { thread_id: threadId2, content_segments: contentSegments, isStreaming: false }
|
|
1974
2563
|
}
|
|
1975
2564
|
];
|
|
1976
2565
|
}
|
|
@@ -1981,6 +2570,8 @@ function Chat({
|
|
|
1981
2570
|
onThreadChange?.(threadId2);
|
|
1982
2571
|
}
|
|
1983
2572
|
setIsLoading(false);
|
|
2573
|
+
setCurrentRequestId(null);
|
|
2574
|
+
setChatToolName(null);
|
|
1984
2575
|
},
|
|
1985
2576
|
(error) => {
|
|
1986
2577
|
const errorMessage = {
|
|
@@ -1998,6 +2589,8 @@ function Chat({
|
|
|
1998
2589
|
return [...prev, errorMessage];
|
|
1999
2590
|
});
|
|
2000
2591
|
setIsLoading(false);
|
|
2592
|
+
setCurrentRequestId(null);
|
|
2593
|
+
setChatToolName(null);
|
|
2001
2594
|
onError?.(error);
|
|
2002
2595
|
}
|
|
2003
2596
|
);
|
|
@@ -2040,7 +2633,7 @@ function Chat({
|
|
|
2040
2633
|
} else {
|
|
2041
2634
|
try {
|
|
2042
2635
|
const planningInstruction = `CRITICAL PLANNING MODE: You are ONLY creating a plan. Write a numbered list of steps describing what WOULD be done. DO NOT execute anything.`;
|
|
2043
|
-
const systemMessage =
|
|
2636
|
+
const systemMessage = effectiveContext ? `${effectiveContext}
|
|
2044
2637
|
|
|
2045
2638
|
${planningInstruction}` : planningInstruction;
|
|
2046
2639
|
const response = await aptevaClient.chat({
|
|
@@ -2111,7 +2704,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2111
2704
|
}
|
|
2112
2705
|
} else {
|
|
2113
2706
|
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.`;
|
|
2114
|
-
const systemMessage =
|
|
2707
|
+
const systemMessage = effectiveContext ? `${effectiveContext}
|
|
2115
2708
|
|
|
2116
2709
|
${commandInstruction}` : commandInstruction;
|
|
2117
2710
|
const messagePayload = files && files.length > 0 ? await buildMessageWithAttachments(currentCommand, files) : currentCommand;
|
|
@@ -2146,6 +2739,8 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2146
2739
|
setCurrentThreadId(chunk.thread_id);
|
|
2147
2740
|
onThreadChange?.(chunk.thread_id);
|
|
2148
2741
|
}
|
|
2742
|
+
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
2743
|
+
setCurrentRequestId(chunk.request_id);
|
|
2149
2744
|
}
|
|
2150
2745
|
},
|
|
2151
2746
|
(threadId2) => {
|
|
@@ -2157,11 +2752,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2157
2752
|
setCommandResult(result);
|
|
2158
2753
|
setCommandState("success");
|
|
2159
2754
|
setProgress(100);
|
|
2755
|
+
setCurrentRequestId(null);
|
|
2160
2756
|
onComplete?.(result);
|
|
2161
2757
|
},
|
|
2162
2758
|
(error) => {
|
|
2163
2759
|
setCommandError(error);
|
|
2164
2760
|
setCommandState("error");
|
|
2761
|
+
setCurrentRequestId(null);
|
|
2165
2762
|
onError?.(error);
|
|
2166
2763
|
}
|
|
2167
2764
|
);
|
|
@@ -2218,11 +2815,34 @@ ${planToExecute}`;
|
|
|
2218
2815
|
setPendingCommand("");
|
|
2219
2816
|
setCommandState("idle");
|
|
2220
2817
|
};
|
|
2818
|
+
const handleStop = async () => {
|
|
2819
|
+
if (currentRequestId && agentId) {
|
|
2820
|
+
try {
|
|
2821
|
+
await aptevaClient.cancelRequest(agentId, currentRequestId);
|
|
2822
|
+
} catch (error) {
|
|
2823
|
+
console.error("Failed to cancel request:", error);
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
setIsLoading(false);
|
|
2827
|
+
if (commandState === "loading") {
|
|
2828
|
+
setCommandState("idle");
|
|
2829
|
+
setStreamedContent("");
|
|
2830
|
+
setCurrentToolName(null);
|
|
2831
|
+
setProgress(0);
|
|
2832
|
+
}
|
|
2833
|
+
setCurrentRequestId(null);
|
|
2834
|
+
};
|
|
2221
2835
|
const isCompact = commandVariant === "compact";
|
|
2222
|
-
return /* @__PURE__ */
|
|
2223
|
-
showHeader && mode === "chat" && /* @__PURE__ */
|
|
2224
|
-
|
|
2225
|
-
/* @__PURE__ */
|
|
2836
|
+
return /* @__PURE__ */ jsxs12("div", { className: cn("flex flex-col h-full", className), children: [
|
|
2837
|
+
showHeader && mode === "chat" && /* @__PURE__ */ jsx16("div", { className: "px-4 py-3 flex items-center justify-between", children: /* @__PURE__ */ jsxs12("div", { children: [
|
|
2838
|
+
/* @__PURE__ */ jsx16("h2", { className: "!text-lg font-semibold !text-gray-900 dark:!text-white", children: headerTitle }),
|
|
2839
|
+
/* @__PURE__ */ jsx16("p", { className: cn(
|
|
2840
|
+
"!text-xs",
|
|
2841
|
+
isLoading ? chatToolName ? "!text-blue-500 dark:!text-blue-400" : "!text-gray-400 dark:!text-gray-500" : "!text-gray-400 dark:!text-gray-500"
|
|
2842
|
+
), children: isLoading ? chatToolName ? `Using ${chatToolName}...` : "Thinking..." : "Ready" })
|
|
2843
|
+
] }) }),
|
|
2844
|
+
mode === "chat" && /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
2845
|
+
/* @__PURE__ */ jsx16(
|
|
2226
2846
|
MessageList,
|
|
2227
2847
|
{
|
|
2228
2848
|
messages,
|
|
@@ -2232,22 +2852,25 @@ ${planToExecute}`;
|
|
|
2232
2852
|
welcomeIcon,
|
|
2233
2853
|
suggestedPrompts,
|
|
2234
2854
|
welcomeVariant,
|
|
2235
|
-
onPromptClick: (prompt) => handleSendMessage(prompt)
|
|
2855
|
+
onPromptClick: (prompt) => handleSendMessage(prompt),
|
|
2856
|
+
enableWidgets,
|
|
2857
|
+
onWidgetRender
|
|
2236
2858
|
}
|
|
2237
2859
|
),
|
|
2238
|
-
|
|
2239
|
-
/* @__PURE__ */ jsx14(
|
|
2860
|
+
/* @__PURE__ */ jsx16(
|
|
2240
2861
|
Composer,
|
|
2241
2862
|
{
|
|
2242
2863
|
onSendMessage: handleSendMessage,
|
|
2243
2864
|
placeholder: placeholder || defaultPlaceholder,
|
|
2244
2865
|
disabled: isLoading,
|
|
2866
|
+
isLoading,
|
|
2867
|
+
onStop: handleStop,
|
|
2245
2868
|
onFileUpload,
|
|
2246
2869
|
onSwitchMode: showModeToggle ? () => handleModeChange("command") : void 0
|
|
2247
2870
|
}
|
|
2248
2871
|
)
|
|
2249
2872
|
] }),
|
|
2250
|
-
mode === "command" && /* @__PURE__ */
|
|
2873
|
+
mode === "command" && /* @__PURE__ */ jsx16("div", { className: "w-full", children: /* @__PURE__ */ jsx16(
|
|
2251
2874
|
CommandComposer,
|
|
2252
2875
|
{
|
|
2253
2876
|
onExecute: (text, files) => {
|
|
@@ -2263,11 +2886,12 @@ ${planToExecute}`;
|
|
|
2263
2886
|
onApprove: approvePlan,
|
|
2264
2887
|
onReject: rejectPlan,
|
|
2265
2888
|
onReset: resetCommand,
|
|
2889
|
+
onStop: handleStop,
|
|
2266
2890
|
onExpand: showModeToggle ? () => handleModeChange("chat") : void 0,
|
|
2267
2891
|
placeholder: placeholder || "Enter your command..."
|
|
2268
2892
|
}
|
|
2269
2893
|
) }),
|
|
2270
|
-
/* @__PURE__ */
|
|
2894
|
+
/* @__PURE__ */ jsx16("style", { dangerouslySetInnerHTML: {
|
|
2271
2895
|
__html: `
|
|
2272
2896
|
@keyframes pulse-border {
|
|
2273
2897
|
0%, 100% { border-color: rgb(59, 130, 246); }
|
|
@@ -2286,11 +2910,11 @@ ${planToExecute}`;
|
|
|
2286
2910
|
|
|
2287
2911
|
// src/components/Chat/CommandOutput.tsx
|
|
2288
2912
|
import { useState as useState4 } from "react";
|
|
2289
|
-
import { jsx as
|
|
2913
|
+
import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2290
2914
|
|
|
2291
2915
|
// src/components/Command/Command.tsx
|
|
2292
|
-
import React, { useState as useState5, useEffect as
|
|
2293
|
-
import { Fragment as
|
|
2916
|
+
import React, { useState as useState5, useEffect as useEffect5 } from "react";
|
|
2917
|
+
import { Fragment as Fragment5, jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2294
2918
|
function Command({
|
|
2295
2919
|
agentId,
|
|
2296
2920
|
command: initialCommand,
|
|
@@ -2330,15 +2954,15 @@ function Command({
|
|
|
2330
2954
|
const [showSettingsMenu, setShowSettingsMenu] = useState5(false);
|
|
2331
2955
|
const [internalPlanMode, setInternalPlanMode] = useState5(planMode);
|
|
2332
2956
|
const fileInputRef = React.useRef(null);
|
|
2333
|
-
|
|
2957
|
+
useEffect5(() => {
|
|
2334
2958
|
if (autoExecute && state === "idle" && command) {
|
|
2335
2959
|
executeCommand();
|
|
2336
2960
|
}
|
|
2337
2961
|
}, [autoExecute]);
|
|
2338
|
-
|
|
2962
|
+
useEffect5(() => {
|
|
2339
2963
|
setInternalPlanMode(planMode);
|
|
2340
2964
|
}, [planMode]);
|
|
2341
|
-
|
|
2965
|
+
useEffect5(() => {
|
|
2342
2966
|
const handleClickOutside = (event) => {
|
|
2343
2967
|
const target = event.target;
|
|
2344
2968
|
if (showSettingsMenu && !target.closest(".settings-menu-container")) {
|
|
@@ -2740,7 +3364,7 @@ ${planToExecute}`;
|
|
|
2740
3364
|
setUploadedFiles((prev) => prev.filter((_, i) => i !== index));
|
|
2741
3365
|
};
|
|
2742
3366
|
const isCompact = variant === "compact";
|
|
2743
|
-
return /* @__PURE__ */
|
|
3367
|
+
return /* @__PURE__ */ jsxs14(
|
|
2744
3368
|
"div",
|
|
2745
3369
|
{
|
|
2746
3370
|
className: cn(
|
|
@@ -2755,9 +3379,9 @@ ${planToExecute}`;
|
|
|
2755
3379
|
),
|
|
2756
3380
|
style: { minHeight: isCompact ? "auto" : "180px" },
|
|
2757
3381
|
children: [
|
|
2758
|
-
/* @__PURE__ */
|
|
2759
|
-
state === "idle" && allowInput && !isCompact && /* @__PURE__ */
|
|
2760
|
-
/* @__PURE__ */
|
|
3382
|
+
/* @__PURE__ */ jsxs14("div", { className: cn("flex-1 flex", isCompact ? "flex-row items-center p-3 gap-3" : "flex-col p-4"), children: [
|
|
3383
|
+
state === "idle" && allowInput && !isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3384
|
+
/* @__PURE__ */ jsx18(
|
|
2761
3385
|
"textarea",
|
|
2762
3386
|
{
|
|
2763
3387
|
value: command,
|
|
@@ -2773,42 +3397,42 @@ ${planToExecute}`;
|
|
|
2773
3397
|
rows: 6
|
|
2774
3398
|
}
|
|
2775
3399
|
),
|
|
2776
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
2777
|
-
file.type === "image" ? /* @__PURE__ */
|
|
3400
|
+
uploadedFiles.length > 0 && /* @__PURE__ */ jsx18("div", { className: "flex flex-wrap gap-2 mt-2", children: uploadedFiles.map((file, index) => /* @__PURE__ */ jsxs14("div", { className: "relative group", children: [
|
|
3401
|
+
file.type === "image" ? /* @__PURE__ */ jsx18(
|
|
2778
3402
|
"img",
|
|
2779
3403
|
{
|
|
2780
3404
|
src: file.preview,
|
|
2781
3405
|
alt: file.name,
|
|
2782
3406
|
className: "w-20 h-20 object-cover rounded-lg border-2 border-gray-300 dark:border-gray-600"
|
|
2783
3407
|
}
|
|
2784
|
-
) : /* @__PURE__ */
|
|
2785
|
-
/* @__PURE__ */
|
|
2786
|
-
/* @__PURE__ */
|
|
3408
|
+
) : /* @__PURE__ */ jsxs14("div", { className: "w-20 h-20 flex flex-col items-center justify-center rounded-lg border-2 border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800", children: [
|
|
3409
|
+
/* @__PURE__ */ jsx18("svg", { className: "w-8 h-8 text-gray-500 dark:text-gray-400", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx18("path", { fillRule: "evenodd", d: "M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z", clipRule: "evenodd" }) }),
|
|
3410
|
+
/* @__PURE__ */ jsx18("span", { className: "text-[8px] text-gray-500 dark:text-gray-400 mt-1 px-1 truncate max-w-full", children: file.name.length > 12 ? file.name.slice(0, 12) + "..." : file.name })
|
|
2787
3411
|
] }),
|
|
2788
|
-
/* @__PURE__ */
|
|
3412
|
+
/* @__PURE__ */ jsx18(
|
|
2789
3413
|
"button",
|
|
2790
3414
|
{
|
|
2791
3415
|
onClick: () => removeFile(index),
|
|
2792
3416
|
className: "absolute -top-2 -right-2 w-6 h-6 bg-red-500 hover:bg-red-600 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",
|
|
2793
3417
|
title: `Remove ${file.type}`,
|
|
2794
|
-
children: /* @__PURE__ */
|
|
3418
|
+
children: /* @__PURE__ */ jsx18("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
2795
3419
|
}
|
|
2796
3420
|
)
|
|
2797
3421
|
] }, index)) })
|
|
2798
3422
|
] }),
|
|
2799
|
-
state === "idle" && allowInput && isCompact && /* @__PURE__ */
|
|
2800
|
-
/* @__PURE__ */
|
|
2801
|
-
enableFileUpload && /* @__PURE__ */
|
|
3423
|
+
state === "idle" && allowInput && isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3424
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-0.5 flex-shrink-0", children: [
|
|
3425
|
+
enableFileUpload && /* @__PURE__ */ jsx18(
|
|
2802
3426
|
"button",
|
|
2803
3427
|
{
|
|
2804
3428
|
onClick: () => fileInputRef.current?.click(),
|
|
2805
3429
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-gray-500 dark:!text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
2806
3430
|
title: "Attach file",
|
|
2807
|
-
children: /* @__PURE__ */
|
|
3431
|
+
children: /* @__PURE__ */ jsx18("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx18("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)" }) })
|
|
2808
3432
|
}
|
|
2809
3433
|
),
|
|
2810
|
-
planMode && /* @__PURE__ */
|
|
2811
|
-
/* @__PURE__ */
|
|
3434
|
+
planMode && /* @__PURE__ */ jsxs14("div", { className: "relative settings-menu-container", children: [
|
|
3435
|
+
/* @__PURE__ */ jsx18(
|
|
2812
3436
|
"button",
|
|
2813
3437
|
{
|
|
2814
3438
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -2817,28 +3441,28 @@ ${planToExecute}`;
|
|
|
2817
3441
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-gray-500 dark:!text-gray-500"
|
|
2818
3442
|
),
|
|
2819
3443
|
title: "Settings",
|
|
2820
|
-
children: /* @__PURE__ */
|
|
2821
|
-
/* @__PURE__ */
|
|
2822
|
-
/* @__PURE__ */
|
|
2823
|
-
/* @__PURE__ */
|
|
2824
|
-
/* @__PURE__ */
|
|
2825
|
-
/* @__PURE__ */
|
|
2826
|
-
/* @__PURE__ */
|
|
2827
|
-
/* @__PURE__ */
|
|
2828
|
-
/* @__PURE__ */
|
|
2829
|
-
/* @__PURE__ */
|
|
3444
|
+
children: /* @__PURE__ */ jsxs14("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
3445
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
3446
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
3447
|
+
/* @__PURE__ */ jsx18("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
3448
|
+
/* @__PURE__ */ jsx18("line", { x1: "12", y1: "8", x2: "12", y2: "3" }),
|
|
3449
|
+
/* @__PURE__ */ jsx18("line", { x1: "20", y1: "21", x2: "20", y2: "16" }),
|
|
3450
|
+
/* @__PURE__ */ jsx18("line", { x1: "20", y1: "12", x2: "20", y2: "3" }),
|
|
3451
|
+
/* @__PURE__ */ jsx18("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
3452
|
+
/* @__PURE__ */ jsx18("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
3453
|
+
/* @__PURE__ */ jsx18("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
2830
3454
|
] })
|
|
2831
3455
|
}
|
|
2832
3456
|
),
|
|
2833
|
-
showSettingsMenu && /* @__PURE__ */
|
|
2834
|
-
/* @__PURE__ */
|
|
2835
|
-
/* @__PURE__ */
|
|
2836
|
-
/* @__PURE__ */
|
|
2837
|
-
/* @__PURE__ */
|
|
2838
|
-
/* @__PURE__ */
|
|
3457
|
+
showSettingsMenu && /* @__PURE__ */ jsx18("div", { className: "absolute top-10 left-0 z-50 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2.5 settings-menu-container", children: /* @__PURE__ */ jsxs14("label", { className: "flex items-center justify-between cursor-pointer group", children: [
|
|
3458
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
3459
|
+
/* @__PURE__ */ jsx18("svg", { className: "w-3.5 h-3.5 text-gray-500 dark:text-gray-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
3460
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
3461
|
+
/* @__PURE__ */ jsx18("div", { className: "text-xs font-medium text-gray-700 dark:text-gray-300", children: "Plan Mode" }),
|
|
3462
|
+
/* @__PURE__ */ jsx18("div", { className: "text-[10px] text-gray-500 dark:text-gray-400", children: "Review first" })
|
|
2839
3463
|
] })
|
|
2840
3464
|
] }),
|
|
2841
|
-
/* @__PURE__ */
|
|
3465
|
+
/* @__PURE__ */ jsx18(
|
|
2842
3466
|
"button",
|
|
2843
3467
|
{
|
|
2844
3468
|
onClick: (e) => {
|
|
@@ -2850,7 +3474,7 @@ ${planToExecute}`;
|
|
|
2850
3474
|
internalPlanMode ? "bg-blue-600" : "bg-gray-300 dark:bg-gray-600"
|
|
2851
3475
|
),
|
|
2852
3476
|
type: "button",
|
|
2853
|
-
children: /* @__PURE__ */
|
|
3477
|
+
children: /* @__PURE__ */ jsx18(
|
|
2854
3478
|
"span",
|
|
2855
3479
|
{
|
|
2856
3480
|
className: cn(
|
|
@@ -2864,26 +3488,26 @@ ${planToExecute}`;
|
|
|
2864
3488
|
] }) })
|
|
2865
3489
|
] })
|
|
2866
3490
|
] }),
|
|
2867
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
2868
|
-
file.type === "image" ? /* @__PURE__ */
|
|
3491
|
+
uploadedFiles.length > 0 && /* @__PURE__ */ jsx18("div", { className: "flex gap-1 flex-shrink-0", children: uploadedFiles.map((file, index) => /* @__PURE__ */ jsxs14("div", { className: "relative group", children: [
|
|
3492
|
+
file.type === "image" ? /* @__PURE__ */ jsx18(
|
|
2869
3493
|
"img",
|
|
2870
3494
|
{
|
|
2871
3495
|
src: file.preview,
|
|
2872
3496
|
alt: file.name,
|
|
2873
3497
|
className: "w-8 h-8 object-cover rounded border border-gray-300 dark:border-gray-600"
|
|
2874
3498
|
}
|
|
2875
|
-
) : /* @__PURE__ */
|
|
2876
|
-
/* @__PURE__ */
|
|
3499
|
+
) : /* @__PURE__ */ jsx18("div", { className: "w-8 h-8 flex items-center justify-center rounded border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800", title: file.name, children: /* @__PURE__ */ jsx18("svg", { className: "w-4 h-4 text-gray-500 dark:text-gray-400", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx18("path", { fillRule: "evenodd", d: "M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z", clipRule: "evenodd" }) }) }),
|
|
3500
|
+
/* @__PURE__ */ jsx18(
|
|
2877
3501
|
"button",
|
|
2878
3502
|
{
|
|
2879
3503
|
onClick: () => removeFile(index),
|
|
2880
3504
|
className: "absolute -top-1 -right-1 w-4 h-4 bg-red-500 hover:bg-red-600 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",
|
|
2881
3505
|
title: "Remove",
|
|
2882
|
-
children: /* @__PURE__ */
|
|
3506
|
+
children: /* @__PURE__ */ jsx18("svg", { className: "w-2.5 h-2.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 3, children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
|
|
2883
3507
|
}
|
|
2884
3508
|
)
|
|
2885
3509
|
] }, index)) }),
|
|
2886
|
-
/* @__PURE__ */
|
|
3510
|
+
/* @__PURE__ */ jsx18(
|
|
2887
3511
|
"input",
|
|
2888
3512
|
{
|
|
2889
3513
|
type: "text",
|
|
@@ -2899,7 +3523,7 @@ ${planToExecute}`;
|
|
|
2899
3523
|
className: "flex-1 bg-transparent border-none focus:outline-none !text-gray-900 dark:!text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 py-1"
|
|
2900
3524
|
}
|
|
2901
3525
|
),
|
|
2902
|
-
/* @__PURE__ */
|
|
3526
|
+
/* @__PURE__ */ jsx18(
|
|
2903
3527
|
"button",
|
|
2904
3528
|
{
|
|
2905
3529
|
onClick: () => executeCommand(),
|
|
@@ -2915,33 +3539,33 @@ ${planToExecute}`;
|
|
|
2915
3539
|
!command.trim() && "border-gray-200 dark:border-gray-700 !text-gray-400 dark:!text-gray-600"
|
|
2916
3540
|
),
|
|
2917
3541
|
title: "Execute",
|
|
2918
|
-
children: /* @__PURE__ */
|
|
3542
|
+
children: /* @__PURE__ */ jsx18("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx18("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2919
3543
|
}
|
|
2920
3544
|
)
|
|
2921
3545
|
] }),
|
|
2922
|
-
state === "loading" && !isCompact && /* @__PURE__ */
|
|
2923
|
-
/* @__PURE__ */
|
|
2924
|
-
/* @__PURE__ */
|
|
2925
|
-
showProgress && /* @__PURE__ */
|
|
2926
|
-
/* @__PURE__ */
|
|
3546
|
+
state === "loading" && !isCompact && /* @__PURE__ */ jsxs14("div", { className: "flex-1 flex flex-col items-center justify-center space-y-4 py-8", children: [
|
|
3547
|
+
/* @__PURE__ */ jsx18("div", { className: "w-6 h-6 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
3548
|
+
/* @__PURE__ */ jsx18("div", { className: "text-gray-600 dark:text-gray-400 text-sm text-center max-w-md", children: enableStreaming && streamedContent ? streamedContent : loadingText }),
|
|
3549
|
+
showProgress && /* @__PURE__ */ jsxs14("div", { className: "w-full max-w-sm", children: [
|
|
3550
|
+
/* @__PURE__ */ jsx18("div", { className: "w-full bg-gray-200 dark:bg-gray-700 rounded-full h-1.5", children: /* @__PURE__ */ jsx18(
|
|
2927
3551
|
"div",
|
|
2928
3552
|
{
|
|
2929
3553
|
className: "bg-blue-500 h-1.5 rounded-full transition-all duration-300",
|
|
2930
3554
|
style: { width: `${progress}%` }
|
|
2931
3555
|
}
|
|
2932
3556
|
) }),
|
|
2933
|
-
/* @__PURE__ */
|
|
3557
|
+
/* @__PURE__ */ jsxs14("p", { className: "text-xs text-gray-500 mt-2 text-center", children: [
|
|
2934
3558
|
progress,
|
|
2935
3559
|
"%"
|
|
2936
3560
|
] })
|
|
2937
3561
|
] })
|
|
2938
3562
|
] }),
|
|
2939
|
-
state === "loading" && isCompact && /* @__PURE__ */
|
|
2940
|
-
/* @__PURE__ */
|
|
2941
|
-
/* @__PURE__ */
|
|
2942
|
-
/* @__PURE__ */
|
|
3563
|
+
state === "loading" && isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3564
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex-1 flex items-center gap-3 py-1", children: [
|
|
3565
|
+
/* @__PURE__ */ jsx18("div", { className: "w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
3566
|
+
/* @__PURE__ */ jsx18("div", { className: "text-gray-600 dark:text-gray-400 text-sm truncate", children: enableStreaming && streamedContent ? streamedContent : loadingText })
|
|
2943
3567
|
] }),
|
|
2944
|
-
/* @__PURE__ */
|
|
3568
|
+
/* @__PURE__ */ jsx18(
|
|
2945
3569
|
"button",
|
|
2946
3570
|
{
|
|
2947
3571
|
disabled: true,
|
|
@@ -2953,20 +3577,20 @@ ${planToExecute}`;
|
|
|
2953
3577
|
"!text-lg",
|
|
2954
3578
|
"opacity-30 cursor-not-allowed"
|
|
2955
3579
|
),
|
|
2956
|
-
children: /* @__PURE__ */
|
|
3580
|
+
children: /* @__PURE__ */ jsx18("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx18("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2957
3581
|
}
|
|
2958
3582
|
)
|
|
2959
3583
|
] }),
|
|
2960
|
-
state === "plan-pending" && !isCompact && /* @__PURE__ */
|
|
2961
|
-
/* @__PURE__ */
|
|
2962
|
-
/* @__PURE__ */
|
|
2963
|
-
/* @__PURE__ */
|
|
2964
|
-
/* @__PURE__ */
|
|
2965
|
-
/* @__PURE__ */
|
|
3584
|
+
state === "plan-pending" && !isCompact && /* @__PURE__ */ jsx18("div", { className: "flex-1 flex flex-col", children: /* @__PURE__ */ jsxs14("div", { className: "mb-4 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg", children: [
|
|
3585
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-start gap-2 mb-3", children: [
|
|
3586
|
+
/* @__PURE__ */ jsx18("svg", { className: "w-5 h-5 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
3587
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex-1", children: [
|
|
3588
|
+
/* @__PURE__ */ jsx18("h3", { className: "text-sm font-semibold text-blue-800 dark:text-blue-300 mb-1", children: "Proposed Plan" }),
|
|
3589
|
+
/* @__PURE__ */ jsx18("div", { className: "text-blue-700 dark:text-blue-300 text-sm whitespace-pre-line leading-relaxed", children: plan })
|
|
2966
3590
|
] })
|
|
2967
3591
|
] }),
|
|
2968
|
-
/* @__PURE__ */
|
|
2969
|
-
/* @__PURE__ */
|
|
3592
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex gap-2 mt-4", children: [
|
|
3593
|
+
/* @__PURE__ */ jsx18(
|
|
2970
3594
|
"button",
|
|
2971
3595
|
{
|
|
2972
3596
|
onClick: approvePlan,
|
|
@@ -2974,7 +3598,7 @@ ${planToExecute}`;
|
|
|
2974
3598
|
children: "Approve & Execute"
|
|
2975
3599
|
}
|
|
2976
3600
|
),
|
|
2977
|
-
/* @__PURE__ */
|
|
3601
|
+
/* @__PURE__ */ jsx18(
|
|
2978
3602
|
"button",
|
|
2979
3603
|
{
|
|
2980
3604
|
onClick: rejectPlan,
|
|
@@ -2984,20 +3608,20 @@ ${planToExecute}`;
|
|
|
2984
3608
|
)
|
|
2985
3609
|
] })
|
|
2986
3610
|
] }) }),
|
|
2987
|
-
state === "plan-pending" && isCompact && /* @__PURE__ */
|
|
2988
|
-
/* @__PURE__ */
|
|
3611
|
+
state === "plan-pending" && isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3612
|
+
/* @__PURE__ */ jsxs14(
|
|
2989
3613
|
"button",
|
|
2990
3614
|
{
|
|
2991
3615
|
onClick: () => setShowPlanDetails(true),
|
|
2992
3616
|
className: "flex-1 flex items-center gap-2 px-3 py-2 bg-blue-50 dark:bg-blue-900/30 hover:bg-blue-100 dark:hover:bg-blue-900/40 border border-blue-200 dark:border-blue-800 rounded-lg transition-colors",
|
|
2993
3617
|
children: [
|
|
2994
|
-
/* @__PURE__ */
|
|
2995
|
-
/* @__PURE__ */
|
|
3618
|
+
/* @__PURE__ */ jsx18("svg", { className: "w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
3619
|
+
/* @__PURE__ */ jsx18("span", { className: "text-sm font-medium text-blue-700 dark:text-blue-300 truncate flex-1", children: "View Execution Plan" })
|
|
2996
3620
|
]
|
|
2997
3621
|
}
|
|
2998
3622
|
),
|
|
2999
|
-
/* @__PURE__ */
|
|
3000
|
-
/* @__PURE__ */
|
|
3623
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex gap-2 flex-shrink-0", children: [
|
|
3624
|
+
/* @__PURE__ */ jsx18(
|
|
3001
3625
|
"button",
|
|
3002
3626
|
{
|
|
3003
3627
|
onClick: approvePlan,
|
|
@@ -3005,7 +3629,7 @@ ${planToExecute}`;
|
|
|
3005
3629
|
children: "Approve"
|
|
3006
3630
|
}
|
|
3007
3631
|
),
|
|
3008
|
-
/* @__PURE__ */
|
|
3632
|
+
/* @__PURE__ */ jsx18(
|
|
3009
3633
|
"button",
|
|
3010
3634
|
{
|
|
3011
3635
|
onClick: rejectPlan,
|
|
@@ -3015,15 +3639,15 @@ ${planToExecute}`;
|
|
|
3015
3639
|
)
|
|
3016
3640
|
] })
|
|
3017
3641
|
] }),
|
|
3018
|
-
state === "error" && /* @__PURE__ */
|
|
3019
|
-
/* @__PURE__ */
|
|
3020
|
-
/* @__PURE__ */
|
|
3021
|
-
/* @__PURE__ */
|
|
3022
|
-
/* @__PURE__ */
|
|
3023
|
-
/* @__PURE__ */
|
|
3642
|
+
state === "error" && /* @__PURE__ */ jsxs14("div", { className: "flex-1 flex flex-col", children: [
|
|
3643
|
+
/* @__PURE__ */ jsx18("div", { className: "mb-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg", children: /* @__PURE__ */ jsxs14("div", { className: "flex items-start gap-2", children: [
|
|
3644
|
+
/* @__PURE__ */ jsx18("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__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
3645
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
3646
|
+
/* @__PURE__ */ jsx18("h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
|
|
3647
|
+
/* @__PURE__ */ jsx18("p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: error?.message })
|
|
3024
3648
|
] })
|
|
3025
3649
|
] }) }),
|
|
3026
|
-
allowInput && /* @__PURE__ */
|
|
3650
|
+
allowInput && /* @__PURE__ */ jsx18(
|
|
3027
3651
|
"textarea",
|
|
3028
3652
|
{
|
|
3029
3653
|
value: command,
|
|
@@ -3040,16 +3664,16 @@ ${planToExecute}`;
|
|
|
3040
3664
|
}
|
|
3041
3665
|
)
|
|
3042
3666
|
] }),
|
|
3043
|
-
state === "success" && result && !isCompact && /* @__PURE__ */
|
|
3044
|
-
/* @__PURE__ */
|
|
3045
|
-
/* @__PURE__ */
|
|
3046
|
-
/* @__PURE__ */
|
|
3047
|
-
/* @__PURE__ */
|
|
3048
|
-
/* @__PURE__ */
|
|
3667
|
+
state === "success" && result && !isCompact && /* @__PURE__ */ jsx18("div", { className: "flex-1 overflow-auto", children: resultRenderer ? resultRenderer(result.data) : /* @__PURE__ */ jsxs14("div", { className: "space-y-4", children: [
|
|
3668
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-start gap-3 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg", children: [
|
|
3669
|
+
/* @__PURE__ */ jsx18("svg", { className: "w-5 h-5 text-green-600 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
3670
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex-1", children: [
|
|
3671
|
+
/* @__PURE__ */ jsx18("h3", { className: "text-sm font-semibold text-green-800 dark:text-green-400 mb-1", children: "Success" }),
|
|
3672
|
+
/* @__PURE__ */ jsx18("p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
3049
3673
|
] })
|
|
3050
3674
|
] }),
|
|
3051
|
-
result.data?.summary && /* @__PURE__ */
|
|
3052
|
-
result.widgets && result.widgets.length > 0 && /* @__PURE__ */
|
|
3675
|
+
result.data?.summary && /* @__PURE__ */ jsx18("div", { className: "text-gray-700 dark:text-gray-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
|
|
3676
|
+
result.widgets && result.widgets.length > 0 && /* @__PURE__ */ jsx18("div", { className: "space-y-3", children: result.widgets.map((widget) => /* @__PURE__ */ jsx18(
|
|
3053
3677
|
WidgetRenderer,
|
|
3054
3678
|
{
|
|
3055
3679
|
widget,
|
|
@@ -3058,8 +3682,8 @@ ${planToExecute}`;
|
|
|
3058
3682
|
widget.id
|
|
3059
3683
|
)) })
|
|
3060
3684
|
] }) }),
|
|
3061
|
-
state === "success" && result && isCompact && /* @__PURE__ */
|
|
3062
|
-
/* @__PURE__ */
|
|
3685
|
+
state === "success" && result && isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3686
|
+
/* @__PURE__ */ jsxs14(
|
|
3063
3687
|
"div",
|
|
3064
3688
|
{
|
|
3065
3689
|
className: "flex-1 flex items-center gap-2 py-1 cursor-text min-w-0",
|
|
@@ -3068,12 +3692,12 @@ ${planToExecute}`;
|
|
|
3068
3692
|
setResult(null);
|
|
3069
3693
|
},
|
|
3070
3694
|
children: [
|
|
3071
|
-
/* @__PURE__ */
|
|
3072
|
-
/* @__PURE__ */
|
|
3695
|
+
/* @__PURE__ */ jsx18("svg", { className: "w-4 h-4 text-green-600 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
3696
|
+
/* @__PURE__ */ jsx18("div", { className: "text-green-700 dark:text-green-300 text-sm truncate flex-1 min-w-0", children: resultRenderer ? resultRenderer(result.data) : result.message || "Command executed successfully" })
|
|
3073
3697
|
]
|
|
3074
3698
|
}
|
|
3075
3699
|
),
|
|
3076
|
-
/* @__PURE__ */
|
|
3700
|
+
/* @__PURE__ */ jsx18(
|
|
3077
3701
|
"button",
|
|
3078
3702
|
{
|
|
3079
3703
|
onClick: () => {
|
|
@@ -3089,24 +3713,24 @@ ${planToExecute}`;
|
|
|
3089
3713
|
"!text-lg"
|
|
3090
3714
|
),
|
|
3091
3715
|
title: "New command",
|
|
3092
|
-
children: /* @__PURE__ */
|
|
3716
|
+
children: /* @__PURE__ */ jsx18("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx18("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
3093
3717
|
}
|
|
3094
3718
|
)
|
|
3095
3719
|
] })
|
|
3096
3720
|
] }),
|
|
3097
|
-
!isCompact && /* @__PURE__ */
|
|
3098
|
-
/* @__PURE__ */
|
|
3099
|
-
enableFileUpload && /* @__PURE__ */
|
|
3721
|
+
!isCompact && /* @__PURE__ */ jsxs14("div", { className: "p-3 flex items-center justify-between gap-2", children: [
|
|
3722
|
+
/* @__PURE__ */ jsx18("div", { className: "flex items-center gap-1", children: state === "idle" && allowInput && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3723
|
+
enableFileUpload && /* @__PURE__ */ jsx18(
|
|
3100
3724
|
"button",
|
|
3101
3725
|
{
|
|
3102
3726
|
onClick: () => fileInputRef.current?.click(),
|
|
3103
3727
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-gray-500 dark:!text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
3104
3728
|
title: "Attach file",
|
|
3105
|
-
children: /* @__PURE__ */
|
|
3729
|
+
children: /* @__PURE__ */ jsx18("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx18("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)" }) })
|
|
3106
3730
|
}
|
|
3107
3731
|
),
|
|
3108
|
-
planMode && /* @__PURE__ */
|
|
3109
|
-
/* @__PURE__ */
|
|
3732
|
+
planMode && /* @__PURE__ */ jsxs14("div", { className: "relative settings-menu-container", children: [
|
|
3733
|
+
/* @__PURE__ */ jsx18(
|
|
3110
3734
|
"button",
|
|
3111
3735
|
{
|
|
3112
3736
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -3115,28 +3739,28 @@ ${planToExecute}`;
|
|
|
3115
3739
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-gray-500 dark:!text-gray-500"
|
|
3116
3740
|
),
|
|
3117
3741
|
title: "Settings",
|
|
3118
|
-
children: /* @__PURE__ */
|
|
3119
|
-
/* @__PURE__ */
|
|
3120
|
-
/* @__PURE__ */
|
|
3121
|
-
/* @__PURE__ */
|
|
3122
|
-
/* @__PURE__ */
|
|
3123
|
-
/* @__PURE__ */
|
|
3124
|
-
/* @__PURE__ */
|
|
3125
|
-
/* @__PURE__ */
|
|
3126
|
-
/* @__PURE__ */
|
|
3127
|
-
/* @__PURE__ */
|
|
3742
|
+
children: /* @__PURE__ */ jsxs14("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
3743
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
3744
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
3745
|
+
/* @__PURE__ */ jsx18("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
3746
|
+
/* @__PURE__ */ jsx18("line", { x1: "12", y1: "8", x2: "12", y2: "3" }),
|
|
3747
|
+
/* @__PURE__ */ jsx18("line", { x1: "20", y1: "21", x2: "20", y2: "16" }),
|
|
3748
|
+
/* @__PURE__ */ jsx18("line", { x1: "20", y1: "12", x2: "20", y2: "3" }),
|
|
3749
|
+
/* @__PURE__ */ jsx18("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
3750
|
+
/* @__PURE__ */ jsx18("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
3751
|
+
/* @__PURE__ */ jsx18("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
3128
3752
|
] })
|
|
3129
3753
|
}
|
|
3130
3754
|
),
|
|
3131
|
-
showSettingsMenu && /* @__PURE__ */
|
|
3132
|
-
/* @__PURE__ */
|
|
3133
|
-
/* @__PURE__ */
|
|
3134
|
-
/* @__PURE__ */
|
|
3135
|
-
/* @__PURE__ */
|
|
3136
|
-
/* @__PURE__ */
|
|
3755
|
+
showSettingsMenu && /* @__PURE__ */ jsx18("div", { className: "absolute top-10 left-0 z-50 w-64 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 settings-menu-container", children: /* @__PURE__ */ jsxs14("label", { className: "flex items-center justify-between cursor-pointer group", children: [
|
|
3756
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
3757
|
+
/* @__PURE__ */ jsx18("svg", { className: "w-4 h-4 text-gray-500 dark:text-gray-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
3758
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
3759
|
+
/* @__PURE__ */ jsx18("div", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: "Plan Mode" }),
|
|
3760
|
+
/* @__PURE__ */ jsx18("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: "Review before executing" })
|
|
3137
3761
|
] })
|
|
3138
3762
|
] }),
|
|
3139
|
-
/* @__PURE__ */
|
|
3763
|
+
/* @__PURE__ */ jsx18(
|
|
3140
3764
|
"button",
|
|
3141
3765
|
{
|
|
3142
3766
|
onClick: (e) => {
|
|
@@ -3148,7 +3772,7 @@ ${planToExecute}`;
|
|
|
3148
3772
|
internalPlanMode ? "bg-blue-600" : "bg-gray-300 dark:bg-gray-600"
|
|
3149
3773
|
),
|
|
3150
3774
|
type: "button",
|
|
3151
|
-
children: /* @__PURE__ */
|
|
3775
|
+
children: /* @__PURE__ */ jsx18(
|
|
3152
3776
|
"span",
|
|
3153
3777
|
{
|
|
3154
3778
|
className: cn(
|
|
@@ -3162,9 +3786,9 @@ ${planToExecute}`;
|
|
|
3162
3786
|
] }) })
|
|
3163
3787
|
] })
|
|
3164
3788
|
] }) }),
|
|
3165
|
-
!(state === "idle" && allowInput) && /* @__PURE__ */
|
|
3166
|
-
/* @__PURE__ */
|
|
3167
|
-
(state === "success" || state === "error") && allowInput && /* @__PURE__ */
|
|
3789
|
+
!(state === "idle" && allowInput) && /* @__PURE__ */ jsx18("div", {}),
|
|
3790
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
3791
|
+
(state === "success" || state === "error") && allowInput && /* @__PURE__ */ jsx18(
|
|
3168
3792
|
"button",
|
|
3169
3793
|
{
|
|
3170
3794
|
onClick: resetCommand,
|
|
@@ -3172,7 +3796,7 @@ ${planToExecute}`;
|
|
|
3172
3796
|
children: "Reset"
|
|
3173
3797
|
}
|
|
3174
3798
|
),
|
|
3175
|
-
(state === "idle" || state === "error") && /* @__PURE__ */
|
|
3799
|
+
(state === "idle" || state === "error") && /* @__PURE__ */ jsx18(
|
|
3176
3800
|
"button",
|
|
3177
3801
|
{
|
|
3178
3802
|
onClick: () => executeCommand(),
|
|
@@ -3188,29 +3812,29 @@ ${planToExecute}`;
|
|
|
3188
3812
|
!command.trim() && "border-gray-200 dark:border-gray-700 !text-gray-400 dark:!text-gray-600"
|
|
3189
3813
|
),
|
|
3190
3814
|
title: state === "error" ? "Retry" : "Execute",
|
|
3191
|
-
children: state === "error" ? /* @__PURE__ */
|
|
3815
|
+
children: state === "error" ? /* @__PURE__ */ jsx18("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx18("path", { d: "M13 8C13 10.7614 10.7614 13 8 13C5.23858 13 3 10.7614 3 8C3 5.23858 5.23858 3 8 3C9.65685 3 11.1257 3.82818 12 5.09091M12 3V5.09091M12 5.09091H9.81818", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) : /* @__PURE__ */ jsx18("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx18("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
3192
3816
|
}
|
|
3193
3817
|
)
|
|
3194
3818
|
] })
|
|
3195
3819
|
] }),
|
|
3196
|
-
showPlanDetails && isCompact && state === "plan-pending" && /* @__PURE__ */
|
|
3197
|
-
/* @__PURE__ */
|
|
3198
|
-
/* @__PURE__ */
|
|
3199
|
-
/* @__PURE__ */
|
|
3200
|
-
/* @__PURE__ */
|
|
3820
|
+
showPlanDetails && isCompact && state === "plan-pending" && /* @__PURE__ */ jsx18("div", { className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4", onClick: () => setShowPlanDetails(false), children: /* @__PURE__ */ jsxs14("div", { className: "bg-white dark:bg-gray-900 rounded-2xl shadow-2xl max-w-2xl w-full max-h-[80vh] overflow-hidden", onClick: (e) => e.stopPropagation(), children: [
|
|
3821
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700", children: [
|
|
3822
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-3", children: [
|
|
3823
|
+
/* @__PURE__ */ jsx18("svg", { className: "w-6 h-6 text-blue-600 dark:text-blue-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" }) }),
|
|
3824
|
+
/* @__PURE__ */ jsx18("h2", { className: "text-xl font-semibold text-gray-900 dark:text-white", children: "Proposed Execution Plan" })
|
|
3201
3825
|
] }),
|
|
3202
|
-
/* @__PURE__ */
|
|
3826
|
+
/* @__PURE__ */ jsx18(
|
|
3203
3827
|
"button",
|
|
3204
3828
|
{
|
|
3205
3829
|
onClick: () => setShowPlanDetails(false),
|
|
3206
3830
|
className: "text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",
|
|
3207
|
-
children: /* @__PURE__ */
|
|
3831
|
+
children: /* @__PURE__ */ jsx18("svg", { className: "w-6 h-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
3208
3832
|
}
|
|
3209
3833
|
)
|
|
3210
3834
|
] }),
|
|
3211
|
-
/* @__PURE__ */
|
|
3212
|
-
/* @__PURE__ */
|
|
3213
|
-
/* @__PURE__ */
|
|
3835
|
+
/* @__PURE__ */ jsx18("div", { className: "p-6 overflow-y-auto max-h-[calc(80vh-180px)]", children: /* @__PURE__ */ jsx18("div", { className: "prose prose-sm dark:prose-invert max-w-none", children: /* @__PURE__ */ jsx18("div", { className: "text-gray-700 dark:text-gray-300 whitespace-pre-line leading-relaxed", children: plan }) }) }),
|
|
3836
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-end gap-3 p-6 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50", children: [
|
|
3837
|
+
/* @__PURE__ */ jsx18(
|
|
3214
3838
|
"button",
|
|
3215
3839
|
{
|
|
3216
3840
|
onClick: rejectPlan,
|
|
@@ -3218,7 +3842,7 @@ ${planToExecute}`;
|
|
|
3218
3842
|
children: "Modify Command"
|
|
3219
3843
|
}
|
|
3220
3844
|
),
|
|
3221
|
-
/* @__PURE__ */
|
|
3845
|
+
/* @__PURE__ */ jsx18(
|
|
3222
3846
|
"button",
|
|
3223
3847
|
{
|
|
3224
3848
|
onClick: approvePlan,
|
|
@@ -3228,7 +3852,7 @@ ${planToExecute}`;
|
|
|
3228
3852
|
)
|
|
3229
3853
|
] })
|
|
3230
3854
|
] }) }),
|
|
3231
|
-
/* @__PURE__ */
|
|
3855
|
+
/* @__PURE__ */ jsx18(
|
|
3232
3856
|
"input",
|
|
3233
3857
|
{
|
|
3234
3858
|
ref: fileInputRef,
|
|
@@ -3239,7 +3863,7 @@ ${planToExecute}`;
|
|
|
3239
3863
|
accept: "image/*,application/pdf,.doc,.docx,.txt"
|
|
3240
3864
|
}
|
|
3241
3865
|
),
|
|
3242
|
-
/* @__PURE__ */
|
|
3866
|
+
/* @__PURE__ */ jsx18("style", { dangerouslySetInnerHTML: {
|
|
3243
3867
|
__html: `
|
|
3244
3868
|
@keyframes pulse-border {
|
|
3245
3869
|
0%, 100% {
|
|
@@ -3261,7 +3885,7 @@ ${planToExecute}`;
|
|
|
3261
3885
|
|
|
3262
3886
|
// src/components/Prompt/Prompt.tsx
|
|
3263
3887
|
import { useState as useState6 } from "react";
|
|
3264
|
-
import { jsx as
|
|
3888
|
+
import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3265
3889
|
function Prompt({
|
|
3266
3890
|
agentId,
|
|
3267
3891
|
placeholder = "Enter your prompt...",
|
|
@@ -3323,9 +3947,9 @@ function Prompt({
|
|
|
3323
3947
|
handleSubmit();
|
|
3324
3948
|
}
|
|
3325
3949
|
};
|
|
3326
|
-
return /* @__PURE__ */
|
|
3327
|
-
/* @__PURE__ */
|
|
3328
|
-
/* @__PURE__ */
|
|
3950
|
+
return /* @__PURE__ */ jsxs15("div", { className: cn("space-y-2", className), children: [
|
|
3951
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex gap-2", children: [
|
|
3952
|
+
/* @__PURE__ */ jsx19(
|
|
3329
3953
|
"input",
|
|
3330
3954
|
{
|
|
3331
3955
|
type: "text",
|
|
@@ -3338,7 +3962,7 @@ function Prompt({
|
|
|
3338
3962
|
className: "flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-apteva-500 dark:bg-gray-800 dark:border-gray-600 dark:text-white"
|
|
3339
3963
|
}
|
|
3340
3964
|
),
|
|
3341
|
-
submitOn === "button" && /* @__PURE__ */
|
|
3965
|
+
submitOn === "button" && /* @__PURE__ */ jsx19(
|
|
3342
3966
|
"button",
|
|
3343
3967
|
{
|
|
3344
3968
|
onClick: handleSubmit,
|
|
@@ -3348,13 +3972,13 @@ function Prompt({
|
|
|
3348
3972
|
}
|
|
3349
3973
|
)
|
|
3350
3974
|
] }),
|
|
3351
|
-
maxLength && /* @__PURE__ */
|
|
3975
|
+
maxLength && /* @__PURE__ */ jsxs15("p", { className: "text-xs text-gray-500", children: [
|
|
3352
3976
|
value.length,
|
|
3353
3977
|
" / ",
|
|
3354
3978
|
maxLength,
|
|
3355
3979
|
" characters"
|
|
3356
3980
|
] }),
|
|
3357
|
-
showSuggestions && !value && /* @__PURE__ */
|
|
3981
|
+
showSuggestions && !value && /* @__PURE__ */ jsx19("div", { className: "flex flex-wrap gap-2", children: suggestions.map((suggestion, idx) => /* @__PURE__ */ jsx19(
|
|
3358
3982
|
"button",
|
|
3359
3983
|
{
|
|
3360
3984
|
onClick: () => setValue(suggestion),
|
|
@@ -3363,16 +3987,16 @@ function Prompt({
|
|
|
3363
3987
|
},
|
|
3364
3988
|
idx
|
|
3365
3989
|
)) }),
|
|
3366
|
-
isLoading && /* @__PURE__ */
|
|
3367
|
-
/* @__PURE__ */
|
|
3368
|
-
/* @__PURE__ */
|
|
3990
|
+
isLoading && /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 text-sm text-gray-500", children: [
|
|
3991
|
+
/* @__PURE__ */ jsx19("div", { className: "w-4 h-4 border-2 border-apteva-500 border-t-transparent rounded-full animate-spin" }),
|
|
3992
|
+
/* @__PURE__ */ jsx19("span", { children: "AI is processing your request..." })
|
|
3369
3993
|
] })
|
|
3370
3994
|
] });
|
|
3371
3995
|
}
|
|
3372
3996
|
|
|
3373
3997
|
// src/components/Stream/Stream.tsx
|
|
3374
|
-
import { useState as useState7, useEffect as
|
|
3375
|
-
import { jsx as
|
|
3998
|
+
import { useState as useState7, useEffect as useEffect6 } from "react";
|
|
3999
|
+
import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3376
4000
|
function Stream({
|
|
3377
4001
|
agentId,
|
|
3378
4002
|
prompt,
|
|
@@ -3391,7 +4015,7 @@ function Stream({
|
|
|
3391
4015
|
const [text, setText] = useState7("");
|
|
3392
4016
|
const [isStreaming, setIsStreaming] = useState7(false);
|
|
3393
4017
|
const [isComplete, setIsComplete] = useState7(false);
|
|
3394
|
-
|
|
4018
|
+
useEffect6(() => {
|
|
3395
4019
|
if (autoStart && !isStreaming && !isComplete) {
|
|
3396
4020
|
startStreaming();
|
|
3397
4021
|
}
|
|
@@ -3452,7 +4076,7 @@ function Stream({
|
|
|
3452
4076
|
plain: "text-gray-900 dark:text-gray-100"
|
|
3453
4077
|
};
|
|
3454
4078
|
if (!isStreaming && !isComplete) {
|
|
3455
|
-
return /* @__PURE__ */
|
|
4079
|
+
return /* @__PURE__ */ jsx20("div", { className: cn("p-4", className), children: /* @__PURE__ */ jsx20(
|
|
3456
4080
|
"button",
|
|
3457
4081
|
{
|
|
3458
4082
|
onClick: startStreaming,
|
|
@@ -3461,9 +4085,9 @@ function Stream({
|
|
|
3461
4085
|
}
|
|
3462
4086
|
) });
|
|
3463
4087
|
}
|
|
3464
|
-
return /* @__PURE__ */
|
|
4088
|
+
return /* @__PURE__ */ jsxs16("div", { className: cn(variantClasses[variant], className), children: [
|
|
3465
4089
|
text,
|
|
3466
|
-
isStreaming && showCursor && /* @__PURE__ */
|
|
4090
|
+
isStreaming && showCursor && /* @__PURE__ */ jsx20("span", { className: "apteva-stream-cursor" })
|
|
3467
4091
|
] });
|
|
3468
4092
|
}
|
|
3469
4093
|
|
|
@@ -3471,9 +4095,9 @@ function Stream({
|
|
|
3471
4095
|
import { useState as useState8 } from "react";
|
|
3472
4096
|
|
|
3473
4097
|
// src/components/Threads/ThreadItem.tsx
|
|
3474
|
-
import { jsx as
|
|
4098
|
+
import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3475
4099
|
function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
3476
|
-
return /* @__PURE__ */
|
|
4100
|
+
return /* @__PURE__ */ jsxs17(
|
|
3477
4101
|
"div",
|
|
3478
4102
|
{
|
|
3479
4103
|
className: cn("apteva-thread-item", {
|
|
@@ -3481,19 +4105,19 @@ function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
|
3481
4105
|
}),
|
|
3482
4106
|
onClick: onSelect,
|
|
3483
4107
|
children: [
|
|
3484
|
-
/* @__PURE__ */
|
|
3485
|
-
/* @__PURE__ */
|
|
3486
|
-
thread.preview && /* @__PURE__ */
|
|
3487
|
-
/* @__PURE__ */
|
|
3488
|
-
/* @__PURE__ */
|
|
4108
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-1 min-w-0", children: [
|
|
4109
|
+
/* @__PURE__ */ jsx21("h4", { className: "font-semibold text-gray-900 dark:text-white truncate", children: thread.title }),
|
|
4110
|
+
thread.preview && /* @__PURE__ */ jsx21("p", { className: "text-sm text-gray-600 dark:text-gray-400 truncate", children: thread.preview }),
|
|
4111
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2 mt-1 text-xs text-gray-500", children: [
|
|
4112
|
+
/* @__PURE__ */ jsxs17("span", { children: [
|
|
3489
4113
|
thread.messageCount,
|
|
3490
4114
|
" messages"
|
|
3491
4115
|
] }),
|
|
3492
|
-
/* @__PURE__ */
|
|
3493
|
-
/* @__PURE__ */
|
|
4116
|
+
/* @__PURE__ */ jsx21("span", { children: "\u2022" }),
|
|
4117
|
+
/* @__PURE__ */ jsx21("span", { children: formatRelativeTime(thread.updatedAt) })
|
|
3494
4118
|
] })
|
|
3495
4119
|
] }),
|
|
3496
|
-
onDelete && /* @__PURE__ */
|
|
4120
|
+
onDelete && /* @__PURE__ */ jsx21(
|
|
3497
4121
|
"button",
|
|
3498
4122
|
{
|
|
3499
4123
|
onClick: (e) => {
|
|
@@ -3523,7 +4147,7 @@ function formatRelativeTime(date) {
|
|
|
3523
4147
|
}
|
|
3524
4148
|
|
|
3525
4149
|
// src/components/Threads/ThreadList.tsx
|
|
3526
|
-
import { jsx as
|
|
4150
|
+
import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3527
4151
|
function ThreadList({
|
|
3528
4152
|
threads,
|
|
3529
4153
|
currentThreadId,
|
|
@@ -3537,8 +4161,8 @@ function ThreadList({
|
|
|
3537
4161
|
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || thread.preview?.toLowerCase().includes(searchQuery.toLowerCase())
|
|
3538
4162
|
);
|
|
3539
4163
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
3540
|
-
return /* @__PURE__ */
|
|
3541
|
-
showSearch && /* @__PURE__ */
|
|
4164
|
+
return /* @__PURE__ */ jsxs18("div", { className: "flex flex-col h-full", children: [
|
|
4165
|
+
showSearch && /* @__PURE__ */ jsx22("div", { className: "p-3 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsx22(
|
|
3542
4166
|
"input",
|
|
3543
4167
|
{
|
|
3544
4168
|
type: "text",
|
|
@@ -3548,10 +4172,10 @@ function ThreadList({
|
|
|
3548
4172
|
className: "w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-apteva-500 dark:bg-gray-800 dark:border-gray-600 dark:text-white"
|
|
3549
4173
|
}
|
|
3550
4174
|
) }),
|
|
3551
|
-
/* @__PURE__ */
|
|
3552
|
-
Object.entries(groupedThreads).map(([group, groupThreads]) => /* @__PURE__ */
|
|
3553
|
-
groupBy !== "none" && /* @__PURE__ */
|
|
3554
|
-
groupThreads.map((thread) => /* @__PURE__ */
|
|
4175
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1 overflow-y-auto", children: [
|
|
4176
|
+
Object.entries(groupedThreads).map(([group, groupThreads]) => /* @__PURE__ */ jsxs18("div", { children: [
|
|
4177
|
+
groupBy !== "none" && /* @__PURE__ */ jsx22("div", { className: "px-3 py-2 text-xs font-semibold text-gray-500 uppercase", children: group }),
|
|
4178
|
+
groupThreads.map((thread) => /* @__PURE__ */ jsx22(
|
|
3555
4179
|
ThreadItem,
|
|
3556
4180
|
{
|
|
3557
4181
|
thread,
|
|
@@ -3562,9 +4186,9 @@ function ThreadList({
|
|
|
3562
4186
|
thread.id
|
|
3563
4187
|
))
|
|
3564
4188
|
] }, group)),
|
|
3565
|
-
filteredThreads.length === 0 && /* @__PURE__ */
|
|
3566
|
-
/* @__PURE__ */
|
|
3567
|
-
/* @__PURE__ */
|
|
4189
|
+
filteredThreads.length === 0 && /* @__PURE__ */ jsxs18("div", { className: "p-8 text-center text-gray-500", children: [
|
|
4190
|
+
/* @__PURE__ */ jsx22("svg", { className: "w-10 h-10 mx-auto mb-2 opacity-50", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx22("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }),
|
|
4191
|
+
/* @__PURE__ */ jsx22("p", { children: "No conversations found" })
|
|
3568
4192
|
] })
|
|
3569
4193
|
] })
|
|
3570
4194
|
] });
|
|
@@ -3596,7 +4220,7 @@ function groupThreadsByDate(threads) {
|
|
|
3596
4220
|
}
|
|
3597
4221
|
|
|
3598
4222
|
// src/components/Threads/Threads.tsx
|
|
3599
|
-
import { jsx as
|
|
4223
|
+
import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3600
4224
|
function Threads({
|
|
3601
4225
|
threads,
|
|
3602
4226
|
currentThreadId,
|
|
@@ -3615,8 +4239,8 @@ function Threads({
|
|
|
3615
4239
|
tabs: "flex gap-2 border-b border-gray-200 dark:border-gray-700 overflow-x-auto"
|
|
3616
4240
|
};
|
|
3617
4241
|
if (variant === "tabs") {
|
|
3618
|
-
return /* @__PURE__ */
|
|
3619
|
-
threads.slice(0, 5).map((thread) => /* @__PURE__ */
|
|
4242
|
+
return /* @__PURE__ */ jsxs19("div", { className: cn(variantClasses[variant], className), children: [
|
|
4243
|
+
threads.slice(0, 5).map((thread) => /* @__PURE__ */ jsx23(
|
|
3620
4244
|
"button",
|
|
3621
4245
|
{
|
|
3622
4246
|
onClick: () => onThreadSelect?.(thread.id),
|
|
@@ -3628,7 +4252,7 @@ function Threads({
|
|
|
3628
4252
|
},
|
|
3629
4253
|
thread.id
|
|
3630
4254
|
)),
|
|
3631
|
-
showNewButton && onNewThread && /* @__PURE__ */
|
|
4255
|
+
showNewButton && onNewThread && /* @__PURE__ */ jsx23(
|
|
3632
4256
|
"button",
|
|
3633
4257
|
{
|
|
3634
4258
|
onClick: onNewThread,
|
|
@@ -3638,8 +4262,8 @@ function Threads({
|
|
|
3638
4262
|
)
|
|
3639
4263
|
] });
|
|
3640
4264
|
}
|
|
3641
|
-
return /* @__PURE__ */
|
|
3642
|
-
showNewButton && onNewThread && /* @__PURE__ */
|
|
4265
|
+
return /* @__PURE__ */ jsxs19("div", { className: cn(variantClasses[variant], "flex flex-col", className), children: [
|
|
4266
|
+
showNewButton && onNewThread && /* @__PURE__ */ jsx23("div", { className: "p-3 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsx23(
|
|
3643
4267
|
"button",
|
|
3644
4268
|
{
|
|
3645
4269
|
onClick: onNewThread,
|
|
@@ -3647,7 +4271,7 @@ function Threads({
|
|
|
3647
4271
|
children: "+ New Conversation"
|
|
3648
4272
|
}
|
|
3649
4273
|
) }),
|
|
3650
|
-
/* @__PURE__ */
|
|
4274
|
+
/* @__PURE__ */ jsx23(
|
|
3651
4275
|
ThreadList,
|
|
3652
4276
|
{
|
|
3653
4277
|
threads,
|