@apteva/apteva-kit 0.1.17 → 0.1.18
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 +575 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +837 -349
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ 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 useEffect3, useRef as useRef4 } from "react";
|
|
7
|
+
import { useState as useState3, useEffect as useEffect3, useRef as useRef4, useMemo } from "react";
|
|
8
8
|
|
|
9
9
|
// src/components/Chat/MessageList.tsx
|
|
10
10
|
import { useEffect as useEffect2, useRef } from "react";
|
|
@@ -498,6 +498,237 @@ function validateFile(file) {
|
|
|
498
498
|
return { valid: true };
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
+
// src/utils/widget-parser.ts
|
|
502
|
+
function findMatchingBracket(text, startIndex) {
|
|
503
|
+
let depth = 0;
|
|
504
|
+
let inString = false;
|
|
505
|
+
let escapeNext = false;
|
|
506
|
+
for (let i = startIndex; i < text.length; i++) {
|
|
507
|
+
const char = text[i];
|
|
508
|
+
if (escapeNext) {
|
|
509
|
+
escapeNext = false;
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
if (char === "\\" && inString) {
|
|
513
|
+
escapeNext = true;
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
if (char === '"') {
|
|
517
|
+
inString = !inString;
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
if (inString) continue;
|
|
521
|
+
if (char === "[" || char === "{") {
|
|
522
|
+
depth++;
|
|
523
|
+
} else if (char === "]" || char === "}") {
|
|
524
|
+
depth--;
|
|
525
|
+
if (depth === 0) {
|
|
526
|
+
return i;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return -1;
|
|
531
|
+
}
|
|
532
|
+
function parseWidgetsFromText(text) {
|
|
533
|
+
const segments = [];
|
|
534
|
+
let hasWidgets = false;
|
|
535
|
+
let hasPendingWidget = false;
|
|
536
|
+
let currentIndex = 0;
|
|
537
|
+
let pendingWidgetType = null;
|
|
538
|
+
let processText = text;
|
|
539
|
+
const lastWidgetStart = text.lastIndexOf("@ui:");
|
|
540
|
+
if (lastWidgetStart !== -1) {
|
|
541
|
+
const afterStart = text.slice(lastWidgetStart);
|
|
542
|
+
const typeMatch = afterStart.match(/^@ui:(\w+)/);
|
|
543
|
+
if (typeMatch) {
|
|
544
|
+
const widgetType = typeMatch[1];
|
|
545
|
+
const bracketOpenIndex = afterStart.indexOf("[");
|
|
546
|
+
if (bracketOpenIndex === -1) {
|
|
547
|
+
processText = text.slice(0, lastWidgetStart);
|
|
548
|
+
pendingWidgetType = widgetType;
|
|
549
|
+
hasPendingWidget = true;
|
|
550
|
+
} else {
|
|
551
|
+
const fullBracketStart = lastWidgetStart + bracketOpenIndex;
|
|
552
|
+
const bracketEnd = findMatchingBracket(text, fullBracketStart);
|
|
553
|
+
if (bracketEnd === -1) {
|
|
554
|
+
processText = text.slice(0, lastWidgetStart);
|
|
555
|
+
pendingWidgetType = widgetType;
|
|
556
|
+
hasPendingWidget = true;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (hasPendingWidget) {
|
|
562
|
+
processText = processText.replace(/[\s:;\-–—\.]+$/g, "");
|
|
563
|
+
}
|
|
564
|
+
const startPattern = /@ui:(\w+)\[/g;
|
|
565
|
+
let match;
|
|
566
|
+
while ((match = startPattern.exec(processText)) !== null) {
|
|
567
|
+
const widgetType = match[1];
|
|
568
|
+
const bracketStart = match.index + match[0].length - 1;
|
|
569
|
+
const bracketEnd = findMatchingBracket(processText, bracketStart);
|
|
570
|
+
if (bracketEnd === -1) {
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
const jsonContent = processText.slice(bracketStart + 1, bracketEnd);
|
|
574
|
+
if (match.index > currentIndex) {
|
|
575
|
+
const textContent = processText.slice(currentIndex, match.index).trim();
|
|
576
|
+
if (textContent) {
|
|
577
|
+
segments.push({
|
|
578
|
+
type: "text",
|
|
579
|
+
content: textContent
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
try {
|
|
584
|
+
const trimmedJson = jsonContent.trim();
|
|
585
|
+
const props = JSON.parse(trimmedJson);
|
|
586
|
+
const widgetId = `widget-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
587
|
+
segments.push({
|
|
588
|
+
type: "widget",
|
|
589
|
+
widget: {
|
|
590
|
+
type: widgetType,
|
|
591
|
+
id: widgetId,
|
|
592
|
+
props
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
hasWidgets = true;
|
|
596
|
+
} catch (e) {
|
|
597
|
+
}
|
|
598
|
+
currentIndex = bracketEnd + 1;
|
|
599
|
+
startPattern.lastIndex = currentIndex;
|
|
600
|
+
}
|
|
601
|
+
if (currentIndex < processText.length) {
|
|
602
|
+
const remainingText = processText.slice(currentIndex).trim();
|
|
603
|
+
if (remainingText) {
|
|
604
|
+
segments.push({
|
|
605
|
+
type: "text",
|
|
606
|
+
content: remainingText
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
if (segments.length === 0 && processText.trim()) {
|
|
611
|
+
segments.push({
|
|
612
|
+
type: "text",
|
|
613
|
+
content: processText.trim()
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
if (pendingWidgetType) {
|
|
617
|
+
segments.push({
|
|
618
|
+
type: "widget_pending",
|
|
619
|
+
pendingType: pendingWidgetType
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
return { segments, hasWidgets, hasPendingWidget };
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// src/utils/widget-context.ts
|
|
626
|
+
var WIDGET_DEFINITIONS = {
|
|
627
|
+
card: {
|
|
628
|
+
description: "Displays a card with title and optional description, image, footer",
|
|
629
|
+
schema: '{"title": "string", "description?": "string", "image?": "url", "footer?": "string"}',
|
|
630
|
+
example: '@ui:card[{"title": "Summary", "description": "Key findings from the analysis"}]'
|
|
631
|
+
},
|
|
632
|
+
list: {
|
|
633
|
+
description: "Displays a list of items with title, subtitle, and optional description",
|
|
634
|
+
schema: '{"items": [{"id": "string", "title": "string", "subtitle?": "string", "description?": "string", "image?": "url"}]}',
|
|
635
|
+
example: '@ui:list[{"items": [{"id": "1", "title": "First item", "subtitle": "Details"}]}]'
|
|
636
|
+
},
|
|
637
|
+
button_group: {
|
|
638
|
+
description: "Displays action buttons. User clicks are sent back to you with the button id",
|
|
639
|
+
schema: '{"buttons": [{"id": "string", "label": "string", "variant?": "primary|secondary|outline"}], "layout?": "horizontal|vertical"}',
|
|
640
|
+
example: '@ui:button_group[{"buttons": [{"id": "confirm", "label": "Confirm", "variant": "primary"}, {"id": "cancel", "label": "Cancel"}]}]'
|
|
641
|
+
},
|
|
642
|
+
form: {
|
|
643
|
+
description: "Displays an input form. Submitted data is sent back to you",
|
|
644
|
+
schema: '{"title?": "string", "fields": [{"name": "string", "type": "text|number|select|checkbox|textarea|date", "label": "string", "required?": boolean, "placeholder?": "string", "options?": [{"label": "string", "value": "string"}]}]}',
|
|
645
|
+
example: '@ui:form[{"title": "Contact", "fields": [{"name": "email", "type": "text", "label": "Email", "required": true}]}]'
|
|
646
|
+
},
|
|
647
|
+
image: {
|
|
648
|
+
description: "Displays a single image with optional caption",
|
|
649
|
+
schema: '{"src": "url", "alt": "string", "caption?": "string"}',
|
|
650
|
+
example: '@ui:image[{"src": "https://example.com/img.png", "alt": "Description", "caption": "Figure 1"}]'
|
|
651
|
+
},
|
|
652
|
+
gallery: {
|
|
653
|
+
description: "Displays multiple images in a grid or carousel layout",
|
|
654
|
+
schema: '{"images": [{"id": "string", "src": "url", "alt": "string", "caption?": "string"}], "layout?": "grid|carousel"}',
|
|
655
|
+
example: '@ui:gallery[{"images": [{"id": "1", "src": "https://example.com/1.png", "alt": "Image 1"}], "layout": "grid"}]'
|
|
656
|
+
},
|
|
657
|
+
chart: {
|
|
658
|
+
description: "Displays a chart visualization (line, bar, pie, doughnut)",
|
|
659
|
+
schema: '{"chartType": "line|bar|pie|doughnut", "title?": "string", "data": {"labels": ["string"], "datasets": [{"label": "string", "data": [number], "backgroundColor?": "string|string[]"}]}}',
|
|
660
|
+
example: '@ui:chart[{"chartType": "bar", "title": "Sales", "data": {"labels": ["Q1", "Q2"], "datasets": [{"label": "Revenue", "data": [100, 150]}]}}]'
|
|
661
|
+
},
|
|
662
|
+
map: {
|
|
663
|
+
description: "Displays an interactive map with optional markers",
|
|
664
|
+
schema: '{"center": {"lat": number, "lng": number}, "zoom?": number, "markers?": [{"id": "string", "position": {"lat": number, "lng": number}, "title": "string"}]}',
|
|
665
|
+
example: '@ui:map[{"center": {"lat": 40.7128, "lng": -74.0060}, "zoom": 12, "markers": [{"id": "1", "position": {"lat": 40.7128, "lng": -74.0060}, "title": "NYC"}]}]'
|
|
666
|
+
},
|
|
667
|
+
table: {
|
|
668
|
+
description: "Displays structured data in rows and columns",
|
|
669
|
+
schema: '{"columns": [{"key": "string", "label": "string", "align?": "left|center|right"}], "rows": [{"id?": "string", ...}], "caption?": "string", "compact?": boolean, "striped?": boolean}',
|
|
670
|
+
example: '@ui:table[{"columns": [{"key": "name", "label": "Name"}, {"key": "status", "label": "Status"}], "rows": [{"name": "Item 1", "status": "Active"}, {"name": "Item 2", "status": "Pending"}]}]'
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
var ALL_WIDGET_TYPES = Object.keys(WIDGET_DEFINITIONS);
|
|
674
|
+
function generateWidgetContext(enabledWidgets) {
|
|
675
|
+
const widgets = enabledWidgets || ALL_WIDGET_TYPES;
|
|
676
|
+
let context = `
|
|
677
|
+
## Available UI Widgets
|
|
678
|
+
|
|
679
|
+
`;
|
|
680
|
+
context += `You can render rich UI components in your responses using this syntax: @ui:type[{json_props}]
|
|
681
|
+
|
|
682
|
+
`;
|
|
683
|
+
context += `The widget syntax will be automatically converted to interactive UI. Users see the rendered widget, not the raw syntax.
|
|
684
|
+
|
|
685
|
+
`;
|
|
686
|
+
context += `### Available widgets:
|
|
687
|
+
|
|
688
|
+
`;
|
|
689
|
+
for (const type of widgets) {
|
|
690
|
+
const def = WIDGET_DEFINITIONS[type];
|
|
691
|
+
if (!def) continue;
|
|
692
|
+
context += `**${type}** - ${def.description}
|
|
693
|
+
`;
|
|
694
|
+
context += `Schema: \`${def.schema}\`
|
|
695
|
+
`;
|
|
696
|
+
context += `Example: \`${def.example}\`
|
|
697
|
+
|
|
698
|
+
`;
|
|
699
|
+
}
|
|
700
|
+
context += `### Important notes:
|
|
701
|
+
`;
|
|
702
|
+
context += `- JSON must be valid (use double quotes for strings)
|
|
703
|
+
`;
|
|
704
|
+
context += `- Widget actions (button clicks, form submissions) are sent back to you
|
|
705
|
+
`;
|
|
706
|
+
context += `- You can include multiple widgets in a single response
|
|
707
|
+
`;
|
|
708
|
+
context += `- Combine widgets with regular text for context
|
|
709
|
+
`;
|
|
710
|
+
return context;
|
|
711
|
+
}
|
|
712
|
+
function generateCompactWidgetContext(enabledWidgets) {
|
|
713
|
+
const widgets = enabledWidgets || ALL_WIDGET_TYPES;
|
|
714
|
+
let context = `
|
|
715
|
+
UI Widgets: Use @ui:type[{props}] syntax.
|
|
716
|
+
`;
|
|
717
|
+
context += `Available: ${widgets.join(", ")}
|
|
718
|
+
`;
|
|
719
|
+
context += `Examples:
|
|
720
|
+
`;
|
|
721
|
+
const examples = ["card", "list", "button_group"].filter((w) => widgets.includes(w));
|
|
722
|
+
for (const type of examples) {
|
|
723
|
+
const def = WIDGET_DEFINITIONS[type];
|
|
724
|
+
if (def) {
|
|
725
|
+
context += `${def.example}
|
|
726
|
+
`;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return context;
|
|
730
|
+
}
|
|
731
|
+
|
|
501
732
|
// src/components/Widgets/Widgets.tsx
|
|
502
733
|
import { useEffect } from "react";
|
|
503
734
|
|
|
@@ -642,31 +873,109 @@ function ButtonGroup({ widget, onAction }) {
|
|
|
642
873
|
);
|
|
643
874
|
}
|
|
644
875
|
|
|
645
|
-
// src/components/Widgets/
|
|
876
|
+
// src/components/Widgets/widget-library/Table.tsx
|
|
646
877
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
878
|
+
function Table({ widget, onAction }) {
|
|
879
|
+
const { columns, rows, caption, compact = false, striped = false } = widget.props;
|
|
880
|
+
const getAlignment = (align) => {
|
|
881
|
+
switch (align) {
|
|
882
|
+
case "center":
|
|
883
|
+
return "text-center";
|
|
884
|
+
case "right":
|
|
885
|
+
return "text-right";
|
|
886
|
+
default:
|
|
887
|
+
return "text-left";
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
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: [
|
|
891
|
+
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 }),
|
|
892
|
+
/* @__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(
|
|
893
|
+
"th",
|
|
894
|
+
{
|
|
895
|
+
className: cn(
|
|
896
|
+
"font-semibold text-gray-900 dark:text-white",
|
|
897
|
+
compact ? "px-3 py-2 text-xs" : "px-4 py-3 text-sm",
|
|
898
|
+
getAlignment(column.align)
|
|
899
|
+
),
|
|
900
|
+
style: column.width ? { width: column.width } : void 0,
|
|
901
|
+
children: column.label
|
|
902
|
+
},
|
|
903
|
+
column.key
|
|
904
|
+
)) }) }),
|
|
905
|
+
/* @__PURE__ */ jsxs3("tbody", { children: [
|
|
906
|
+
rows.map((row, rowIndex) => /* @__PURE__ */ jsx5(
|
|
907
|
+
"tr",
|
|
908
|
+
{
|
|
909
|
+
className: cn(
|
|
910
|
+
"border-b border-gray-200 dark:border-gray-700 last:border-b-0",
|
|
911
|
+
"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800",
|
|
912
|
+
striped && rowIndex % 2 === 1 && "bg-gray-50/50 dark:bg-gray-800/50"
|
|
913
|
+
),
|
|
914
|
+
onClick: () => {
|
|
915
|
+
if (widget.actions && widget.actions.length > 0) {
|
|
916
|
+
onAction?.({
|
|
917
|
+
type: widget.actions[0].type,
|
|
918
|
+
payload: row,
|
|
919
|
+
widgetId: widget.id,
|
|
920
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
},
|
|
924
|
+
style: { cursor: widget.actions?.length ? "pointer" : "default" },
|
|
925
|
+
children: columns.map((column) => /* @__PURE__ */ jsx5(
|
|
926
|
+
"td",
|
|
927
|
+
{
|
|
928
|
+
className: cn(
|
|
929
|
+
"text-gray-700 dark:text-gray-300",
|
|
930
|
+
compact ? "px-3 py-2 text-xs" : "px-4 py-3 text-sm",
|
|
931
|
+
getAlignment(column.align)
|
|
932
|
+
),
|
|
933
|
+
children: row[column.key] ?? "\u2014"
|
|
934
|
+
},
|
|
935
|
+
column.key
|
|
936
|
+
))
|
|
937
|
+
},
|
|
938
|
+
row.id || rowIndex
|
|
939
|
+
)),
|
|
940
|
+
rows.length === 0 && /* @__PURE__ */ jsx5("tr", { children: /* @__PURE__ */ jsx5(
|
|
941
|
+
"td",
|
|
942
|
+
{
|
|
943
|
+
colSpan: columns.length,
|
|
944
|
+
className: "px-4 py-8 text-center text-sm text-gray-500 dark:text-gray-400",
|
|
945
|
+
children: "No data available"
|
|
946
|
+
}
|
|
947
|
+
) })
|
|
948
|
+
] })
|
|
949
|
+
] }) }) });
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
// src/components/Widgets/WidgetRenderer.tsx
|
|
953
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
647
954
|
function WidgetRenderer({ widget, onAction }) {
|
|
648
955
|
switch (widget.type) {
|
|
649
956
|
case "card":
|
|
650
|
-
return /* @__PURE__ */
|
|
957
|
+
return /* @__PURE__ */ jsx6(Card, { widget, onAction });
|
|
651
958
|
case "list":
|
|
652
|
-
return /* @__PURE__ */
|
|
959
|
+
return /* @__PURE__ */ jsx6(List, { widget, onAction });
|
|
653
960
|
case "button":
|
|
654
|
-
return /* @__PURE__ */
|
|
961
|
+
return /* @__PURE__ */ jsx6(Button, { widget, onAction });
|
|
655
962
|
case "button_group":
|
|
656
|
-
return /* @__PURE__ */
|
|
963
|
+
return /* @__PURE__ */ jsx6(ButtonGroup, { widget, onAction });
|
|
964
|
+
case "table":
|
|
965
|
+
return /* @__PURE__ */ jsx6(Table, { widget, onAction });
|
|
657
966
|
default:
|
|
658
|
-
return /* @__PURE__ */
|
|
659
|
-
/* @__PURE__ */
|
|
967
|
+
return /* @__PURE__ */ jsxs4("div", { className: "p-4 border border-yellow-300 bg-yellow-50 rounded-lg", children: [
|
|
968
|
+
/* @__PURE__ */ jsxs4("p", { className: "text-sm text-yellow-800", children: [
|
|
660
969
|
"Unknown widget type: ",
|
|
661
970
|
widget.type
|
|
662
971
|
] }),
|
|
663
|
-
/* @__PURE__ */
|
|
972
|
+
/* @__PURE__ */ jsx6("pre", { className: "text-xs mt-2 overflow-auto", children: JSON.stringify(widget, null, 2) })
|
|
664
973
|
] });
|
|
665
974
|
}
|
|
666
975
|
}
|
|
667
976
|
|
|
668
977
|
// src/components/Widgets/Widgets.tsx
|
|
669
|
-
import { jsx as
|
|
978
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
670
979
|
function Widgets({
|
|
671
980
|
widgets,
|
|
672
981
|
onAction,
|
|
@@ -691,11 +1000,85 @@ function Widgets({
|
|
|
691
1000
|
normal: "gap-4",
|
|
692
1001
|
loose: "gap-6"
|
|
693
1002
|
};
|
|
694
|
-
return /* @__PURE__ */
|
|
1003
|
+
return /* @__PURE__ */ jsx7("div", { className: cn(layoutClasses[layout], spacingClasses[spacing], className), children: widgets.map((widget) => /* @__PURE__ */ jsx7(WidgetRenderer, { widget, onAction }, widget.id)) });
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// src/components/Widgets/WidgetSkeleton.tsx
|
|
1007
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1008
|
+
function WidgetSkeleton({ type, className }) {
|
|
1009
|
+
switch (type) {
|
|
1010
|
+
case "card":
|
|
1011
|
+
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: [
|
|
1012
|
+
/* @__PURE__ */ jsx8("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-3/4" }),
|
|
1013
|
+
/* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-full" }),
|
|
1014
|
+
/* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-5/6" })
|
|
1015
|
+
] }) });
|
|
1016
|
+
case "list":
|
|
1017
|
+
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: [
|
|
1018
|
+
/* @__PURE__ */ jsx8("div", { className: "w-10 h-10 bg-gray-200 dark:bg-gray-700 rounded-full flex-shrink-0" }),
|
|
1019
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex-1 space-y-2", children: [
|
|
1020
|
+
/* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-1/2" }),
|
|
1021
|
+
/* @__PURE__ */ jsx8("div", { className: "h-2 bg-gray-200 dark:bg-gray-700 rounded w-3/4" })
|
|
1022
|
+
] })
|
|
1023
|
+
] }, i)) });
|
|
1024
|
+
case "button_group":
|
|
1025
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("animate-pulse flex gap-2", className), children: [
|
|
1026
|
+
/* @__PURE__ */ jsx8("div", { className: "h-9 bg-gray-200 dark:bg-gray-700 rounded-lg w-20" }),
|
|
1027
|
+
/* @__PURE__ */ jsx8("div", { className: "h-9 bg-gray-200 dark:bg-gray-700 rounded-lg w-20" }),
|
|
1028
|
+
/* @__PURE__ */ jsx8("div", { className: "h-9 bg-gray-200 dark:bg-gray-700 rounded-lg w-20" })
|
|
1029
|
+
] });
|
|
1030
|
+
case "form":
|
|
1031
|
+
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: [
|
|
1032
|
+
/* @__PURE__ */ jsx8("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/3" }),
|
|
1033
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-3", children: [
|
|
1034
|
+
/* @__PURE__ */ jsx8("div", { className: "h-10 bg-gray-200 dark:bg-gray-700 rounded" }),
|
|
1035
|
+
/* @__PURE__ */ jsx8("div", { className: "h-10 bg-gray-200 dark:bg-gray-700 rounded" })
|
|
1036
|
+
] }),
|
|
1037
|
+
/* @__PURE__ */ jsx8("div", { className: "h-9 bg-gray-200 dark:bg-gray-700 rounded w-24" })
|
|
1038
|
+
] });
|
|
1039
|
+
case "chart":
|
|
1040
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("animate-pulse rounded-lg border border-gray-200 dark:border-gray-700 p-4", className), children: [
|
|
1041
|
+
/* @__PURE__ */ jsx8("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/4 mb-4" }),
|
|
1042
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-end gap-2 h-32", children: [
|
|
1043
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-1/2" }),
|
|
1044
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-3/4" }),
|
|
1045
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-1/3" }),
|
|
1046
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-full" }),
|
|
1047
|
+
/* @__PURE__ */ jsx8("div", { className: "flex-1 bg-gray-200 dark:bg-gray-700 rounded-t h-2/3" })
|
|
1048
|
+
] })
|
|
1049
|
+
] });
|
|
1050
|
+
case "image":
|
|
1051
|
+
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" }) });
|
|
1052
|
+
case "gallery":
|
|
1053
|
+
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)) });
|
|
1054
|
+
case "map":
|
|
1055
|
+
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: [
|
|
1056
|
+
/* @__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" }),
|
|
1057
|
+
/* @__PURE__ */ jsx8("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z" })
|
|
1058
|
+
] }) }) });
|
|
1059
|
+
case "table":
|
|
1060
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("animate-pulse rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden", className), children: [
|
|
1061
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex bg-gray-100 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700", children: [
|
|
1062
|
+
/* @__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" }) }),
|
|
1063
|
+
/* @__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" }) }),
|
|
1064
|
+
/* @__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" }) })
|
|
1065
|
+
] }),
|
|
1066
|
+
[1, 2, 3].map((i) => /* @__PURE__ */ jsxs5("div", { className: "flex border-b border-gray-200 dark:border-gray-700 last:border-b-0", children: [
|
|
1067
|
+
/* @__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" }) }),
|
|
1068
|
+
/* @__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" }) }),
|
|
1069
|
+
/* @__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" }) })
|
|
1070
|
+
] }, i))
|
|
1071
|
+
] });
|
|
1072
|
+
default:
|
|
1073
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("animate-pulse rounded-lg border border-gray-200 dark:border-gray-700 p-4", className), children: [
|
|
1074
|
+
/* @__PURE__ */ jsx8("div", { className: "h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/2 mb-2" }),
|
|
1075
|
+
/* @__PURE__ */ jsx8("div", { className: "h-3 bg-gray-200 dark:bg-gray-700 rounded w-full" })
|
|
1076
|
+
] });
|
|
1077
|
+
}
|
|
695
1078
|
}
|
|
696
1079
|
|
|
697
1080
|
// src/components/Chat/MarkdownContent.tsx
|
|
698
|
-
import { jsx as
|
|
1081
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
699
1082
|
function parseInlineMarkdown(text, keyPrefix = "") {
|
|
700
1083
|
const result = [];
|
|
701
1084
|
const boldRegex = /(\*\*|__)(.+?)\1/g;
|
|
@@ -706,7 +1089,7 @@ function parseInlineMarkdown(text, keyPrefix = "") {
|
|
|
706
1089
|
if (match.index > lastIndex) {
|
|
707
1090
|
result.push(text.slice(lastIndex, match.index));
|
|
708
1091
|
}
|
|
709
|
-
result.push(/* @__PURE__ */
|
|
1092
|
+
result.push(/* @__PURE__ */ jsx9("strong", { children: match[2] }, `${keyPrefix}b${key++}`));
|
|
710
1093
|
lastIndex = match.index + match[0].length;
|
|
711
1094
|
}
|
|
712
1095
|
if (lastIndex < text.length) {
|
|
@@ -724,7 +1107,7 @@ function parseMarkdown(content) {
|
|
|
724
1107
|
const h2Match = line.match(/^##\s+(.*)$/);
|
|
725
1108
|
if (h2Match) {
|
|
726
1109
|
result.push(
|
|
727
|
-
/* @__PURE__ */
|
|
1110
|
+
/* @__PURE__ */ jsx9("h2", { className: "apteva-md-h2", children: parseInlineMarkdown(h2Match[1], `${key}`) }, `h2${key++}`)
|
|
728
1111
|
);
|
|
729
1112
|
i++;
|
|
730
1113
|
continue;
|
|
@@ -732,7 +1115,7 @@ function parseMarkdown(content) {
|
|
|
732
1115
|
const h3Match = line.match(/^###\s+(.*)$/);
|
|
733
1116
|
if (h3Match) {
|
|
734
1117
|
result.push(
|
|
735
|
-
/* @__PURE__ */
|
|
1118
|
+
/* @__PURE__ */ jsx9("h3", { className: "apteva-md-h3", children: parseInlineMarkdown(h3Match[1], `${key}`) }, `h3${key++}`)
|
|
736
1119
|
);
|
|
737
1120
|
i++;
|
|
738
1121
|
continue;
|
|
@@ -745,7 +1128,7 @@ function parseMarkdown(content) {
|
|
|
745
1128
|
const itemMatch = lines[i].match(/^(\s*)([-*+])\s+(.*)$/);
|
|
746
1129
|
if (itemMatch && itemMatch[1].length === indent) {
|
|
747
1130
|
listItems.push(
|
|
748
|
-
/* @__PURE__ */
|
|
1131
|
+
/* @__PURE__ */ jsx9("li", { className: "apteva-md-li", children: parseInlineMarkdown(itemMatch[3], `${key}`) }, `li${key++}`)
|
|
749
1132
|
);
|
|
750
1133
|
i++;
|
|
751
1134
|
} else {
|
|
@@ -753,7 +1136,7 @@ function parseMarkdown(content) {
|
|
|
753
1136
|
}
|
|
754
1137
|
}
|
|
755
1138
|
result.push(
|
|
756
|
-
/* @__PURE__ */
|
|
1139
|
+
/* @__PURE__ */ jsx9("ul", { className: "apteva-md-ul", children: listItems }, `ul${key++}`)
|
|
757
1140
|
);
|
|
758
1141
|
continue;
|
|
759
1142
|
}
|
|
@@ -765,7 +1148,7 @@ function parseMarkdown(content) {
|
|
|
765
1148
|
const itemMatch = lines[i].match(/^(\s*)(\d+)\.\s+(.*)$/);
|
|
766
1149
|
if (itemMatch && itemMatch[1].length === indent) {
|
|
767
1150
|
listItems.push(
|
|
768
|
-
/* @__PURE__ */
|
|
1151
|
+
/* @__PURE__ */ jsx9("li", { className: "apteva-md-li", children: parseInlineMarkdown(itemMatch[3], `${key}`) }, `li${key++}`)
|
|
769
1152
|
);
|
|
770
1153
|
i++;
|
|
771
1154
|
} else {
|
|
@@ -773,7 +1156,7 @@ function parseMarkdown(content) {
|
|
|
773
1156
|
}
|
|
774
1157
|
}
|
|
775
1158
|
result.push(
|
|
776
|
-
/* @__PURE__ */
|
|
1159
|
+
/* @__PURE__ */ jsx9("ol", { className: "apteva-md-ol", children: listItems }, `ol${key++}`)
|
|
777
1160
|
);
|
|
778
1161
|
continue;
|
|
779
1162
|
}
|
|
@@ -796,19 +1179,19 @@ function parseMarkdown(content) {
|
|
|
796
1179
|
}
|
|
797
1180
|
}
|
|
798
1181
|
result.push(
|
|
799
|
-
/* @__PURE__ */
|
|
800
|
-
/* @__PURE__ */
|
|
801
|
-
/* @__PURE__ */
|
|
1182
|
+
/* @__PURE__ */ jsx9("div", { className: "apteva-md-table-wrapper", children: /* @__PURE__ */ jsxs6("table", { className: "apteva-md-table", children: [
|
|
1183
|
+
/* @__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}`)) }) }),
|
|
1184
|
+
/* @__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
1185
|
] }) }, `table-wrapper${key++}`)
|
|
803
1186
|
);
|
|
804
1187
|
continue;
|
|
805
1188
|
}
|
|
806
1189
|
}
|
|
807
1190
|
if (line === "") {
|
|
808
|
-
result.push(/* @__PURE__ */
|
|
1191
|
+
result.push(/* @__PURE__ */ jsx9("br", {}, `br${key++}`));
|
|
809
1192
|
} else {
|
|
810
1193
|
result.push(
|
|
811
|
-
/* @__PURE__ */
|
|
1194
|
+
/* @__PURE__ */ jsxs6("span", { children: [
|
|
812
1195
|
parseInlineMarkdown(line, `${key}`),
|
|
813
1196
|
i < lines.length - 1 ? "\n" : ""
|
|
814
1197
|
] }, `p${key++}`)
|
|
@@ -819,38 +1202,59 @@ function parseMarkdown(content) {
|
|
|
819
1202
|
return result;
|
|
820
1203
|
}
|
|
821
1204
|
function MarkdownContent({ content, className = "" }) {
|
|
822
|
-
return /* @__PURE__ */
|
|
1205
|
+
return /* @__PURE__ */ jsx9("div", { className: `apteva-md ${className}`, children: parseMarkdown(content) });
|
|
823
1206
|
}
|
|
824
1207
|
|
|
825
1208
|
// src/components/Chat/ToolCall.tsx
|
|
826
|
-
import { jsx as
|
|
1209
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
827
1210
|
function ToolCall({ name, status }) {
|
|
828
|
-
return /* @__PURE__ */
|
|
829
|
-
status === "running" && /* @__PURE__ */
|
|
830
|
-
status === "completed" && /* @__PURE__ */
|
|
831
|
-
status === "error" && /* @__PURE__ */
|
|
832
|
-
/* @__PURE__ */
|
|
833
|
-
status === "running" && /* @__PURE__ */
|
|
834
|
-
status === "completed" && /* @__PURE__ */
|
|
835
|
-
status === "error" && /* @__PURE__ */
|
|
1211
|
+
return /* @__PURE__ */ jsxs7("div", { className: "apteva-tool-call", children: [
|
|
1212
|
+
status === "running" && /* @__PURE__ */ jsx10("div", { className: "apteva-tool-call-dot apteva-tool-call-dot-running" }),
|
|
1213
|
+
status === "completed" && /* @__PURE__ */ jsx10("div", { className: "apteva-tool-call-dot apteva-tool-call-dot-completed" }),
|
|
1214
|
+
status === "error" && /* @__PURE__ */ jsx10("div", { className: "apteva-tool-call-dot apteva-tool-call-dot-error" }),
|
|
1215
|
+
/* @__PURE__ */ jsx10("span", { className: "apteva-tool-call-name", children: name }),
|
|
1216
|
+
status === "running" && /* @__PURE__ */ jsx10("span", { className: "apteva-tool-call-status", children: "Running..." }),
|
|
1217
|
+
status === "completed" && /* @__PURE__ */ jsx10("span", { className: "apteva-tool-call-status apteva-tool-call-status-completed", children: "Completed" }),
|
|
1218
|
+
status === "error" && /* @__PURE__ */ jsx10("span", { className: "apteva-tool-call-status apteva-tool-call-status-error", children: "Error" })
|
|
836
1219
|
] });
|
|
837
1220
|
}
|
|
838
1221
|
|
|
839
1222
|
// src/components/Chat/Message.tsx
|
|
840
|
-
import { jsx as
|
|
841
|
-
function Message({ message, onAction }) {
|
|
1223
|
+
import { Fragment, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1224
|
+
function Message({ message, onAction, enableWidgets }) {
|
|
842
1225
|
const isUser = message.role === "user";
|
|
843
1226
|
const contentSegments = message.metadata?.content_segments;
|
|
1227
|
+
const renderTextContent = (text) => {
|
|
1228
|
+
if (!enableWidgets || isUser) {
|
|
1229
|
+
return /* @__PURE__ */ jsx11(MarkdownContent, { content: text });
|
|
1230
|
+
}
|
|
1231
|
+
const parsed = parseWidgetsFromText(text);
|
|
1232
|
+
if (parsed.segments.length === 0) {
|
|
1233
|
+
return null;
|
|
1234
|
+
}
|
|
1235
|
+
return /* @__PURE__ */ jsx11(Fragment, { children: parsed.segments.map((segment, index) => {
|
|
1236
|
+
if (segment.type === "text" && segment.content) {
|
|
1237
|
+
return /* @__PURE__ */ jsx11(MarkdownContent, { content: segment.content }, `text-${index}`);
|
|
1238
|
+
}
|
|
1239
|
+
if (segment.type === "widget" && segment.widget) {
|
|
1240
|
+
return /* @__PURE__ */ jsx11("div", { className: "my-3", children: /* @__PURE__ */ jsx11(WidgetRenderer, { widget: segment.widget, onAction }) }, `widget-${index}`);
|
|
1241
|
+
}
|
|
1242
|
+
if (segment.type === "widget_pending" && segment.pendingType) {
|
|
1243
|
+
return /* @__PURE__ */ jsx11("div", { className: "my-3", children: /* @__PURE__ */ jsx11(WidgetSkeleton, { type: segment.pendingType }) }, `pending-${index}`);
|
|
1244
|
+
}
|
|
1245
|
+
return null;
|
|
1246
|
+
}) });
|
|
1247
|
+
};
|
|
844
1248
|
const renderContent = () => {
|
|
845
1249
|
if (isUser) {
|
|
846
|
-
return /* @__PURE__ */
|
|
1250
|
+
return /* @__PURE__ */ jsx11("div", { className: "whitespace-pre-wrap !text-sm leading-relaxed", children: message.content });
|
|
847
1251
|
}
|
|
848
1252
|
if (contentSegments && contentSegments.length > 0) {
|
|
849
|
-
return /* @__PURE__ */
|
|
1253
|
+
return /* @__PURE__ */ jsx11("div", { children: contentSegments.map((segment, index) => {
|
|
850
1254
|
if (segment.type === "text") {
|
|
851
|
-
return segment.content ? /* @__PURE__ */
|
|
1255
|
+
return segment.content ? /* @__PURE__ */ jsx11("div", { children: renderTextContent(segment.content) }, `text-${index}`) : null;
|
|
852
1256
|
} else if (segment.type === "tool") {
|
|
853
|
-
return /* @__PURE__ */
|
|
1257
|
+
return /* @__PURE__ */ jsx11("div", { className: "my-2", children: /* @__PURE__ */ jsx11(
|
|
854
1258
|
ToolCall,
|
|
855
1259
|
{
|
|
856
1260
|
name: segment.name,
|
|
@@ -861,9 +1265,9 @@ function Message({ message, onAction }) {
|
|
|
861
1265
|
return null;
|
|
862
1266
|
}) });
|
|
863
1267
|
}
|
|
864
|
-
return
|
|
1268
|
+
return renderTextContent(message.content);
|
|
865
1269
|
};
|
|
866
|
-
return /* @__PURE__ */
|
|
1270
|
+
return /* @__PURE__ */ jsxs8(
|
|
867
1271
|
"div",
|
|
868
1272
|
{
|
|
869
1273
|
className: cn(
|
|
@@ -872,16 +1276,16 @@ function Message({ message, onAction }) {
|
|
|
872
1276
|
),
|
|
873
1277
|
children: [
|
|
874
1278
|
renderContent(),
|
|
875
|
-
message.widgets && message.widgets.length > 0 && /* @__PURE__ */
|
|
876
|
-
/* @__PURE__ */
|
|
1279
|
+
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" }) }),
|
|
1280
|
+
/* @__PURE__ */ jsx11("div", { className: cn("!text-xs opacity-70", isUser ? "mt-1.5 !text-gray-500 dark:!text-gray-400" : "mt-1 !text-gray-500 dark:!text-gray-400"), suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
877
1281
|
]
|
|
878
1282
|
}
|
|
879
1283
|
);
|
|
880
1284
|
}
|
|
881
1285
|
|
|
882
1286
|
// src/components/Chat/WelcomeScreen.tsx
|
|
883
|
-
import { jsx as
|
|
884
|
-
var DefaultIcon = () => /* @__PURE__ */
|
|
1287
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1288
|
+
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
1289
|
"path",
|
|
886
1290
|
{
|
|
887
1291
|
strokeLinecap: "round",
|
|
@@ -890,7 +1294,7 @@ var DefaultIcon = () => /* @__PURE__ */ jsx10("svg", { className: "w-12 h-12 sm:
|
|
|
890
1294
|
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
1295
|
}
|
|
892
1296
|
) });
|
|
893
|
-
var ArrowIcon = () => /* @__PURE__ */
|
|
1297
|
+
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
1298
|
function WelcomeScreen({
|
|
895
1299
|
title,
|
|
896
1300
|
subtitle,
|
|
@@ -905,18 +1309,18 @@ function WelcomeScreen({
|
|
|
905
1309
|
const hasPrompts = normalizedPrompts.length > 0;
|
|
906
1310
|
const hasHeader = title || subtitle || icon;
|
|
907
1311
|
if (!hasHeader && !hasPrompts) {
|
|
908
|
-
return /* @__PURE__ */
|
|
909
|
-
/* @__PURE__ */
|
|
910
|
-
/* @__PURE__ */
|
|
1312
|
+
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: [
|
|
1313
|
+
/* @__PURE__ */ jsx12("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx12(DefaultIcon, {}) }),
|
|
1314
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm", children: "No messages yet. Start a conversation!" })
|
|
911
1315
|
] }) });
|
|
912
1316
|
}
|
|
913
1317
|
if (variant === "minimal") {
|
|
914
|
-
return /* @__PURE__ */
|
|
915
|
-
hasHeader && /* @__PURE__ */
|
|
916
|
-
title && /* @__PURE__ */
|
|
917
|
-
subtitle && /* @__PURE__ */
|
|
1318
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex flex-col h-full px-4 py-4", children: [
|
|
1319
|
+
hasHeader && /* @__PURE__ */ jsxs9("div", { className: "mb-4", children: [
|
|
1320
|
+
title && /* @__PURE__ */ jsx12("h2", { className: "text-lg font-semibold !text-gray-900 dark:!text-white", children: title }),
|
|
1321
|
+
subtitle && /* @__PURE__ */ jsx12("p", { className: "text-sm !text-gray-500 dark:!text-gray-400 mt-1", children: subtitle })
|
|
918
1322
|
] }),
|
|
919
|
-
hasPrompts && /* @__PURE__ */
|
|
1323
|
+
hasPrompts && /* @__PURE__ */ jsx12("div", { className: "flex-1 space-y-2", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx12(
|
|
920
1324
|
"button",
|
|
921
1325
|
{
|
|
922
1326
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -929,11 +1333,11 @@ function WelcomeScreen({
|
|
|
929
1333
|
"transition-all duration-200",
|
|
930
1334
|
"group"
|
|
931
1335
|
),
|
|
932
|
-
children: /* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
935
|
-
/* @__PURE__ */
|
|
936
|
-
prompt.description && /* @__PURE__ */
|
|
1336
|
+
children: /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-3", children: [
|
|
1337
|
+
/* @__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, {}) }),
|
|
1338
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex-1 min-w-0", children: [
|
|
1339
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm font-medium !text-gray-900 dark:!text-white truncate", children: prompt.text }),
|
|
1340
|
+
prompt.description && /* @__PURE__ */ jsx12("p", { className: "text-xs !text-gray-500 dark:!text-gray-400 mt-0.5 truncate", children: prompt.description })
|
|
937
1341
|
] })
|
|
938
1342
|
] })
|
|
939
1343
|
},
|
|
@@ -941,14 +1345,14 @@ function WelcomeScreen({
|
|
|
941
1345
|
)) })
|
|
942
1346
|
] });
|
|
943
1347
|
}
|
|
944
|
-
return /* @__PURE__ */
|
|
945
|
-
/* @__PURE__ */
|
|
946
|
-
/* @__PURE__ */
|
|
947
|
-
title && /* @__PURE__ */
|
|
948
|
-
subtitle && /* @__PURE__ */
|
|
1348
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex flex-col items-center justify-center h-full px-4 py-6 sm:py-8", children: [
|
|
1349
|
+
/* @__PURE__ */ jsxs9("div", { className: "text-center mb-6 sm:mb-8 max-w-md", children: [
|
|
1350
|
+
/* @__PURE__ */ jsx12("div", { className: "mb-4 !text-gray-400 dark:!text-gray-500 flex justify-center", children: icon || /* @__PURE__ */ jsx12(DefaultIcon, {}) }),
|
|
1351
|
+
title && /* @__PURE__ */ jsx12("h1", { className: "text-xl sm:text-2xl font-semibold !text-gray-900 dark:!text-white mb-2", children: title }),
|
|
1352
|
+
subtitle && /* @__PURE__ */ jsx12("p", { className: "text-sm sm:text-base !text-gray-500 dark:!text-gray-400", children: subtitle })
|
|
949
1353
|
] }),
|
|
950
|
-
hasPrompts && /* @__PURE__ */
|
|
951
|
-
/* @__PURE__ */
|
|
1354
|
+
hasPrompts && /* @__PURE__ */ jsxs9("div", { className: "w-full max-w-2xl", children: [
|
|
1355
|
+
/* @__PURE__ */ jsx12("div", { className: "sm:hidden space-y-2", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx12(
|
|
952
1356
|
"button",
|
|
953
1357
|
{
|
|
954
1358
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -963,20 +1367,20 @@ function WelcomeScreen({
|
|
|
963
1367
|
"shadow-sm hover:shadow",
|
|
964
1368
|
"group"
|
|
965
1369
|
),
|
|
966
|
-
children: /* @__PURE__ */
|
|
967
|
-
/* @__PURE__ */
|
|
968
|
-
/* @__PURE__ */
|
|
969
|
-
/* @__PURE__ */
|
|
970
|
-
prompt.description && /* @__PURE__ */
|
|
1370
|
+
children: /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-3", children: [
|
|
1371
|
+
/* @__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, {}) }),
|
|
1372
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex-1 min-w-0", children: [
|
|
1373
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm font-medium !text-gray-900 dark:!text-white", children: prompt.text }),
|
|
1374
|
+
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
1375
|
] }),
|
|
972
|
-
/* @__PURE__ */
|
|
1376
|
+
/* @__PURE__ */ jsx12(
|
|
973
1377
|
"svg",
|
|
974
1378
|
{
|
|
975
1379
|
className: "w-4 h-4 !text-gray-400 group-hover:!text-blue-500 transition-colors flex-shrink-0",
|
|
976
1380
|
fill: "none",
|
|
977
1381
|
stroke: "currentColor",
|
|
978
1382
|
viewBox: "0 0 24 24",
|
|
979
|
-
children: /* @__PURE__ */
|
|
1383
|
+
children: /* @__PURE__ */ jsx12(
|
|
980
1384
|
"path",
|
|
981
1385
|
{
|
|
982
1386
|
strokeLinecap: "round",
|
|
@@ -991,7 +1395,7 @@ function WelcomeScreen({
|
|
|
991
1395
|
},
|
|
992
1396
|
index
|
|
993
1397
|
)) }),
|
|
994
|
-
/* @__PURE__ */
|
|
1398
|
+
/* @__PURE__ */ jsx12("div", { className: "hidden sm:grid sm:grid-cols-2 gap-3", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx12(
|
|
995
1399
|
"button",
|
|
996
1400
|
{
|
|
997
1401
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -1006,11 +1410,11 @@ function WelcomeScreen({
|
|
|
1006
1410
|
"transition-all duration-200",
|
|
1007
1411
|
"group"
|
|
1008
1412
|
),
|
|
1009
|
-
children: /* @__PURE__ */
|
|
1010
|
-
/* @__PURE__ */
|
|
1011
|
-
/* @__PURE__ */
|
|
1012
|
-
/* @__PURE__ */
|
|
1013
|
-
prompt.description && /* @__PURE__ */
|
|
1413
|
+
children: /* @__PURE__ */ jsxs9("div", { className: "flex items-start gap-3", children: [
|
|
1414
|
+
/* @__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, {}) }),
|
|
1415
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex-1 min-w-0", children: [
|
|
1416
|
+
/* @__PURE__ */ jsx12("p", { className: "text-sm font-medium !text-gray-900 dark:!text-white leading-snug", children: prompt.text }),
|
|
1417
|
+
prompt.description && /* @__PURE__ */ jsx12("p", { className: "text-xs !text-gray-500 dark:!text-gray-400 mt-1 line-clamp-2", children: prompt.description })
|
|
1014
1418
|
] })
|
|
1015
1419
|
] })
|
|
1016
1420
|
},
|
|
@@ -1021,7 +1425,7 @@ function WelcomeScreen({
|
|
|
1021
1425
|
}
|
|
1022
1426
|
|
|
1023
1427
|
// src/components/Chat/MessageList.tsx
|
|
1024
|
-
import { jsx as
|
|
1428
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1025
1429
|
function MessageList({
|
|
1026
1430
|
messages,
|
|
1027
1431
|
onAction,
|
|
@@ -1030,7 +1434,8 @@ function MessageList({
|
|
|
1030
1434
|
welcomeIcon,
|
|
1031
1435
|
suggestedPrompts,
|
|
1032
1436
|
welcomeVariant,
|
|
1033
|
-
onPromptClick
|
|
1437
|
+
onPromptClick,
|
|
1438
|
+
enableWidgets
|
|
1034
1439
|
}) {
|
|
1035
1440
|
const listRef = useRef(null);
|
|
1036
1441
|
useEffect2(() => {
|
|
@@ -1038,7 +1443,7 @@ function MessageList({
|
|
|
1038
1443
|
listRef.current.scrollTop = listRef.current.scrollHeight;
|
|
1039
1444
|
}
|
|
1040
1445
|
}, [messages]);
|
|
1041
|
-
return /* @__PURE__ */
|
|
1446
|
+
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
1447
|
WelcomeScreen,
|
|
1043
1448
|
{
|
|
1044
1449
|
title: welcomeTitle,
|
|
@@ -1049,13 +1454,13 @@ function MessageList({
|
|
|
1049
1454
|
onPromptClick: onPromptClick || (() => {
|
|
1050
1455
|
})
|
|
1051
1456
|
}
|
|
1052
|
-
) : messages.map((message) => /* @__PURE__ */
|
|
1457
|
+
) : messages.map((message) => /* @__PURE__ */ jsx13(Message, { message, onAction, enableWidgets }, message.id)) });
|
|
1053
1458
|
}
|
|
1054
1459
|
|
|
1055
1460
|
// src/components/Chat/Composer.tsx
|
|
1056
1461
|
import { useState, useRef as useRef2 } from "react";
|
|
1057
|
-
import { Fragment, jsx as
|
|
1058
|
-
function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, onFileUpload, onSwitchMode }) {
|
|
1462
|
+
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1463
|
+
function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, isLoading = false, onStop, onFileUpload, onSwitchMode }) {
|
|
1059
1464
|
const [text, setText] = useState("");
|
|
1060
1465
|
const [showMenu, setShowMenu] = useState(false);
|
|
1061
1466
|
const [pendingFiles, setPendingFiles] = useState([]);
|
|
@@ -1128,56 +1533,56 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1128
1533
|
};
|
|
1129
1534
|
const getFileIcon = (mimeType) => {
|
|
1130
1535
|
if (mimeType.startsWith("image/")) {
|
|
1131
|
-
return /* @__PURE__ */
|
|
1536
|
+
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
1537
|
}
|
|
1133
1538
|
if (mimeType === "application/pdf") {
|
|
1134
|
-
return /* @__PURE__ */
|
|
1539
|
+
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
1540
|
}
|
|
1136
|
-
return /* @__PURE__ */
|
|
1541
|
+
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
1542
|
};
|
|
1138
|
-
return /* @__PURE__ */
|
|
1139
|
-
fileError && /* @__PURE__ */
|
|
1140
|
-
/* @__PURE__ */
|
|
1141
|
-
/* @__PURE__ */
|
|
1543
|
+
return /* @__PURE__ */ jsxs10("div", { className: "px-4 py-3 relative", children: [
|
|
1544
|
+
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: [
|
|
1545
|
+
/* @__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" }) }),
|
|
1546
|
+
/* @__PURE__ */ jsx14("span", { children: fileError })
|
|
1142
1547
|
] }) }),
|
|
1143
|
-
pendingFiles.length > 0 && /* @__PURE__ */
|
|
1548
|
+
pendingFiles.length > 0 && /* @__PURE__ */ jsx14("div", { className: "mb-2 flex flex-wrap gap-2", children: pendingFiles.map((pf, index) => /* @__PURE__ */ jsxs10(
|
|
1144
1549
|
"div",
|
|
1145
1550
|
{
|
|
1146
1551
|
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
1552
|
children: [
|
|
1148
|
-
pf.preview ? /* @__PURE__ */
|
|
1149
|
-
/* @__PURE__ */
|
|
1150
|
-
/* @__PURE__ */
|
|
1151
|
-
/* @__PURE__ */
|
|
1553
|
+
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) }),
|
|
1554
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-col min-w-0", children: [
|
|
1555
|
+
/* @__PURE__ */ jsx14("span", { className: "text-xs font-medium !text-gray-700 dark:!text-gray-300 truncate max-w-[120px]", children: pf.file.name }),
|
|
1556
|
+
/* @__PURE__ */ jsx14("span", { className: "text-xs !text-gray-500 dark:!text-gray-400", children: formatFileSize(pf.file.size) })
|
|
1152
1557
|
] }),
|
|
1153
|
-
/* @__PURE__ */
|
|
1558
|
+
/* @__PURE__ */ jsx14(
|
|
1154
1559
|
"button",
|
|
1155
1560
|
{
|
|
1156
1561
|
onClick: () => removeFile(index),
|
|
1157
1562
|
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
1563
|
title: "Remove file",
|
|
1159
|
-
children: /* @__PURE__ */
|
|
1564
|
+
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
1565
|
}
|
|
1161
1566
|
)
|
|
1162
1567
|
]
|
|
1163
1568
|
},
|
|
1164
1569
|
index
|
|
1165
1570
|
)) }),
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1571
|
+
/* @__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: [
|
|
1572
|
+
/* @__PURE__ */ jsxs10("div", { className: "relative flex-shrink-0", children: [
|
|
1573
|
+
/* @__PURE__ */ jsx14(
|
|
1169
1574
|
"button",
|
|
1170
1575
|
{
|
|
1171
1576
|
ref: menuButtonRef,
|
|
1172
1577
|
onClick: () => setShowMenu(!showMenu),
|
|
1173
1578
|
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
1579
|
title: "More options",
|
|
1175
|
-
children: /* @__PURE__ */
|
|
1580
|
+
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
1581
|
}
|
|
1177
1582
|
),
|
|
1178
|
-
showMenu && /* @__PURE__ */
|
|
1179
|
-
/* @__PURE__ */
|
|
1180
|
-
/* @__PURE__ */
|
|
1583
|
+
showMenu && /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
1584
|
+
/* @__PURE__ */ jsx14("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
1585
|
+
/* @__PURE__ */ jsxs10(
|
|
1181
1586
|
"div",
|
|
1182
1587
|
{
|
|
1183
1588
|
className: "fixed bg-gray-800 dark:bg-gray-700 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
@@ -1186,7 +1591,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1186
1591
|
top: (menuButtonRef.current?.getBoundingClientRect().bottom ?? 0) + 8
|
|
1187
1592
|
},
|
|
1188
1593
|
children: [
|
|
1189
|
-
/* @__PURE__ */
|
|
1594
|
+
/* @__PURE__ */ jsxs10(
|
|
1190
1595
|
"button",
|
|
1191
1596
|
{
|
|
1192
1597
|
onClick: () => {
|
|
@@ -1195,12 +1600,12 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1195
1600
|
},
|
|
1196
1601
|
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
1602
|
children: [
|
|
1198
|
-
/* @__PURE__ */
|
|
1199
|
-
/* @__PURE__ */
|
|
1603
|
+
/* @__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)" }) }),
|
|
1604
|
+
/* @__PURE__ */ jsx14("span", { className: "!text-sm font-medium", children: "Add photos & files" })
|
|
1200
1605
|
]
|
|
1201
1606
|
}
|
|
1202
1607
|
),
|
|
1203
|
-
onSwitchMode && /* @__PURE__ */
|
|
1608
|
+
onSwitchMode && /* @__PURE__ */ jsxs10(
|
|
1204
1609
|
"button",
|
|
1205
1610
|
{
|
|
1206
1611
|
onClick: () => {
|
|
@@ -1209,8 +1614,8 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1209
1614
|
},
|
|
1210
1615
|
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
1616
|
children: [
|
|
1212
|
-
/* @__PURE__ */
|
|
1213
|
-
/* @__PURE__ */
|
|
1617
|
+
/* @__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" }) }),
|
|
1618
|
+
/* @__PURE__ */ jsx14("span", { className: "!text-sm font-medium", children: "Switch to command mode" })
|
|
1214
1619
|
]
|
|
1215
1620
|
}
|
|
1216
1621
|
)
|
|
@@ -1219,7 +1624,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1219
1624
|
)
|
|
1220
1625
|
] })
|
|
1221
1626
|
] }),
|
|
1222
|
-
/* @__PURE__ */
|
|
1627
|
+
/* @__PURE__ */ jsx14(
|
|
1223
1628
|
"textarea",
|
|
1224
1629
|
{
|
|
1225
1630
|
ref: textareaRef,
|
|
@@ -1233,18 +1638,26 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1233
1638
|
style: { maxHeight: "120px" }
|
|
1234
1639
|
}
|
|
1235
1640
|
),
|
|
1236
|
-
/* @__PURE__ */
|
|
1641
|
+
isLoading && onStop ? /* @__PURE__ */ jsx14(
|
|
1642
|
+
"button",
|
|
1643
|
+
{
|
|
1644
|
+
onClick: onStop,
|
|
1645
|
+
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",
|
|
1646
|
+
title: "Stop generation",
|
|
1647
|
+
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" }) })
|
|
1648
|
+
}
|
|
1649
|
+
) : /* @__PURE__ */ jsx14(
|
|
1237
1650
|
"button",
|
|
1238
1651
|
{
|
|
1239
1652
|
onClick: handleSend,
|
|
1240
1653
|
disabled: !text.trim() && pendingFiles.length === 0 || disabled,
|
|
1241
1654
|
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
1655
|
title: "Send message",
|
|
1243
|
-
children: /* @__PURE__ */
|
|
1656
|
+
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
1657
|
}
|
|
1245
1658
|
)
|
|
1246
1659
|
] }),
|
|
1247
|
-
/* @__PURE__ */
|
|
1660
|
+
/* @__PURE__ */ jsx14(
|
|
1248
1661
|
"input",
|
|
1249
1662
|
{
|
|
1250
1663
|
ref: fileInputRef,
|
|
@@ -1260,7 +1673,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
1260
1673
|
|
|
1261
1674
|
// src/components/Chat/CommandComposer.tsx
|
|
1262
1675
|
import { useState as useState2, useRef as useRef3 } from "react";
|
|
1263
|
-
import { Fragment as
|
|
1676
|
+
import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1264
1677
|
function CommandComposer({
|
|
1265
1678
|
onExecute,
|
|
1266
1679
|
state,
|
|
@@ -1272,6 +1685,7 @@ function CommandComposer({
|
|
|
1272
1685
|
onApprove,
|
|
1273
1686
|
onReject,
|
|
1274
1687
|
onReset,
|
|
1688
|
+
onStop,
|
|
1275
1689
|
onExpand,
|
|
1276
1690
|
placeholder = "Enter your command...",
|
|
1277
1691
|
disabled = false
|
|
@@ -1349,12 +1763,12 @@ function CommandComposer({
|
|
|
1349
1763
|
};
|
|
1350
1764
|
const getFileIcon = (mimeType) => {
|
|
1351
1765
|
if (mimeType.startsWith("image/")) {
|
|
1352
|
-
return /* @__PURE__ */
|
|
1766
|
+
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
1767
|
}
|
|
1354
1768
|
if (mimeType === "application/pdf") {
|
|
1355
|
-
return /* @__PURE__ */
|
|
1769
|
+
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
1770
|
}
|
|
1357
|
-
return /* @__PURE__ */
|
|
1771
|
+
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
1772
|
};
|
|
1359
1773
|
const getDisplayContent = () => {
|
|
1360
1774
|
if (state === "loading") {
|
|
@@ -1379,12 +1793,12 @@ function CommandComposer({
|
|
|
1379
1793
|
};
|
|
1380
1794
|
const isShowingResult = state !== "idle";
|
|
1381
1795
|
const { text: displayContent, isToolCall } = getDisplayContent();
|
|
1382
|
-
return /* @__PURE__ */
|
|
1383
|
-
fileError && /* @__PURE__ */
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
/* @__PURE__ */
|
|
1796
|
+
return /* @__PURE__ */ jsxs11("div", { className: "w-full relative", children: [
|
|
1797
|
+
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: [
|
|
1798
|
+
/* @__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" }) }),
|
|
1799
|
+
/* @__PURE__ */ jsx15("span", { children: fileError })
|
|
1386
1800
|
] }) }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1801
|
+
/* @__PURE__ */ jsxs11(
|
|
1388
1802
|
"div",
|
|
1389
1803
|
{
|
|
1390
1804
|
className: cn(
|
|
@@ -1396,21 +1810,21 @@ function CommandComposer({
|
|
|
1396
1810
|
state === "error" && "border-red-400 dark:border-red-500"
|
|
1397
1811
|
),
|
|
1398
1812
|
children: [
|
|
1399
|
-
/* @__PURE__ */
|
|
1400
|
-
state === "idle" && /* @__PURE__ */
|
|
1401
|
-
/* @__PURE__ */
|
|
1813
|
+
/* @__PURE__ */ jsxs11("div", { className: "w-8 h-8 flex items-center justify-center flex-shrink-0", children: [
|
|
1814
|
+
state === "idle" && /* @__PURE__ */ jsxs11("div", { className: "relative", children: [
|
|
1815
|
+
/* @__PURE__ */ jsx15(
|
|
1402
1816
|
"button",
|
|
1403
1817
|
{
|
|
1404
1818
|
ref: menuButtonRef,
|
|
1405
1819
|
onClick: () => setShowMenu(!showMenu),
|
|
1406
1820
|
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
1821
|
title: "More options",
|
|
1408
|
-
children: /* @__PURE__ */
|
|
1822
|
+
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
1823
|
}
|
|
1410
1824
|
),
|
|
1411
|
-
showMenu && /* @__PURE__ */
|
|
1412
|
-
/* @__PURE__ */
|
|
1413
|
-
/* @__PURE__ */
|
|
1825
|
+
showMenu && /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
1826
|
+
/* @__PURE__ */ jsx15("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
1827
|
+
/* @__PURE__ */ jsxs11(
|
|
1414
1828
|
"div",
|
|
1415
1829
|
{
|
|
1416
1830
|
className: "fixed bg-gray-800 dark:bg-gray-700 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
@@ -1419,7 +1833,7 @@ function CommandComposer({
|
|
|
1419
1833
|
top: (menuButtonRef.current?.getBoundingClientRect().bottom ?? 0) + 8
|
|
1420
1834
|
},
|
|
1421
1835
|
children: [
|
|
1422
|
-
/* @__PURE__ */
|
|
1836
|
+
/* @__PURE__ */ jsxs11(
|
|
1423
1837
|
"button",
|
|
1424
1838
|
{
|
|
1425
1839
|
onClick: () => {
|
|
@@ -1428,12 +1842,12 @@ function CommandComposer({
|
|
|
1428
1842
|
},
|
|
1429
1843
|
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
1844
|
children: [
|
|
1431
|
-
/* @__PURE__ */
|
|
1432
|
-
/* @__PURE__ */
|
|
1845
|
+
/* @__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)" }) }),
|
|
1846
|
+
/* @__PURE__ */ jsx15("span", { className: "!text-sm font-medium", children: "Add photos & files" })
|
|
1433
1847
|
]
|
|
1434
1848
|
}
|
|
1435
1849
|
),
|
|
1436
|
-
onExpand && /* @__PURE__ */
|
|
1850
|
+
onExpand && /* @__PURE__ */ jsxs11(
|
|
1437
1851
|
"button",
|
|
1438
1852
|
{
|
|
1439
1853
|
onClick: () => {
|
|
@@ -1442,8 +1856,8 @@ function CommandComposer({
|
|
|
1442
1856
|
},
|
|
1443
1857
|
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
1858
|
children: [
|
|
1445
|
-
/* @__PURE__ */
|
|
1446
|
-
/* @__PURE__ */
|
|
1859
|
+
/* @__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" }) }),
|
|
1860
|
+
/* @__PURE__ */ jsx15("span", { className: "!text-sm font-medium", children: "Expand to chat" })
|
|
1447
1861
|
]
|
|
1448
1862
|
}
|
|
1449
1863
|
)
|
|
@@ -1452,30 +1866,30 @@ function CommandComposer({
|
|
|
1452
1866
|
)
|
|
1453
1867
|
] })
|
|
1454
1868
|
] }),
|
|
1455
|
-
state === "loading" && !toolName && /* @__PURE__ */
|
|
1456
|
-
state === "loading" && toolName && /* @__PURE__ */
|
|
1869
|
+
state === "loading" && !toolName && /* @__PURE__ */ jsx15("div", { className: "w-4 h-4 border-2 border-blue-200 border-t-blue-500 rounded-full animate-spin" }),
|
|
1870
|
+
state === "loading" && toolName && /* @__PURE__ */ jsx15("div", { className: "w-2 h-2 rounded-full bg-blue-500 animate-pulse" })
|
|
1457
1871
|
] }),
|
|
1458
|
-
pendingFiles.length > 0 && state === "idle" && /* @__PURE__ */
|
|
1872
|
+
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
1873
|
"div",
|
|
1460
1874
|
{
|
|
1461
1875
|
className: "relative group flex items-center justify-center w-6 h-6 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",
|
|
1462
1876
|
title: pf.file.name,
|
|
1463
1877
|
children: [
|
|
1464
|
-
pf.preview ? /* @__PURE__ */
|
|
1465
|
-
/* @__PURE__ */
|
|
1878
|
+
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) }),
|
|
1879
|
+
/* @__PURE__ */ jsx15(
|
|
1466
1880
|
"button",
|
|
1467
1881
|
{
|
|
1468
1882
|
onClick: () => removeFile(index),
|
|
1469
1883
|
className: "absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 flex items-center justify-center transition-opacity",
|
|
1470
1884
|
title: "Remove",
|
|
1471
|
-
children: /* @__PURE__ */
|
|
1885
|
+
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
1886
|
}
|
|
1473
1887
|
)
|
|
1474
1888
|
]
|
|
1475
1889
|
},
|
|
1476
1890
|
index
|
|
1477
1891
|
)) }),
|
|
1478
|
-
state === "idle" ? /* @__PURE__ */
|
|
1892
|
+
state === "idle" ? /* @__PURE__ */ jsx15(
|
|
1479
1893
|
"textarea",
|
|
1480
1894
|
{
|
|
1481
1895
|
ref: inputRef,
|
|
@@ -1493,7 +1907,7 @@ function CommandComposer({
|
|
|
1493
1907
|
),
|
|
1494
1908
|
style: { minHeight: "24px", maxHeight: "120px" }
|
|
1495
1909
|
}
|
|
1496
|
-
) : /* @__PURE__ */
|
|
1910
|
+
) : /* @__PURE__ */ jsx15(
|
|
1497
1911
|
"div",
|
|
1498
1912
|
{
|
|
1499
1913
|
className: cn(
|
|
@@ -1504,14 +1918,14 @@ function CommandComposer({
|
|
|
1504
1918
|
state === "error" && "!text-red-600 dark:!text-red-400",
|
|
1505
1919
|
state === "plan-pending" && "!text-amber-700 dark:!text-amber-300"
|
|
1506
1920
|
),
|
|
1507
|
-
children: isToolCall ? /* @__PURE__ */
|
|
1508
|
-
/* @__PURE__ */
|
|
1509
|
-
/* @__PURE__ */
|
|
1921
|
+
children: isToolCall ? /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
1922
|
+
/* @__PURE__ */ jsx15("span", { className: "font-mono", children: displayContent }),
|
|
1923
|
+
/* @__PURE__ */ jsx15("span", { className: "text-gray-400 dark:text-gray-500", children: "Running..." })
|
|
1510
1924
|
] }) : displayContent
|
|
1511
1925
|
}
|
|
1512
1926
|
),
|
|
1513
|
-
/* @__PURE__ */
|
|
1514
|
-
/* @__PURE__ */
|
|
1927
|
+
/* @__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: [
|
|
1928
|
+
/* @__PURE__ */ jsx15(
|
|
1515
1929
|
"button",
|
|
1516
1930
|
{
|
|
1517
1931
|
onClick: onApprove,
|
|
@@ -1519,7 +1933,7 @@ function CommandComposer({
|
|
|
1519
1933
|
children: "Approve"
|
|
1520
1934
|
}
|
|
1521
1935
|
),
|
|
1522
|
-
/* @__PURE__ */
|
|
1936
|
+
/* @__PURE__ */ jsx15(
|
|
1523
1937
|
"button",
|
|
1524
1938
|
{
|
|
1525
1939
|
onClick: onReject,
|
|
@@ -1527,17 +1941,26 @@ function CommandComposer({
|
|
|
1527
1941
|
children: "Modify"
|
|
1528
1942
|
}
|
|
1529
1943
|
)
|
|
1530
|
-
] }) : /* @__PURE__ */
|
|
1531
|
-
|
|
1944
|
+
] }) : /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
1945
|
+
state === "loading" && onStop && /* @__PURE__ */ jsx15(
|
|
1946
|
+
"button",
|
|
1947
|
+
{
|
|
1948
|
+
onClick: onStop,
|
|
1949
|
+
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",
|
|
1950
|
+
title: "Stop generation",
|
|
1951
|
+
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" }) })
|
|
1952
|
+
}
|
|
1953
|
+
),
|
|
1954
|
+
(state === "success" || state === "error") && /* @__PURE__ */ jsx15(
|
|
1532
1955
|
"button",
|
|
1533
1956
|
{
|
|
1534
1957
|
onClick: handleNewCommand,
|
|
1535
1958
|
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
1959
|
title: "New command",
|
|
1537
|
-
children: /* @__PURE__ */
|
|
1960
|
+
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
1961
|
}
|
|
1539
1962
|
),
|
|
1540
|
-
state === "idle" && /* @__PURE__ */
|
|
1963
|
+
state === "idle" && /* @__PURE__ */ jsx15(
|
|
1541
1964
|
"button",
|
|
1542
1965
|
{
|
|
1543
1966
|
onClick: handleSubmit,
|
|
@@ -1549,14 +1972,14 @@ function CommandComposer({
|
|
|
1549
1972
|
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
1973
|
),
|
|
1551
1974
|
title: "Execute command",
|
|
1552
|
-
children: /* @__PURE__ */
|
|
1975
|
+
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
1976
|
}
|
|
1554
1977
|
)
|
|
1555
1978
|
] }) })
|
|
1556
1979
|
]
|
|
1557
1980
|
}
|
|
1558
1981
|
),
|
|
1559
|
-
/* @__PURE__ */
|
|
1982
|
+
/* @__PURE__ */ jsx15(
|
|
1560
1983
|
"input",
|
|
1561
1984
|
{
|
|
1562
1985
|
ref: fileInputRef,
|
|
@@ -1731,11 +2154,32 @@ var AptevaClient = class {
|
|
|
1731
2154
|
const data = await response.json();
|
|
1732
2155
|
return data.messages;
|
|
1733
2156
|
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Cancel an in-progress request
|
|
2159
|
+
*/
|
|
2160
|
+
async cancelRequest(agentId, requestId) {
|
|
2161
|
+
try {
|
|
2162
|
+
const response = await fetch(`${this.config.apiUrl}/agents/${agentId}/requests/${requestId}/cancel`, {
|
|
2163
|
+
method: "POST",
|
|
2164
|
+
headers: {
|
|
2165
|
+
"Content-Type": "application/json",
|
|
2166
|
+
"X-API-Key": this.config.apiKey
|
|
2167
|
+
}
|
|
2168
|
+
});
|
|
2169
|
+
if (!response.ok) {
|
|
2170
|
+
const error = await response.json().catch(() => ({ error: "Cancel request failed" }));
|
|
2171
|
+
throw new Error(error.error || `Cancel request failed with status ${response.status}`);
|
|
2172
|
+
}
|
|
2173
|
+
} catch (error) {
|
|
2174
|
+
console.error("[AptevaClient] Cancel request error:", error);
|
|
2175
|
+
throw error;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
1734
2178
|
};
|
|
1735
2179
|
var aptevaClient = new AptevaClient();
|
|
1736
2180
|
|
|
1737
2181
|
// src/components/Chat/Chat.tsx
|
|
1738
|
-
import { Fragment as
|
|
2182
|
+
import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1739
2183
|
function Chat({
|
|
1740
2184
|
agentId,
|
|
1741
2185
|
threadId,
|
|
@@ -1773,6 +2217,11 @@ function Chat({
|
|
|
1773
2217
|
placeholder,
|
|
1774
2218
|
showHeader = true,
|
|
1775
2219
|
headerTitle = "Chat",
|
|
2220
|
+
// Widget detection
|
|
2221
|
+
enableWidgets = false,
|
|
2222
|
+
availableWidgets,
|
|
2223
|
+
compactWidgetContext = false,
|
|
2224
|
+
onWidgetRender,
|
|
1776
2225
|
className
|
|
1777
2226
|
}) {
|
|
1778
2227
|
const [messages, setMessages] = useState3(initialMessages);
|
|
@@ -1786,11 +2235,18 @@ function Chat({
|
|
|
1786
2235
|
const [commandInput, setCommandInput] = useState3("");
|
|
1787
2236
|
const [streamedContent, setStreamedContent] = useState3("");
|
|
1788
2237
|
const [currentToolName, setCurrentToolName] = useState3(null);
|
|
2238
|
+
const [currentRequestId, setCurrentRequestId] = useState3(null);
|
|
1789
2239
|
const [plan, setPlan] = useState3("");
|
|
1790
2240
|
const [pendingCommand, setPendingCommand] = useState3("");
|
|
1791
2241
|
const [internalPlanMode, setInternalPlanMode] = useState3(planMode);
|
|
1792
2242
|
const [showSettingsMenu, setShowSettingsMenu] = useState3(false);
|
|
1793
2243
|
const fileInputRef = useRef4(null);
|
|
2244
|
+
const effectiveContext = useMemo(() => {
|
|
2245
|
+
if (!enableWidgets) return context;
|
|
2246
|
+
const widgetContext = compactWidgetContext ? generateCompactWidgetContext(availableWidgets) : generateWidgetContext(availableWidgets);
|
|
2247
|
+
return context ? `${context}
|
|
2248
|
+
${widgetContext}` : widgetContext;
|
|
2249
|
+
}, [context, enableWidgets, availableWidgets, compactWidgetContext]);
|
|
1794
2250
|
useEffect3(() => {
|
|
1795
2251
|
if (apiUrl || apiKey) {
|
|
1796
2252
|
aptevaClient.configure({
|
|
@@ -1895,7 +2351,7 @@ function Chat({
|
|
|
1895
2351
|
message: messagePayload,
|
|
1896
2352
|
stream: true,
|
|
1897
2353
|
...currentThreadId && { thread_id: currentThreadId },
|
|
1898
|
-
...
|
|
2354
|
+
...effectiveContext && { system: effectiveContext }
|
|
1899
2355
|
},
|
|
1900
2356
|
(chunk) => {
|
|
1901
2357
|
switch (chunk.type) {
|
|
@@ -1908,6 +2364,11 @@ function Chat({
|
|
|
1908
2364
|
}
|
|
1909
2365
|
}
|
|
1910
2366
|
break;
|
|
2367
|
+
case "request_id":
|
|
2368
|
+
if (chunk.request_id) {
|
|
2369
|
+
setCurrentRequestId(chunk.request_id);
|
|
2370
|
+
}
|
|
2371
|
+
break;
|
|
1911
2372
|
case "content":
|
|
1912
2373
|
case "token":
|
|
1913
2374
|
if (chunk.content) {
|
|
@@ -1981,6 +2442,7 @@ function Chat({
|
|
|
1981
2442
|
onThreadChange?.(threadId2);
|
|
1982
2443
|
}
|
|
1983
2444
|
setIsLoading(false);
|
|
2445
|
+
setCurrentRequestId(null);
|
|
1984
2446
|
},
|
|
1985
2447
|
(error) => {
|
|
1986
2448
|
const errorMessage = {
|
|
@@ -1998,6 +2460,7 @@ function Chat({
|
|
|
1998
2460
|
return [...prev, errorMessage];
|
|
1999
2461
|
});
|
|
2000
2462
|
setIsLoading(false);
|
|
2463
|
+
setCurrentRequestId(null);
|
|
2001
2464
|
onError?.(error);
|
|
2002
2465
|
}
|
|
2003
2466
|
);
|
|
@@ -2040,7 +2503,7 @@ function Chat({
|
|
|
2040
2503
|
} else {
|
|
2041
2504
|
try {
|
|
2042
2505
|
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 =
|
|
2506
|
+
const systemMessage = effectiveContext ? `${effectiveContext}
|
|
2044
2507
|
|
|
2045
2508
|
${planningInstruction}` : planningInstruction;
|
|
2046
2509
|
const response = await aptevaClient.chat({
|
|
@@ -2111,7 +2574,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
2111
2574
|
}
|
|
2112
2575
|
} else {
|
|
2113
2576
|
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 =
|
|
2577
|
+
const systemMessage = effectiveContext ? `${effectiveContext}
|
|
2115
2578
|
|
|
2116
2579
|
${commandInstruction}` : commandInstruction;
|
|
2117
2580
|
const messagePayload = files && files.length > 0 ? await buildMessageWithAttachments(currentCommand, files) : currentCommand;
|
|
@@ -2146,6 +2609,8 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2146
2609
|
setCurrentThreadId(chunk.thread_id);
|
|
2147
2610
|
onThreadChange?.(chunk.thread_id);
|
|
2148
2611
|
}
|
|
2612
|
+
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
2613
|
+
setCurrentRequestId(chunk.request_id);
|
|
2149
2614
|
}
|
|
2150
2615
|
},
|
|
2151
2616
|
(threadId2) => {
|
|
@@ -2157,11 +2622,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
2157
2622
|
setCommandResult(result);
|
|
2158
2623
|
setCommandState("success");
|
|
2159
2624
|
setProgress(100);
|
|
2625
|
+
setCurrentRequestId(null);
|
|
2160
2626
|
onComplete?.(result);
|
|
2161
2627
|
},
|
|
2162
2628
|
(error) => {
|
|
2163
2629
|
setCommandError(error);
|
|
2164
2630
|
setCommandState("error");
|
|
2631
|
+
setCurrentRequestId(null);
|
|
2165
2632
|
onError?.(error);
|
|
2166
2633
|
}
|
|
2167
2634
|
);
|
|
@@ -2218,11 +2685,28 @@ ${planToExecute}`;
|
|
|
2218
2685
|
setPendingCommand("");
|
|
2219
2686
|
setCommandState("idle");
|
|
2220
2687
|
};
|
|
2688
|
+
const handleStop = async () => {
|
|
2689
|
+
if (currentRequestId && agentId) {
|
|
2690
|
+
try {
|
|
2691
|
+
await aptevaClient.cancelRequest(agentId, currentRequestId);
|
|
2692
|
+
} catch (error) {
|
|
2693
|
+
console.error("Failed to cancel request:", error);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
setIsLoading(false);
|
|
2697
|
+
if (commandState === "loading") {
|
|
2698
|
+
setCommandState("idle");
|
|
2699
|
+
setStreamedContent("");
|
|
2700
|
+
setCurrentToolName(null);
|
|
2701
|
+
setProgress(0);
|
|
2702
|
+
}
|
|
2703
|
+
setCurrentRequestId(null);
|
|
2704
|
+
};
|
|
2221
2705
|
const isCompact = commandVariant === "compact";
|
|
2222
|
-
return /* @__PURE__ */
|
|
2223
|
-
showHeader && mode === "chat" && /* @__PURE__ */
|
|
2224
|
-
mode === "chat" && /* @__PURE__ */
|
|
2225
|
-
/* @__PURE__ */
|
|
2706
|
+
return /* @__PURE__ */ jsxs12("div", { className: cn("flex flex-col h-full", className), children: [
|
|
2707
|
+
showHeader && mode === "chat" && /* @__PURE__ */ jsx16("div", { className: "px-4 py-3 flex items-center justify-between", children: /* @__PURE__ */ jsx16("h2", { className: "!text-lg font-semibold !text-gray-900 dark:!text-white", children: headerTitle }) }),
|
|
2708
|
+
mode === "chat" && /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
2709
|
+
/* @__PURE__ */ jsx16(
|
|
2226
2710
|
MessageList,
|
|
2227
2711
|
{
|
|
2228
2712
|
messages,
|
|
@@ -2232,22 +2716,25 @@ ${planToExecute}`;
|
|
|
2232
2716
|
welcomeIcon,
|
|
2233
2717
|
suggestedPrompts,
|
|
2234
2718
|
welcomeVariant,
|
|
2235
|
-
onPromptClick: (prompt) => handleSendMessage(prompt)
|
|
2719
|
+
onPromptClick: (prompt) => handleSendMessage(prompt),
|
|
2720
|
+
enableWidgets
|
|
2236
2721
|
}
|
|
2237
2722
|
),
|
|
2238
|
-
isLoading && /* @__PURE__ */
|
|
2239
|
-
/* @__PURE__ */
|
|
2723
|
+
isLoading && /* @__PURE__ */ jsx16("div", { className: "px-4 py-2 !text-sm !text-gray-500 dark:!text-gray-400 italic", children: "AI is thinking..." }),
|
|
2724
|
+
/* @__PURE__ */ jsx16(
|
|
2240
2725
|
Composer,
|
|
2241
2726
|
{
|
|
2242
2727
|
onSendMessage: handleSendMessage,
|
|
2243
2728
|
placeholder: placeholder || defaultPlaceholder,
|
|
2244
2729
|
disabled: isLoading,
|
|
2730
|
+
isLoading,
|
|
2731
|
+
onStop: handleStop,
|
|
2245
2732
|
onFileUpload,
|
|
2246
2733
|
onSwitchMode: showModeToggle ? () => handleModeChange("command") : void 0
|
|
2247
2734
|
}
|
|
2248
2735
|
)
|
|
2249
2736
|
] }),
|
|
2250
|
-
mode === "command" && /* @__PURE__ */
|
|
2737
|
+
mode === "command" && /* @__PURE__ */ jsx16("div", { className: "w-full", children: /* @__PURE__ */ jsx16(
|
|
2251
2738
|
CommandComposer,
|
|
2252
2739
|
{
|
|
2253
2740
|
onExecute: (text, files) => {
|
|
@@ -2263,11 +2750,12 @@ ${planToExecute}`;
|
|
|
2263
2750
|
onApprove: approvePlan,
|
|
2264
2751
|
onReject: rejectPlan,
|
|
2265
2752
|
onReset: resetCommand,
|
|
2753
|
+
onStop: handleStop,
|
|
2266
2754
|
onExpand: showModeToggle ? () => handleModeChange("chat") : void 0,
|
|
2267
2755
|
placeholder: placeholder || "Enter your command..."
|
|
2268
2756
|
}
|
|
2269
2757
|
) }),
|
|
2270
|
-
/* @__PURE__ */
|
|
2758
|
+
/* @__PURE__ */ jsx16("style", { dangerouslySetInnerHTML: {
|
|
2271
2759
|
__html: `
|
|
2272
2760
|
@keyframes pulse-border {
|
|
2273
2761
|
0%, 100% { border-color: rgb(59, 130, 246); }
|
|
@@ -2286,11 +2774,11 @@ ${planToExecute}`;
|
|
|
2286
2774
|
|
|
2287
2775
|
// src/components/Chat/CommandOutput.tsx
|
|
2288
2776
|
import { useState as useState4 } from "react";
|
|
2289
|
-
import { jsx as
|
|
2777
|
+
import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2290
2778
|
|
|
2291
2779
|
// src/components/Command/Command.tsx
|
|
2292
2780
|
import React, { useState as useState5, useEffect as useEffect4 } from "react";
|
|
2293
|
-
import { Fragment as
|
|
2781
|
+
import { Fragment as Fragment5, jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2294
2782
|
function Command({
|
|
2295
2783
|
agentId,
|
|
2296
2784
|
command: initialCommand,
|
|
@@ -2740,7 +3228,7 @@ ${planToExecute}`;
|
|
|
2740
3228
|
setUploadedFiles((prev) => prev.filter((_, i) => i !== index));
|
|
2741
3229
|
};
|
|
2742
3230
|
const isCompact = variant === "compact";
|
|
2743
|
-
return /* @__PURE__ */
|
|
3231
|
+
return /* @__PURE__ */ jsxs14(
|
|
2744
3232
|
"div",
|
|
2745
3233
|
{
|
|
2746
3234
|
className: cn(
|
|
@@ -2755,9 +3243,9 @@ ${planToExecute}`;
|
|
|
2755
3243
|
),
|
|
2756
3244
|
style: { minHeight: isCompact ? "auto" : "180px" },
|
|
2757
3245
|
children: [
|
|
2758
|
-
/* @__PURE__ */
|
|
2759
|
-
state === "idle" && allowInput && !isCompact && /* @__PURE__ */
|
|
2760
|
-
/* @__PURE__ */
|
|
3246
|
+
/* @__PURE__ */ jsxs14("div", { className: cn("flex-1 flex", isCompact ? "flex-row items-center p-3 gap-3" : "flex-col p-4"), children: [
|
|
3247
|
+
state === "idle" && allowInput && !isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3248
|
+
/* @__PURE__ */ jsx18(
|
|
2761
3249
|
"textarea",
|
|
2762
3250
|
{
|
|
2763
3251
|
value: command,
|
|
@@ -2773,42 +3261,42 @@ ${planToExecute}`;
|
|
|
2773
3261
|
rows: 6
|
|
2774
3262
|
}
|
|
2775
3263
|
),
|
|
2776
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
2777
|
-
file.type === "image" ? /* @__PURE__ */
|
|
3264
|
+
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: [
|
|
3265
|
+
file.type === "image" ? /* @__PURE__ */ jsx18(
|
|
2778
3266
|
"img",
|
|
2779
3267
|
{
|
|
2780
3268
|
src: file.preview,
|
|
2781
3269
|
alt: file.name,
|
|
2782
3270
|
className: "w-20 h-20 object-cover rounded-lg border-2 border-gray-300 dark:border-gray-600"
|
|
2783
3271
|
}
|
|
2784
|
-
) : /* @__PURE__ */
|
|
2785
|
-
/* @__PURE__ */
|
|
2786
|
-
/* @__PURE__ */
|
|
3272
|
+
) : /* @__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: [
|
|
3273
|
+
/* @__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" }) }),
|
|
3274
|
+
/* @__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
3275
|
] }),
|
|
2788
|
-
/* @__PURE__ */
|
|
3276
|
+
/* @__PURE__ */ jsx18(
|
|
2789
3277
|
"button",
|
|
2790
3278
|
{
|
|
2791
3279
|
onClick: () => removeFile(index),
|
|
2792
3280
|
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
3281
|
title: `Remove ${file.type}`,
|
|
2794
|
-
children: /* @__PURE__ */
|
|
3282
|
+
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
3283
|
}
|
|
2796
3284
|
)
|
|
2797
3285
|
] }, index)) })
|
|
2798
3286
|
] }),
|
|
2799
|
-
state === "idle" && allowInput && isCompact && /* @__PURE__ */
|
|
2800
|
-
/* @__PURE__ */
|
|
2801
|
-
enableFileUpload && /* @__PURE__ */
|
|
3287
|
+
state === "idle" && allowInput && isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3288
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-0.5 flex-shrink-0", children: [
|
|
3289
|
+
enableFileUpload && /* @__PURE__ */ jsx18(
|
|
2802
3290
|
"button",
|
|
2803
3291
|
{
|
|
2804
3292
|
onClick: () => fileInputRef.current?.click(),
|
|
2805
3293
|
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
3294
|
title: "Attach file",
|
|
2807
|
-
children: /* @__PURE__ */
|
|
3295
|
+
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
3296
|
}
|
|
2809
3297
|
),
|
|
2810
|
-
planMode && /* @__PURE__ */
|
|
2811
|
-
/* @__PURE__ */
|
|
3298
|
+
planMode && /* @__PURE__ */ jsxs14("div", { className: "relative settings-menu-container", children: [
|
|
3299
|
+
/* @__PURE__ */ jsx18(
|
|
2812
3300
|
"button",
|
|
2813
3301
|
{
|
|
2814
3302
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -2817,28 +3305,28 @@ ${planToExecute}`;
|
|
|
2817
3305
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-gray-500 dark:!text-gray-500"
|
|
2818
3306
|
),
|
|
2819
3307
|
title: "Settings",
|
|
2820
|
-
children: /* @__PURE__ */
|
|
2821
|
-
/* @__PURE__ */
|
|
2822
|
-
/* @__PURE__ */
|
|
2823
|
-
/* @__PURE__ */
|
|
2824
|
-
/* @__PURE__ */
|
|
2825
|
-
/* @__PURE__ */
|
|
2826
|
-
/* @__PURE__ */
|
|
2827
|
-
/* @__PURE__ */
|
|
2828
|
-
/* @__PURE__ */
|
|
2829
|
-
/* @__PURE__ */
|
|
3308
|
+
children: /* @__PURE__ */ jsxs14("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
3309
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
3310
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
3311
|
+
/* @__PURE__ */ jsx18("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
3312
|
+
/* @__PURE__ */ jsx18("line", { x1: "12", y1: "8", x2: "12", y2: "3" }),
|
|
3313
|
+
/* @__PURE__ */ jsx18("line", { x1: "20", y1: "21", x2: "20", y2: "16" }),
|
|
3314
|
+
/* @__PURE__ */ jsx18("line", { x1: "20", y1: "12", x2: "20", y2: "3" }),
|
|
3315
|
+
/* @__PURE__ */ jsx18("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
3316
|
+
/* @__PURE__ */ jsx18("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
3317
|
+
/* @__PURE__ */ jsx18("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
2830
3318
|
] })
|
|
2831
3319
|
}
|
|
2832
3320
|
),
|
|
2833
|
-
showSettingsMenu && /* @__PURE__ */
|
|
2834
|
-
/* @__PURE__ */
|
|
2835
|
-
/* @__PURE__ */
|
|
2836
|
-
/* @__PURE__ */
|
|
2837
|
-
/* @__PURE__ */
|
|
2838
|
-
/* @__PURE__ */
|
|
3321
|
+
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: [
|
|
3322
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
3323
|
+
/* @__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" }) }),
|
|
3324
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
3325
|
+
/* @__PURE__ */ jsx18("div", { className: "text-xs font-medium text-gray-700 dark:text-gray-300", children: "Plan Mode" }),
|
|
3326
|
+
/* @__PURE__ */ jsx18("div", { className: "text-[10px] text-gray-500 dark:text-gray-400", children: "Review first" })
|
|
2839
3327
|
] })
|
|
2840
3328
|
] }),
|
|
2841
|
-
/* @__PURE__ */
|
|
3329
|
+
/* @__PURE__ */ jsx18(
|
|
2842
3330
|
"button",
|
|
2843
3331
|
{
|
|
2844
3332
|
onClick: (e) => {
|
|
@@ -2850,7 +3338,7 @@ ${planToExecute}`;
|
|
|
2850
3338
|
internalPlanMode ? "bg-blue-600" : "bg-gray-300 dark:bg-gray-600"
|
|
2851
3339
|
),
|
|
2852
3340
|
type: "button",
|
|
2853
|
-
children: /* @__PURE__ */
|
|
3341
|
+
children: /* @__PURE__ */ jsx18(
|
|
2854
3342
|
"span",
|
|
2855
3343
|
{
|
|
2856
3344
|
className: cn(
|
|
@@ -2864,26 +3352,26 @@ ${planToExecute}`;
|
|
|
2864
3352
|
] }) })
|
|
2865
3353
|
] })
|
|
2866
3354
|
] }),
|
|
2867
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
2868
|
-
file.type === "image" ? /* @__PURE__ */
|
|
3355
|
+
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: [
|
|
3356
|
+
file.type === "image" ? /* @__PURE__ */ jsx18(
|
|
2869
3357
|
"img",
|
|
2870
3358
|
{
|
|
2871
3359
|
src: file.preview,
|
|
2872
3360
|
alt: file.name,
|
|
2873
3361
|
className: "w-8 h-8 object-cover rounded border border-gray-300 dark:border-gray-600"
|
|
2874
3362
|
}
|
|
2875
|
-
) : /* @__PURE__ */
|
|
2876
|
-
/* @__PURE__ */
|
|
3363
|
+
) : /* @__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" }) }) }),
|
|
3364
|
+
/* @__PURE__ */ jsx18(
|
|
2877
3365
|
"button",
|
|
2878
3366
|
{
|
|
2879
3367
|
onClick: () => removeFile(index),
|
|
2880
3368
|
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
3369
|
title: "Remove",
|
|
2882
|
-
children: /* @__PURE__ */
|
|
3370
|
+
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
3371
|
}
|
|
2884
3372
|
)
|
|
2885
3373
|
] }, index)) }),
|
|
2886
|
-
/* @__PURE__ */
|
|
3374
|
+
/* @__PURE__ */ jsx18(
|
|
2887
3375
|
"input",
|
|
2888
3376
|
{
|
|
2889
3377
|
type: "text",
|
|
@@ -2899,7 +3387,7 @@ ${planToExecute}`;
|
|
|
2899
3387
|
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
3388
|
}
|
|
2901
3389
|
),
|
|
2902
|
-
/* @__PURE__ */
|
|
3390
|
+
/* @__PURE__ */ jsx18(
|
|
2903
3391
|
"button",
|
|
2904
3392
|
{
|
|
2905
3393
|
onClick: () => executeCommand(),
|
|
@@ -2915,33 +3403,33 @@ ${planToExecute}`;
|
|
|
2915
3403
|
!command.trim() && "border-gray-200 dark:border-gray-700 !text-gray-400 dark:!text-gray-600"
|
|
2916
3404
|
),
|
|
2917
3405
|
title: "Execute",
|
|
2918
|
-
children: /* @__PURE__ */
|
|
3406
|
+
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
3407
|
}
|
|
2920
3408
|
)
|
|
2921
3409
|
] }),
|
|
2922
|
-
state === "loading" && !isCompact && /* @__PURE__ */
|
|
2923
|
-
/* @__PURE__ */
|
|
2924
|
-
/* @__PURE__ */
|
|
2925
|
-
showProgress && /* @__PURE__ */
|
|
2926
|
-
/* @__PURE__ */
|
|
3410
|
+
state === "loading" && !isCompact && /* @__PURE__ */ jsxs14("div", { className: "flex-1 flex flex-col items-center justify-center space-y-4 py-8", children: [
|
|
3411
|
+
/* @__PURE__ */ jsx18("div", { className: "w-6 h-6 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
3412
|
+
/* @__PURE__ */ jsx18("div", { className: "text-gray-600 dark:text-gray-400 text-sm text-center max-w-md", children: enableStreaming && streamedContent ? streamedContent : loadingText }),
|
|
3413
|
+
showProgress && /* @__PURE__ */ jsxs14("div", { className: "w-full max-w-sm", children: [
|
|
3414
|
+
/* @__PURE__ */ jsx18("div", { className: "w-full bg-gray-200 dark:bg-gray-700 rounded-full h-1.5", children: /* @__PURE__ */ jsx18(
|
|
2927
3415
|
"div",
|
|
2928
3416
|
{
|
|
2929
3417
|
className: "bg-blue-500 h-1.5 rounded-full transition-all duration-300",
|
|
2930
3418
|
style: { width: `${progress}%` }
|
|
2931
3419
|
}
|
|
2932
3420
|
) }),
|
|
2933
|
-
/* @__PURE__ */
|
|
3421
|
+
/* @__PURE__ */ jsxs14("p", { className: "text-xs text-gray-500 mt-2 text-center", children: [
|
|
2934
3422
|
progress,
|
|
2935
3423
|
"%"
|
|
2936
3424
|
] })
|
|
2937
3425
|
] })
|
|
2938
3426
|
] }),
|
|
2939
|
-
state === "loading" && isCompact && /* @__PURE__ */
|
|
2940
|
-
/* @__PURE__ */
|
|
2941
|
-
/* @__PURE__ */
|
|
2942
|
-
/* @__PURE__ */
|
|
3427
|
+
state === "loading" && isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3428
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex-1 flex items-center gap-3 py-1", children: [
|
|
3429
|
+
/* @__PURE__ */ jsx18("div", { className: "w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
3430
|
+
/* @__PURE__ */ jsx18("div", { className: "text-gray-600 dark:text-gray-400 text-sm truncate", children: enableStreaming && streamedContent ? streamedContent : loadingText })
|
|
2943
3431
|
] }),
|
|
2944
|
-
/* @__PURE__ */
|
|
3432
|
+
/* @__PURE__ */ jsx18(
|
|
2945
3433
|
"button",
|
|
2946
3434
|
{
|
|
2947
3435
|
disabled: true,
|
|
@@ -2953,20 +3441,20 @@ ${planToExecute}`;
|
|
|
2953
3441
|
"!text-lg",
|
|
2954
3442
|
"opacity-30 cursor-not-allowed"
|
|
2955
3443
|
),
|
|
2956
|
-
children: /* @__PURE__ */
|
|
3444
|
+
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
3445
|
}
|
|
2958
3446
|
)
|
|
2959
3447
|
] }),
|
|
2960
|
-
state === "plan-pending" && !isCompact && /* @__PURE__ */
|
|
2961
|
-
/* @__PURE__ */
|
|
2962
|
-
/* @__PURE__ */
|
|
2963
|
-
/* @__PURE__ */
|
|
2964
|
-
/* @__PURE__ */
|
|
2965
|
-
/* @__PURE__ */
|
|
3448
|
+
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: [
|
|
3449
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-start gap-2 mb-3", children: [
|
|
3450
|
+
/* @__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" }) }),
|
|
3451
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex-1", children: [
|
|
3452
|
+
/* @__PURE__ */ jsx18("h3", { className: "text-sm font-semibold text-blue-800 dark:text-blue-300 mb-1", children: "Proposed Plan" }),
|
|
3453
|
+
/* @__PURE__ */ jsx18("div", { className: "text-blue-700 dark:text-blue-300 text-sm whitespace-pre-line leading-relaxed", children: plan })
|
|
2966
3454
|
] })
|
|
2967
3455
|
] }),
|
|
2968
|
-
/* @__PURE__ */
|
|
2969
|
-
/* @__PURE__ */
|
|
3456
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex gap-2 mt-4", children: [
|
|
3457
|
+
/* @__PURE__ */ jsx18(
|
|
2970
3458
|
"button",
|
|
2971
3459
|
{
|
|
2972
3460
|
onClick: approvePlan,
|
|
@@ -2974,7 +3462,7 @@ ${planToExecute}`;
|
|
|
2974
3462
|
children: "Approve & Execute"
|
|
2975
3463
|
}
|
|
2976
3464
|
),
|
|
2977
|
-
/* @__PURE__ */
|
|
3465
|
+
/* @__PURE__ */ jsx18(
|
|
2978
3466
|
"button",
|
|
2979
3467
|
{
|
|
2980
3468
|
onClick: rejectPlan,
|
|
@@ -2984,20 +3472,20 @@ ${planToExecute}`;
|
|
|
2984
3472
|
)
|
|
2985
3473
|
] })
|
|
2986
3474
|
] }) }),
|
|
2987
|
-
state === "plan-pending" && isCompact && /* @__PURE__ */
|
|
2988
|
-
/* @__PURE__ */
|
|
3475
|
+
state === "plan-pending" && isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3476
|
+
/* @__PURE__ */ jsxs14(
|
|
2989
3477
|
"button",
|
|
2990
3478
|
{
|
|
2991
3479
|
onClick: () => setShowPlanDetails(true),
|
|
2992
3480
|
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
3481
|
children: [
|
|
2994
|
-
/* @__PURE__ */
|
|
2995
|
-
/* @__PURE__ */
|
|
3482
|
+
/* @__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" }) }),
|
|
3483
|
+
/* @__PURE__ */ jsx18("span", { className: "text-sm font-medium text-blue-700 dark:text-blue-300 truncate flex-1", children: "View Execution Plan" })
|
|
2996
3484
|
]
|
|
2997
3485
|
}
|
|
2998
3486
|
),
|
|
2999
|
-
/* @__PURE__ */
|
|
3000
|
-
/* @__PURE__ */
|
|
3487
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex gap-2 flex-shrink-0", children: [
|
|
3488
|
+
/* @__PURE__ */ jsx18(
|
|
3001
3489
|
"button",
|
|
3002
3490
|
{
|
|
3003
3491
|
onClick: approvePlan,
|
|
@@ -3005,7 +3493,7 @@ ${planToExecute}`;
|
|
|
3005
3493
|
children: "Approve"
|
|
3006
3494
|
}
|
|
3007
3495
|
),
|
|
3008
|
-
/* @__PURE__ */
|
|
3496
|
+
/* @__PURE__ */ jsx18(
|
|
3009
3497
|
"button",
|
|
3010
3498
|
{
|
|
3011
3499
|
onClick: rejectPlan,
|
|
@@ -3015,15 +3503,15 @@ ${planToExecute}`;
|
|
|
3015
3503
|
)
|
|
3016
3504
|
] })
|
|
3017
3505
|
] }),
|
|
3018
|
-
state === "error" && /* @__PURE__ */
|
|
3019
|
-
/* @__PURE__ */
|
|
3020
|
-
/* @__PURE__ */
|
|
3021
|
-
/* @__PURE__ */
|
|
3022
|
-
/* @__PURE__ */
|
|
3023
|
-
/* @__PURE__ */
|
|
3506
|
+
state === "error" && /* @__PURE__ */ jsxs14("div", { className: "flex-1 flex flex-col", children: [
|
|
3507
|
+
/* @__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: [
|
|
3508
|
+
/* @__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" }) }),
|
|
3509
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
3510
|
+
/* @__PURE__ */ jsx18("h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
|
|
3511
|
+
/* @__PURE__ */ jsx18("p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: error?.message })
|
|
3024
3512
|
] })
|
|
3025
3513
|
] }) }),
|
|
3026
|
-
allowInput && /* @__PURE__ */
|
|
3514
|
+
allowInput && /* @__PURE__ */ jsx18(
|
|
3027
3515
|
"textarea",
|
|
3028
3516
|
{
|
|
3029
3517
|
value: command,
|
|
@@ -3040,16 +3528,16 @@ ${planToExecute}`;
|
|
|
3040
3528
|
}
|
|
3041
3529
|
)
|
|
3042
3530
|
] }),
|
|
3043
|
-
state === "success" && result && !isCompact && /* @__PURE__ */
|
|
3044
|
-
/* @__PURE__ */
|
|
3045
|
-
/* @__PURE__ */
|
|
3046
|
-
/* @__PURE__ */
|
|
3047
|
-
/* @__PURE__ */
|
|
3048
|
-
/* @__PURE__ */
|
|
3531
|
+
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: [
|
|
3532
|
+
/* @__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: [
|
|
3533
|
+
/* @__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" }) }),
|
|
3534
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex-1", children: [
|
|
3535
|
+
/* @__PURE__ */ jsx18("h3", { className: "text-sm font-semibold text-green-800 dark:text-green-400 mb-1", children: "Success" }),
|
|
3536
|
+
/* @__PURE__ */ jsx18("p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
3049
3537
|
] })
|
|
3050
3538
|
] }),
|
|
3051
|
-
result.data?.summary && /* @__PURE__ */
|
|
3052
|
-
result.widgets && result.widgets.length > 0 && /* @__PURE__ */
|
|
3539
|
+
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 }),
|
|
3540
|
+
result.widgets && result.widgets.length > 0 && /* @__PURE__ */ jsx18("div", { className: "space-y-3", children: result.widgets.map((widget) => /* @__PURE__ */ jsx18(
|
|
3053
3541
|
WidgetRenderer,
|
|
3054
3542
|
{
|
|
3055
3543
|
widget,
|
|
@@ -3058,8 +3546,8 @@ ${planToExecute}`;
|
|
|
3058
3546
|
widget.id
|
|
3059
3547
|
)) })
|
|
3060
3548
|
] }) }),
|
|
3061
|
-
state === "success" && result && isCompact && /* @__PURE__ */
|
|
3062
|
-
/* @__PURE__ */
|
|
3549
|
+
state === "success" && result && isCompact && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3550
|
+
/* @__PURE__ */ jsxs14(
|
|
3063
3551
|
"div",
|
|
3064
3552
|
{
|
|
3065
3553
|
className: "flex-1 flex items-center gap-2 py-1 cursor-text min-w-0",
|
|
@@ -3068,12 +3556,12 @@ ${planToExecute}`;
|
|
|
3068
3556
|
setResult(null);
|
|
3069
3557
|
},
|
|
3070
3558
|
children: [
|
|
3071
|
-
/* @__PURE__ */
|
|
3072
|
-
/* @__PURE__ */
|
|
3559
|
+
/* @__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" }) }),
|
|
3560
|
+
/* @__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
3561
|
]
|
|
3074
3562
|
}
|
|
3075
3563
|
),
|
|
3076
|
-
/* @__PURE__ */
|
|
3564
|
+
/* @__PURE__ */ jsx18(
|
|
3077
3565
|
"button",
|
|
3078
3566
|
{
|
|
3079
3567
|
onClick: () => {
|
|
@@ -3089,24 +3577,24 @@ ${planToExecute}`;
|
|
|
3089
3577
|
"!text-lg"
|
|
3090
3578
|
),
|
|
3091
3579
|
title: "New command",
|
|
3092
|
-
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" }) })
|
|
3093
3581
|
}
|
|
3094
3582
|
)
|
|
3095
3583
|
] })
|
|
3096
3584
|
] }),
|
|
3097
|
-
!isCompact && /* @__PURE__ */
|
|
3098
|
-
/* @__PURE__ */
|
|
3099
|
-
enableFileUpload && /* @__PURE__ */
|
|
3585
|
+
!isCompact && /* @__PURE__ */ jsxs14("div", { className: "p-3 flex items-center justify-between gap-2", children: [
|
|
3586
|
+
/* @__PURE__ */ jsx18("div", { className: "flex items-center gap-1", children: state === "idle" && allowInput && /* @__PURE__ */ jsxs14(Fragment5, { children: [
|
|
3587
|
+
enableFileUpload && /* @__PURE__ */ jsx18(
|
|
3100
3588
|
"button",
|
|
3101
3589
|
{
|
|
3102
3590
|
onClick: () => fileInputRef.current?.click(),
|
|
3103
3591
|
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
3592
|
title: "Attach file",
|
|
3105
|
-
children: /* @__PURE__ */
|
|
3593
|
+
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
3594
|
}
|
|
3107
3595
|
),
|
|
3108
|
-
planMode && /* @__PURE__ */
|
|
3109
|
-
/* @__PURE__ */
|
|
3596
|
+
planMode && /* @__PURE__ */ jsxs14("div", { className: "relative settings-menu-container", children: [
|
|
3597
|
+
/* @__PURE__ */ jsx18(
|
|
3110
3598
|
"button",
|
|
3111
3599
|
{
|
|
3112
3600
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -3115,28 +3603,28 @@ ${planToExecute}`;
|
|
|
3115
3603
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-gray-500 dark:!text-gray-500"
|
|
3116
3604
|
),
|
|
3117
3605
|
title: "Settings",
|
|
3118
|
-
children: /* @__PURE__ */
|
|
3119
|
-
/* @__PURE__ */
|
|
3120
|
-
/* @__PURE__ */
|
|
3121
|
-
/* @__PURE__ */
|
|
3122
|
-
/* @__PURE__ */
|
|
3123
|
-
/* @__PURE__ */
|
|
3124
|
-
/* @__PURE__ */
|
|
3125
|
-
/* @__PURE__ */
|
|
3126
|
-
/* @__PURE__ */
|
|
3127
|
-
/* @__PURE__ */
|
|
3606
|
+
children: /* @__PURE__ */ jsxs14("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
3607
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
3608
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
3609
|
+
/* @__PURE__ */ jsx18("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
3610
|
+
/* @__PURE__ */ jsx18("line", { x1: "12", y1: "8", x2: "12", y2: "3" }),
|
|
3611
|
+
/* @__PURE__ */ jsx18("line", { x1: "20", y1: "21", x2: "20", y2: "16" }),
|
|
3612
|
+
/* @__PURE__ */ jsx18("line", { x1: "20", y1: "12", x2: "20", y2: "3" }),
|
|
3613
|
+
/* @__PURE__ */ jsx18("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
3614
|
+
/* @__PURE__ */ jsx18("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
3615
|
+
/* @__PURE__ */ jsx18("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
3128
3616
|
] })
|
|
3129
3617
|
}
|
|
3130
3618
|
),
|
|
3131
|
-
showSettingsMenu && /* @__PURE__ */
|
|
3132
|
-
/* @__PURE__ */
|
|
3133
|
-
/* @__PURE__ */
|
|
3134
|
-
/* @__PURE__ */
|
|
3135
|
-
/* @__PURE__ */
|
|
3136
|
-
/* @__PURE__ */
|
|
3619
|
+
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: [
|
|
3620
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
3621
|
+
/* @__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" }) }),
|
|
3622
|
+
/* @__PURE__ */ jsxs14("div", { children: [
|
|
3623
|
+
/* @__PURE__ */ jsx18("div", { className: "text-sm font-medium text-gray-700 dark:text-gray-300", children: "Plan Mode" }),
|
|
3624
|
+
/* @__PURE__ */ jsx18("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: "Review before executing" })
|
|
3137
3625
|
] })
|
|
3138
3626
|
] }),
|
|
3139
|
-
/* @__PURE__ */
|
|
3627
|
+
/* @__PURE__ */ jsx18(
|
|
3140
3628
|
"button",
|
|
3141
3629
|
{
|
|
3142
3630
|
onClick: (e) => {
|
|
@@ -3148,7 +3636,7 @@ ${planToExecute}`;
|
|
|
3148
3636
|
internalPlanMode ? "bg-blue-600" : "bg-gray-300 dark:bg-gray-600"
|
|
3149
3637
|
),
|
|
3150
3638
|
type: "button",
|
|
3151
|
-
children: /* @__PURE__ */
|
|
3639
|
+
children: /* @__PURE__ */ jsx18(
|
|
3152
3640
|
"span",
|
|
3153
3641
|
{
|
|
3154
3642
|
className: cn(
|
|
@@ -3162,9 +3650,9 @@ ${planToExecute}`;
|
|
|
3162
3650
|
] }) })
|
|
3163
3651
|
] })
|
|
3164
3652
|
] }) }),
|
|
3165
|
-
!(state === "idle" && allowInput) && /* @__PURE__ */
|
|
3166
|
-
/* @__PURE__ */
|
|
3167
|
-
(state === "success" || state === "error") && allowInput && /* @__PURE__ */
|
|
3653
|
+
!(state === "idle" && allowInput) && /* @__PURE__ */ jsx18("div", {}),
|
|
3654
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
3655
|
+
(state === "success" || state === "error") && allowInput && /* @__PURE__ */ jsx18(
|
|
3168
3656
|
"button",
|
|
3169
3657
|
{
|
|
3170
3658
|
onClick: resetCommand,
|
|
@@ -3172,7 +3660,7 @@ ${planToExecute}`;
|
|
|
3172
3660
|
children: "Reset"
|
|
3173
3661
|
}
|
|
3174
3662
|
),
|
|
3175
|
-
(state === "idle" || state === "error") && /* @__PURE__ */
|
|
3663
|
+
(state === "idle" || state === "error") && /* @__PURE__ */ jsx18(
|
|
3176
3664
|
"button",
|
|
3177
3665
|
{
|
|
3178
3666
|
onClick: () => executeCommand(),
|
|
@@ -3188,29 +3676,29 @@ ${planToExecute}`;
|
|
|
3188
3676
|
!command.trim() && "border-gray-200 dark:border-gray-700 !text-gray-400 dark:!text-gray-600"
|
|
3189
3677
|
),
|
|
3190
3678
|
title: state === "error" ? "Retry" : "Execute",
|
|
3191
|
-
children: state === "error" ? /* @__PURE__ */
|
|
3679
|
+
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
3680
|
}
|
|
3193
3681
|
)
|
|
3194
3682
|
] })
|
|
3195
3683
|
] }),
|
|
3196
|
-
showPlanDetails && isCompact && state === "plan-pending" && /* @__PURE__ */
|
|
3197
|
-
/* @__PURE__ */
|
|
3198
|
-
/* @__PURE__ */
|
|
3199
|
-
/* @__PURE__ */
|
|
3200
|
-
/* @__PURE__ */
|
|
3684
|
+
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: [
|
|
3685
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700", children: [
|
|
3686
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-3", children: [
|
|
3687
|
+
/* @__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" }) }),
|
|
3688
|
+
/* @__PURE__ */ jsx18("h2", { className: "text-xl font-semibold text-gray-900 dark:text-white", children: "Proposed Execution Plan" })
|
|
3201
3689
|
] }),
|
|
3202
|
-
/* @__PURE__ */
|
|
3690
|
+
/* @__PURE__ */ jsx18(
|
|
3203
3691
|
"button",
|
|
3204
3692
|
{
|
|
3205
3693
|
onClick: () => setShowPlanDetails(false),
|
|
3206
3694
|
className: "text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",
|
|
3207
|
-
children: /* @__PURE__ */
|
|
3695
|
+
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
3696
|
}
|
|
3209
3697
|
)
|
|
3210
3698
|
] }),
|
|
3211
|
-
/* @__PURE__ */
|
|
3212
|
-
/* @__PURE__ */
|
|
3213
|
-
/* @__PURE__ */
|
|
3699
|
+
/* @__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 }) }) }),
|
|
3700
|
+
/* @__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: [
|
|
3701
|
+
/* @__PURE__ */ jsx18(
|
|
3214
3702
|
"button",
|
|
3215
3703
|
{
|
|
3216
3704
|
onClick: rejectPlan,
|
|
@@ -3218,7 +3706,7 @@ ${planToExecute}`;
|
|
|
3218
3706
|
children: "Modify Command"
|
|
3219
3707
|
}
|
|
3220
3708
|
),
|
|
3221
|
-
/* @__PURE__ */
|
|
3709
|
+
/* @__PURE__ */ jsx18(
|
|
3222
3710
|
"button",
|
|
3223
3711
|
{
|
|
3224
3712
|
onClick: approvePlan,
|
|
@@ -3228,7 +3716,7 @@ ${planToExecute}`;
|
|
|
3228
3716
|
)
|
|
3229
3717
|
] })
|
|
3230
3718
|
] }) }),
|
|
3231
|
-
/* @__PURE__ */
|
|
3719
|
+
/* @__PURE__ */ jsx18(
|
|
3232
3720
|
"input",
|
|
3233
3721
|
{
|
|
3234
3722
|
ref: fileInputRef,
|
|
@@ -3239,7 +3727,7 @@ ${planToExecute}`;
|
|
|
3239
3727
|
accept: "image/*,application/pdf,.doc,.docx,.txt"
|
|
3240
3728
|
}
|
|
3241
3729
|
),
|
|
3242
|
-
/* @__PURE__ */
|
|
3730
|
+
/* @__PURE__ */ jsx18("style", { dangerouslySetInnerHTML: {
|
|
3243
3731
|
__html: `
|
|
3244
3732
|
@keyframes pulse-border {
|
|
3245
3733
|
0%, 100% {
|
|
@@ -3261,7 +3749,7 @@ ${planToExecute}`;
|
|
|
3261
3749
|
|
|
3262
3750
|
// src/components/Prompt/Prompt.tsx
|
|
3263
3751
|
import { useState as useState6 } from "react";
|
|
3264
|
-
import { jsx as
|
|
3752
|
+
import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3265
3753
|
function Prompt({
|
|
3266
3754
|
agentId,
|
|
3267
3755
|
placeholder = "Enter your prompt...",
|
|
@@ -3323,9 +3811,9 @@ function Prompt({
|
|
|
3323
3811
|
handleSubmit();
|
|
3324
3812
|
}
|
|
3325
3813
|
};
|
|
3326
|
-
return /* @__PURE__ */
|
|
3327
|
-
/* @__PURE__ */
|
|
3328
|
-
/* @__PURE__ */
|
|
3814
|
+
return /* @__PURE__ */ jsxs15("div", { className: cn("space-y-2", className), children: [
|
|
3815
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex gap-2", children: [
|
|
3816
|
+
/* @__PURE__ */ jsx19(
|
|
3329
3817
|
"input",
|
|
3330
3818
|
{
|
|
3331
3819
|
type: "text",
|
|
@@ -3338,7 +3826,7 @@ function Prompt({
|
|
|
3338
3826
|
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
3827
|
}
|
|
3340
3828
|
),
|
|
3341
|
-
submitOn === "button" && /* @__PURE__ */
|
|
3829
|
+
submitOn === "button" && /* @__PURE__ */ jsx19(
|
|
3342
3830
|
"button",
|
|
3343
3831
|
{
|
|
3344
3832
|
onClick: handleSubmit,
|
|
@@ -3348,13 +3836,13 @@ function Prompt({
|
|
|
3348
3836
|
}
|
|
3349
3837
|
)
|
|
3350
3838
|
] }),
|
|
3351
|
-
maxLength && /* @__PURE__ */
|
|
3839
|
+
maxLength && /* @__PURE__ */ jsxs15("p", { className: "text-xs text-gray-500", children: [
|
|
3352
3840
|
value.length,
|
|
3353
3841
|
" / ",
|
|
3354
3842
|
maxLength,
|
|
3355
3843
|
" characters"
|
|
3356
3844
|
] }),
|
|
3357
|
-
showSuggestions && !value && /* @__PURE__ */
|
|
3845
|
+
showSuggestions && !value && /* @__PURE__ */ jsx19("div", { className: "flex flex-wrap gap-2", children: suggestions.map((suggestion, idx) => /* @__PURE__ */ jsx19(
|
|
3358
3846
|
"button",
|
|
3359
3847
|
{
|
|
3360
3848
|
onClick: () => setValue(suggestion),
|
|
@@ -3363,16 +3851,16 @@ function Prompt({
|
|
|
3363
3851
|
},
|
|
3364
3852
|
idx
|
|
3365
3853
|
)) }),
|
|
3366
|
-
isLoading && /* @__PURE__ */
|
|
3367
|
-
/* @__PURE__ */
|
|
3368
|
-
/* @__PURE__ */
|
|
3854
|
+
isLoading && /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 text-sm text-gray-500", children: [
|
|
3855
|
+
/* @__PURE__ */ jsx19("div", { className: "w-4 h-4 border-2 border-apteva-500 border-t-transparent rounded-full animate-spin" }),
|
|
3856
|
+
/* @__PURE__ */ jsx19("span", { children: "AI is processing your request..." })
|
|
3369
3857
|
] })
|
|
3370
3858
|
] });
|
|
3371
3859
|
}
|
|
3372
3860
|
|
|
3373
3861
|
// src/components/Stream/Stream.tsx
|
|
3374
3862
|
import { useState as useState7, useEffect as useEffect5 } from "react";
|
|
3375
|
-
import { jsx as
|
|
3863
|
+
import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3376
3864
|
function Stream({
|
|
3377
3865
|
agentId,
|
|
3378
3866
|
prompt,
|
|
@@ -3452,7 +3940,7 @@ function Stream({
|
|
|
3452
3940
|
plain: "text-gray-900 dark:text-gray-100"
|
|
3453
3941
|
};
|
|
3454
3942
|
if (!isStreaming && !isComplete) {
|
|
3455
|
-
return /* @__PURE__ */
|
|
3943
|
+
return /* @__PURE__ */ jsx20("div", { className: cn("p-4", className), children: /* @__PURE__ */ jsx20(
|
|
3456
3944
|
"button",
|
|
3457
3945
|
{
|
|
3458
3946
|
onClick: startStreaming,
|
|
@@ -3461,9 +3949,9 @@ function Stream({
|
|
|
3461
3949
|
}
|
|
3462
3950
|
) });
|
|
3463
3951
|
}
|
|
3464
|
-
return /* @__PURE__ */
|
|
3952
|
+
return /* @__PURE__ */ jsxs16("div", { className: cn(variantClasses[variant], className), children: [
|
|
3465
3953
|
text,
|
|
3466
|
-
isStreaming && showCursor && /* @__PURE__ */
|
|
3954
|
+
isStreaming && showCursor && /* @__PURE__ */ jsx20("span", { className: "apteva-stream-cursor" })
|
|
3467
3955
|
] });
|
|
3468
3956
|
}
|
|
3469
3957
|
|
|
@@ -3471,9 +3959,9 @@ function Stream({
|
|
|
3471
3959
|
import { useState as useState8 } from "react";
|
|
3472
3960
|
|
|
3473
3961
|
// src/components/Threads/ThreadItem.tsx
|
|
3474
|
-
import { jsx as
|
|
3962
|
+
import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3475
3963
|
function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
3476
|
-
return /* @__PURE__ */
|
|
3964
|
+
return /* @__PURE__ */ jsxs17(
|
|
3477
3965
|
"div",
|
|
3478
3966
|
{
|
|
3479
3967
|
className: cn("apteva-thread-item", {
|
|
@@ -3481,19 +3969,19 @@ function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
|
3481
3969
|
}),
|
|
3482
3970
|
onClick: onSelect,
|
|
3483
3971
|
children: [
|
|
3484
|
-
/* @__PURE__ */
|
|
3485
|
-
/* @__PURE__ */
|
|
3486
|
-
thread.preview && /* @__PURE__ */
|
|
3487
|
-
/* @__PURE__ */
|
|
3488
|
-
/* @__PURE__ */
|
|
3972
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex-1 min-w-0", children: [
|
|
3973
|
+
/* @__PURE__ */ jsx21("h4", { className: "font-semibold text-gray-900 dark:text-white truncate", children: thread.title }),
|
|
3974
|
+
thread.preview && /* @__PURE__ */ jsx21("p", { className: "text-sm text-gray-600 dark:text-gray-400 truncate", children: thread.preview }),
|
|
3975
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2 mt-1 text-xs text-gray-500", children: [
|
|
3976
|
+
/* @__PURE__ */ jsxs17("span", { children: [
|
|
3489
3977
|
thread.messageCount,
|
|
3490
3978
|
" messages"
|
|
3491
3979
|
] }),
|
|
3492
|
-
/* @__PURE__ */
|
|
3493
|
-
/* @__PURE__ */
|
|
3980
|
+
/* @__PURE__ */ jsx21("span", { children: "\u2022" }),
|
|
3981
|
+
/* @__PURE__ */ jsx21("span", { children: formatRelativeTime(thread.updatedAt) })
|
|
3494
3982
|
] })
|
|
3495
3983
|
] }),
|
|
3496
|
-
onDelete && /* @__PURE__ */
|
|
3984
|
+
onDelete && /* @__PURE__ */ jsx21(
|
|
3497
3985
|
"button",
|
|
3498
3986
|
{
|
|
3499
3987
|
onClick: (e) => {
|
|
@@ -3523,7 +4011,7 @@ function formatRelativeTime(date) {
|
|
|
3523
4011
|
}
|
|
3524
4012
|
|
|
3525
4013
|
// src/components/Threads/ThreadList.tsx
|
|
3526
|
-
import { jsx as
|
|
4014
|
+
import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3527
4015
|
function ThreadList({
|
|
3528
4016
|
threads,
|
|
3529
4017
|
currentThreadId,
|
|
@@ -3537,8 +4025,8 @@ function ThreadList({
|
|
|
3537
4025
|
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || thread.preview?.toLowerCase().includes(searchQuery.toLowerCase())
|
|
3538
4026
|
);
|
|
3539
4027
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
3540
|
-
return /* @__PURE__ */
|
|
3541
|
-
showSearch && /* @__PURE__ */
|
|
4028
|
+
return /* @__PURE__ */ jsxs18("div", { className: "flex flex-col h-full", children: [
|
|
4029
|
+
showSearch && /* @__PURE__ */ jsx22("div", { className: "p-3 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsx22(
|
|
3542
4030
|
"input",
|
|
3543
4031
|
{
|
|
3544
4032
|
type: "text",
|
|
@@ -3548,10 +4036,10 @@ function ThreadList({
|
|
|
3548
4036
|
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
4037
|
}
|
|
3550
4038
|
) }),
|
|
3551
|
-
/* @__PURE__ */
|
|
3552
|
-
Object.entries(groupedThreads).map(([group, groupThreads]) => /* @__PURE__ */
|
|
3553
|
-
groupBy !== "none" && /* @__PURE__ */
|
|
3554
|
-
groupThreads.map((thread) => /* @__PURE__ */
|
|
4039
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1 overflow-y-auto", children: [
|
|
4040
|
+
Object.entries(groupedThreads).map(([group, groupThreads]) => /* @__PURE__ */ jsxs18("div", { children: [
|
|
4041
|
+
groupBy !== "none" && /* @__PURE__ */ jsx22("div", { className: "px-3 py-2 text-xs font-semibold text-gray-500 uppercase", children: group }),
|
|
4042
|
+
groupThreads.map((thread) => /* @__PURE__ */ jsx22(
|
|
3555
4043
|
ThreadItem,
|
|
3556
4044
|
{
|
|
3557
4045
|
thread,
|
|
@@ -3562,9 +4050,9 @@ function ThreadList({
|
|
|
3562
4050
|
thread.id
|
|
3563
4051
|
))
|
|
3564
4052
|
] }, group)),
|
|
3565
|
-
filteredThreads.length === 0 && /* @__PURE__ */
|
|
3566
|
-
/* @__PURE__ */
|
|
3567
|
-
/* @__PURE__ */
|
|
4053
|
+
filteredThreads.length === 0 && /* @__PURE__ */ jsxs18("div", { className: "p-8 text-center text-gray-500", children: [
|
|
4054
|
+
/* @__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" }) }),
|
|
4055
|
+
/* @__PURE__ */ jsx22("p", { children: "No conversations found" })
|
|
3568
4056
|
] })
|
|
3569
4057
|
] })
|
|
3570
4058
|
] });
|
|
@@ -3596,7 +4084,7 @@ function groupThreadsByDate(threads) {
|
|
|
3596
4084
|
}
|
|
3597
4085
|
|
|
3598
4086
|
// src/components/Threads/Threads.tsx
|
|
3599
|
-
import { jsx as
|
|
4087
|
+
import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3600
4088
|
function Threads({
|
|
3601
4089
|
threads,
|
|
3602
4090
|
currentThreadId,
|
|
@@ -3615,8 +4103,8 @@ function Threads({
|
|
|
3615
4103
|
tabs: "flex gap-2 border-b border-gray-200 dark:border-gray-700 overflow-x-auto"
|
|
3616
4104
|
};
|
|
3617
4105
|
if (variant === "tabs") {
|
|
3618
|
-
return /* @__PURE__ */
|
|
3619
|
-
threads.slice(0, 5).map((thread) => /* @__PURE__ */
|
|
4106
|
+
return /* @__PURE__ */ jsxs19("div", { className: cn(variantClasses[variant], className), children: [
|
|
4107
|
+
threads.slice(0, 5).map((thread) => /* @__PURE__ */ jsx23(
|
|
3620
4108
|
"button",
|
|
3621
4109
|
{
|
|
3622
4110
|
onClick: () => onThreadSelect?.(thread.id),
|
|
@@ -3628,7 +4116,7 @@ function Threads({
|
|
|
3628
4116
|
},
|
|
3629
4117
|
thread.id
|
|
3630
4118
|
)),
|
|
3631
|
-
showNewButton && onNewThread && /* @__PURE__ */
|
|
4119
|
+
showNewButton && onNewThread && /* @__PURE__ */ jsx23(
|
|
3632
4120
|
"button",
|
|
3633
4121
|
{
|
|
3634
4122
|
onClick: onNewThread,
|
|
@@ -3638,8 +4126,8 @@ function Threads({
|
|
|
3638
4126
|
)
|
|
3639
4127
|
] });
|
|
3640
4128
|
}
|
|
3641
|
-
return /* @__PURE__ */
|
|
3642
|
-
showNewButton && onNewThread && /* @__PURE__ */
|
|
4129
|
+
return /* @__PURE__ */ jsxs19("div", { className: cn(variantClasses[variant], "flex flex-col", className), children: [
|
|
4130
|
+
showNewButton && onNewThread && /* @__PURE__ */ jsx23("div", { className: "p-3 border-b border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ jsx23(
|
|
3643
4131
|
"button",
|
|
3644
4132
|
{
|
|
3645
4133
|
onClick: onNewThread,
|
|
@@ -3647,7 +4135,7 @@ function Threads({
|
|
|
3647
4135
|
children: "+ New Conversation"
|
|
3648
4136
|
}
|
|
3649
4137
|
) }),
|
|
3650
|
-
/* @__PURE__ */
|
|
4138
|
+
/* @__PURE__ */ jsx23(
|
|
3651
4139
|
ThreadList,
|
|
3652
4140
|
{
|
|
3653
4141
|
threads,
|