@apteva/apteva-kit 0.1.101 → 0.1.104
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/LICENSE +38 -0
- package/README.md +18 -1
- package/dist/index.d.mts +258 -4
- package/dist/index.d.ts +258 -4
- package/dist/index.js +1158 -154
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1507 -503
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -2
package/dist/index.mjs
CHANGED
|
@@ -797,6 +797,347 @@ Widgets: @ui:type[{json}] - MUST use square brackets []. Example: @ui:list[{"ite
|
|
|
797
797
|
`;
|
|
798
798
|
}
|
|
799
799
|
|
|
800
|
+
// src/utils/interface-parser.ts
|
|
801
|
+
function findMatchingBracket2(text, startIndex) {
|
|
802
|
+
const openChar = text[startIndex];
|
|
803
|
+
const closeChar = openChar === "[" ? "]" : "}";
|
|
804
|
+
let depth = 0;
|
|
805
|
+
let inString = false;
|
|
806
|
+
let escapeNext = false;
|
|
807
|
+
for (let i = startIndex; i < text.length; i++) {
|
|
808
|
+
const char = text[i];
|
|
809
|
+
if (escapeNext) {
|
|
810
|
+
escapeNext = false;
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
if (char === "\\" && inString) {
|
|
814
|
+
escapeNext = true;
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
if (char === '"') {
|
|
818
|
+
inString = !inString;
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
if (inString) continue;
|
|
822
|
+
if (char === openChar || char === (openChar === "[" ? "{" : "[")) {
|
|
823
|
+
if (char === openChar) depth++;
|
|
824
|
+
} else if (char === closeChar || char === (closeChar === "]" ? "}" : "]")) {
|
|
825
|
+
if (char === closeChar) {
|
|
826
|
+
depth--;
|
|
827
|
+
if (depth === 0) return i;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
return -1;
|
|
832
|
+
}
|
|
833
|
+
function parseInterfaceFromText(text) {
|
|
834
|
+
const marker = "@interface[";
|
|
835
|
+
const idx = text.indexOf(marker);
|
|
836
|
+
if (idx === -1) return null;
|
|
837
|
+
const bracketStart = idx + marker.length - 1;
|
|
838
|
+
const bracketEnd = findMatchingBracket2(text, bracketStart);
|
|
839
|
+
if (bracketEnd === -1) return null;
|
|
840
|
+
const jsonContent = text.slice(bracketStart + 1, bracketEnd);
|
|
841
|
+
try {
|
|
842
|
+
const parsed = JSON.parse(jsonContent);
|
|
843
|
+
if (!parsed.root || !parsed.root.id) return null;
|
|
844
|
+
return {
|
|
845
|
+
version: parsed.version || 1,
|
|
846
|
+
root: parsed.root
|
|
847
|
+
};
|
|
848
|
+
} catch {
|
|
849
|
+
return null;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
function parseUpdatesFromText(text) {
|
|
853
|
+
const updates = [];
|
|
854
|
+
const marker = "@update[";
|
|
855
|
+
let searchFrom = 0;
|
|
856
|
+
while (true) {
|
|
857
|
+
const idx = text.indexOf(marker, searchFrom);
|
|
858
|
+
if (idx === -1) break;
|
|
859
|
+
const bracketStart = idx + marker.length - 1;
|
|
860
|
+
const bracketEnd = findMatchingBracket2(text, bracketStart);
|
|
861
|
+
if (bracketEnd === -1) break;
|
|
862
|
+
const jsonContent = text.slice(bracketStart + 1, bracketEnd);
|
|
863
|
+
try {
|
|
864
|
+
const parsed = JSON.parse(jsonContent);
|
|
865
|
+
if (Array.isArray(parsed)) {
|
|
866
|
+
updates.push(...parsed);
|
|
867
|
+
} else if (parsed.op && parsed.target) {
|
|
868
|
+
updates.push(parsed);
|
|
869
|
+
}
|
|
870
|
+
} catch {
|
|
871
|
+
}
|
|
872
|
+
searchFrom = bracketEnd + 1;
|
|
873
|
+
}
|
|
874
|
+
return updates;
|
|
875
|
+
}
|
|
876
|
+
function containsInterface(text) {
|
|
877
|
+
return text.includes("@interface[") || text.includes("@update[");
|
|
878
|
+
}
|
|
879
|
+
function stripInterface(text) {
|
|
880
|
+
let result = text;
|
|
881
|
+
const ifacePattern = /@interface\[/g;
|
|
882
|
+
let match;
|
|
883
|
+
while ((match = ifacePattern.exec(result)) !== null) {
|
|
884
|
+
const bracketStart = match.index + match[0].length - 1;
|
|
885
|
+
const bracketEnd = findMatchingBracket2(result, bracketStart);
|
|
886
|
+
if (bracketEnd === -1) break;
|
|
887
|
+
result = result.slice(0, match.index) + result.slice(bracketEnd + 1);
|
|
888
|
+
ifacePattern.lastIndex = match.index;
|
|
889
|
+
}
|
|
890
|
+
const updatePattern = /@update\[/g;
|
|
891
|
+
while ((match = updatePattern.exec(result)) !== null) {
|
|
892
|
+
const bracketStart = match.index + match[0].length - 1;
|
|
893
|
+
const bracketEnd = findMatchingBracket2(result, bracketStart);
|
|
894
|
+
if (bracketEnd === -1) break;
|
|
895
|
+
result = result.slice(0, match.index) + result.slice(bracketEnd + 1);
|
|
896
|
+
updatePattern.lastIndex = match.index;
|
|
897
|
+
}
|
|
898
|
+
return result.replace(/\s+/g, " ").trim();
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// src/utils/interface-context.ts
|
|
902
|
+
function generateInterfaceContext() {
|
|
903
|
+
return `## Auto Interface Mode
|
|
904
|
+
|
|
905
|
+
You generate full page interfaces as JSON. When asked for a dashboard, form, or any UI, respond with an @interface block.
|
|
906
|
+
|
|
907
|
+
### CRITICAL FORMAT RULES
|
|
908
|
+
1. Wrap your JSON in: @interface[{...}]
|
|
909
|
+
2. Every node MUST have: "type", "id", and "props" (an object)
|
|
910
|
+
3. Widget properties go INSIDE "props", NOT at the top level
|
|
911
|
+
4. The "type" field is the ACTUAL widget name (e.g. "form", "kpi", "table") \u2014 NEVER use "widget" as a type
|
|
912
|
+
5. Layout nodes use type: "layout" with a "layout" field for the layout kind
|
|
913
|
+
|
|
914
|
+
### Node structure
|
|
915
|
+
|
|
916
|
+
Layout node:
|
|
917
|
+
{"type": "layout", "id": "unique-id", "layout": "page|row|stack|columns|sidebar|tabs", "props": {...}, "children": [...]}
|
|
918
|
+
|
|
919
|
+
Widget node:
|
|
920
|
+
{"type": "kpi|text_block|form|table|chart|list|card|spacer|button_group|image", "id": "unique-id", "props": {...}}
|
|
921
|
+
|
|
922
|
+
### Layout types and their props
|
|
923
|
+
- page: { title?, padding?: "none"|"sm"|"md"|"lg", maxWidth?: "sm"|"md"|"lg"|"xl"|"full" }
|
|
924
|
+
- row: { columns?: number[] (e.g. [1,2] for 1/3+2/3), gap?: "none"|"sm"|"md"|"lg" }
|
|
925
|
+
- stack: { gap?: "none"|"sm"|"md"|"lg", align?: "left"|"center"|"right"|"stretch" }
|
|
926
|
+
- columns: { count?: number, gap?: "none"|"sm"|"md"|"lg" }
|
|
927
|
+
- sidebar: { side?: "left"|"right", width?: string }
|
|
928
|
+
- tabs: { labels: string[], defaultTab?: number }
|
|
929
|
+
|
|
930
|
+
### Widget types and their props
|
|
931
|
+
- kpi: { label: string, value: string, change?: string, trend?: "up"|"down"|"flat" }
|
|
932
|
+
- text_block: { content: string (markdown), variant?: "heading"|"body"|"caption" }
|
|
933
|
+
- spacer: { height?: "sm"|"md"|"lg", variant?: "line"|"space" }
|
|
934
|
+
- card: { title: string, description?: string, image?: string, footer?: string }
|
|
935
|
+
- list: { items: [{ id: string, title: string, subtitle?: string }] }
|
|
936
|
+
- table: { columns: [{ key: string, label: string }], rows: [{ key: value, ... }], striped?: boolean, compact?: boolean }
|
|
937
|
+
- chart: { chartType: "line"|"bar"|"pie", title?: string, data: { labels: string[], datasets: [{ label: string, data: number[] }] } }
|
|
938
|
+
- form: { title?: string, fields: [{ name: string, type: "text"|"email"|"select"|"textarea"|"checkbox", label: string, required?: boolean, placeholder?: string, options?: [{ label: string, value: string }] }] }
|
|
939
|
+
- button_group: { buttons: [{ id: string, label: string, variant?: string }] }
|
|
940
|
+
- image: { src: string, alt: string, caption?: string }
|
|
941
|
+
|
|
942
|
+
### CORRECT example
|
|
943
|
+
|
|
944
|
+
@interface[{"version":1,"root":{"type":"layout","id":"root","layout":"page","props":{"title":"My Form"},"children":[{"type":"text_block","id":"t1","props":{"content":"Fill out the form below","variant":"body"}},{"type":"form","id":"f1","props":{"fields":[{"name":"name","type":"text","label":"Name","required":true},{"name":"email","type":"email","label":"Email"}]}},{"type":"button_group","id":"b1","props":{"buttons":[{"id":"submit","label":"Submit"}]}}]}}]
|
|
945
|
+
|
|
946
|
+
### WRONG (do NOT do these)
|
|
947
|
+
- {"type": "widget", "props": {"widget": "form"}} \u2014 WRONG, type must be "form" directly
|
|
948
|
+
- {"type": "text_block", "content": "hello"} \u2014 WRONG, content must be inside props
|
|
949
|
+
- {"type": "text_block", "props": {"style": "heading"}} \u2014 WRONG, use "variant" not "style"
|
|
950
|
+
|
|
951
|
+
### Guidelines
|
|
952
|
+
- Always use unique IDs for every node
|
|
953
|
+
- Organize content logically: KPIs in a row, charts with supporting lists, etc.
|
|
954
|
+
- Use text_block for descriptions and headings within layouts
|
|
955
|
+
- Use spacer with variant "line" to separate sections
|
|
956
|
+
- You can include normal text before/after the @interface block
|
|
957
|
+
- For updates use: @update[{"op": "update", "target": "widget-id", "props": {"key": "new-value"}}]`;
|
|
958
|
+
}
|
|
959
|
+
function generateCompactInterfaceContext() {
|
|
960
|
+
return `Generate a UI interface as JSON wrapped in @interface[{...}].
|
|
961
|
+
|
|
962
|
+
STRICT FORMAT \u2014 every node needs "type", "id", and "props" (object):
|
|
963
|
+
- Layout: {"type":"layout","id":"x","layout":"page|row|stack|tabs","props":{...},"children":[...]}
|
|
964
|
+
- Widget: {"type":"kpi|text_block|form|table|chart|list|card|spacer|button_group|image","id":"x","props":{...}}
|
|
965
|
+
|
|
966
|
+
NEVER use type:"widget". The type IS the widget name. All widget properties go INSIDE "props".
|
|
967
|
+
|
|
968
|
+
Widget props:
|
|
969
|
+
- kpi: {label,value,change?,trend?}
|
|
970
|
+
- text_block: {content,variant?:"heading"|"body"|"caption"}
|
|
971
|
+
- form: {fields:[{name,type,label,required?,placeholder?}]}
|
|
972
|
+
- table: {columns:[{key,label}],rows:[{...}]}
|
|
973
|
+
- chart: {chartType:"line"|"bar"|"pie",data:{labels,datasets:[{label,data}]}}
|
|
974
|
+
- list: {items:[{id,title,subtitle?}]}
|
|
975
|
+
- button_group: {buttons:[{id,label}]}
|
|
976
|
+
|
|
977
|
+
Row props: {columns:[1,2]} means 1/3+2/3. Page props: {title:"..."}.
|
|
978
|
+
|
|
979
|
+
Example: @interface[{"version":1,"root":{"type":"layout","id":"root","layout":"page","props":{"title":"Form"},"children":[{"type":"form","id":"f1","props":{"fields":[{"name":"name","type":"text","label":"Name"}]}}]}}]`;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// src/utils/interface-operations.ts
|
|
983
|
+
function findNode(root, id) {
|
|
984
|
+
if (root.id === id) return root;
|
|
985
|
+
if (root.children) {
|
|
986
|
+
for (const child of root.children) {
|
|
987
|
+
const found = findNode(child, id);
|
|
988
|
+
if (found) return found;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
return null;
|
|
992
|
+
}
|
|
993
|
+
function replaceNode(root, targetId, newNode) {
|
|
994
|
+
if (root.id === targetId) return newNode;
|
|
995
|
+
if (!root.children) return root;
|
|
996
|
+
const newChildren = root.children.map((child) => replaceNode(child, targetId, newNode));
|
|
997
|
+
if (newChildren.every((child, i) => child === root.children[i])) return root;
|
|
998
|
+
return { ...root, children: newChildren };
|
|
999
|
+
}
|
|
1000
|
+
function updateNodeProps(root, targetId, props) {
|
|
1001
|
+
if (root.id === targetId) {
|
|
1002
|
+
return { ...root, props: { ...root.props, ...props } };
|
|
1003
|
+
}
|
|
1004
|
+
if (!root.children) return root;
|
|
1005
|
+
const newChildren = root.children.map((child) => updateNodeProps(child, targetId, props));
|
|
1006
|
+
if (newChildren.every((child, i) => child === root.children[i])) return root;
|
|
1007
|
+
return { ...root, children: newChildren };
|
|
1008
|
+
}
|
|
1009
|
+
function removeNode(root, targetId) {
|
|
1010
|
+
if (root.id === targetId) return null;
|
|
1011
|
+
if (!root.children) return root;
|
|
1012
|
+
const newChildren = root.children.map((child) => removeNode(child, targetId)).filter((child) => child !== null);
|
|
1013
|
+
if (newChildren.length === root.children.length && newChildren.every((child, i) => child === root.children[i])) return root;
|
|
1014
|
+
return { ...root, children: newChildren };
|
|
1015
|
+
}
|
|
1016
|
+
function appendNode(root, targetId, newNode) {
|
|
1017
|
+
if (root.id === targetId) {
|
|
1018
|
+
return { ...root, children: [...root.children || [], newNode] };
|
|
1019
|
+
}
|
|
1020
|
+
if (!root.children) return root;
|
|
1021
|
+
const newChildren = root.children.map((child) => appendNode(child, targetId, newNode));
|
|
1022
|
+
if (newChildren.every((child, i) => child === root.children[i])) return root;
|
|
1023
|
+
return { ...root, children: newChildren };
|
|
1024
|
+
}
|
|
1025
|
+
function prependNode(root, targetId, newNode) {
|
|
1026
|
+
if (root.id === targetId) {
|
|
1027
|
+
return { ...root, children: [newNode, ...root.children || []] };
|
|
1028
|
+
}
|
|
1029
|
+
if (!root.children) return root;
|
|
1030
|
+
const newChildren = root.children.map((child) => prependNode(child, targetId, newNode));
|
|
1031
|
+
if (newChildren.every((child, i) => child === root.children[i])) return root;
|
|
1032
|
+
return { ...root, children: newChildren };
|
|
1033
|
+
}
|
|
1034
|
+
function applyUpdate(spec, update) {
|
|
1035
|
+
let newRoot = spec.root;
|
|
1036
|
+
switch (update.op) {
|
|
1037
|
+
case "replace":
|
|
1038
|
+
if (!update.node) return spec;
|
|
1039
|
+
newRoot = replaceNode(spec.root, update.target, update.node);
|
|
1040
|
+
break;
|
|
1041
|
+
case "update":
|
|
1042
|
+
if (!update.props) return spec;
|
|
1043
|
+
newRoot = updateNodeProps(spec.root, update.target, update.props);
|
|
1044
|
+
break;
|
|
1045
|
+
case "remove":
|
|
1046
|
+
newRoot = removeNode(spec.root, update.target);
|
|
1047
|
+
if (!newRoot) return spec;
|
|
1048
|
+
break;
|
|
1049
|
+
case "append":
|
|
1050
|
+
if (!update.node) return spec;
|
|
1051
|
+
newRoot = appendNode(spec.root, update.target, update.node);
|
|
1052
|
+
break;
|
|
1053
|
+
case "prepend":
|
|
1054
|
+
if (!update.node) return spec;
|
|
1055
|
+
newRoot = prependNode(spec.root, update.target, update.node);
|
|
1056
|
+
break;
|
|
1057
|
+
default:
|
|
1058
|
+
return spec;
|
|
1059
|
+
}
|
|
1060
|
+
if (newRoot === spec.root) return spec;
|
|
1061
|
+
return { ...spec, root: newRoot };
|
|
1062
|
+
}
|
|
1063
|
+
function applyUpdates(spec, updates) {
|
|
1064
|
+
return updates.reduce((s, update) => applyUpdate(s, update), spec);
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
// src/utils/message-converter.ts
|
|
1068
|
+
function convertApiMessages(apiMessages) {
|
|
1069
|
+
const result = [];
|
|
1070
|
+
let lastAssistantSegments = null;
|
|
1071
|
+
for (let i = 0; i < apiMessages.length; i++) {
|
|
1072
|
+
const msg = apiMessages[i];
|
|
1073
|
+
const timestamp = msg.created_at || msg.timestamp ? new Date(msg.created_at || msg.timestamp) : /* @__PURE__ */ new Date();
|
|
1074
|
+
if (typeof msg.content === "string") {
|
|
1075
|
+
const message = {
|
|
1076
|
+
id: msg.id || `thread-msg-${i}`,
|
|
1077
|
+
role: msg.role,
|
|
1078
|
+
content: msg.content,
|
|
1079
|
+
timestamp
|
|
1080
|
+
};
|
|
1081
|
+
result.push(message);
|
|
1082
|
+
lastAssistantSegments = null;
|
|
1083
|
+
} else if (Array.isArray(msg.content)) {
|
|
1084
|
+
if (msg.role === "assistant") {
|
|
1085
|
+
const segments = [];
|
|
1086
|
+
let textContent = "";
|
|
1087
|
+
for (const block of msg.content) {
|
|
1088
|
+
if (block.type === "text" && block.text) {
|
|
1089
|
+
segments.push({ type: "text", content: block.text });
|
|
1090
|
+
textContent += block.text;
|
|
1091
|
+
} else if (block.type === "tool_use") {
|
|
1092
|
+
segments.push({
|
|
1093
|
+
type: "tool",
|
|
1094
|
+
id: block.id || `tool-${i}-${segments.length}`,
|
|
1095
|
+
name: block.name || "unknown",
|
|
1096
|
+
status: "completed"
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
const message = {
|
|
1101
|
+
id: msg.id || `thread-msg-${i}`,
|
|
1102
|
+
role: "assistant",
|
|
1103
|
+
content: textContent,
|
|
1104
|
+
timestamp,
|
|
1105
|
+
metadata: segments.length > 0 ? { content_segments: segments } : void 0
|
|
1106
|
+
};
|
|
1107
|
+
result.push(message);
|
|
1108
|
+
lastAssistantSegments = segments;
|
|
1109
|
+
} else if (msg.role === "user") {
|
|
1110
|
+
const hasToolResults = msg.content.some((b) => b.type === "tool_result");
|
|
1111
|
+
if (hasToolResults && lastAssistantSegments) {
|
|
1112
|
+
for (const block of msg.content) {
|
|
1113
|
+
if (block.type === "tool_result" && block.tool_use_id) {
|
|
1114
|
+
const toolSegment = lastAssistantSegments.find(
|
|
1115
|
+
(s) => s.type === "tool" && s.id === block.tool_use_id
|
|
1116
|
+
);
|
|
1117
|
+
if (toolSegment && toolSegment.type === "tool") {
|
|
1118
|
+
toolSegment.result = typeof block.content === "string" ? block.content : Array.isArray(block.content) ? block.content.map((c) => c.text || "").join("") : void 0;
|
|
1119
|
+
toolSegment.status = block.is_error ? "error" : "completed";
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
} else {
|
|
1124
|
+
const textContent = msg.content.filter((b) => b.type === "text").map((b) => b.text || "").join("");
|
|
1125
|
+
if (textContent) {
|
|
1126
|
+
result.push({
|
|
1127
|
+
id: msg.id || `thread-msg-${i}`,
|
|
1128
|
+
role: "user",
|
|
1129
|
+
content: textContent,
|
|
1130
|
+
timestamp
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
lastAssistantSegments = null;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
return result;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
800
1141
|
// src/components/Widgets/Widgets.tsx
|
|
801
1142
|
import { useEffect as useEffect3 } from "react";
|
|
802
1143
|
|
|
@@ -1436,42 +1777,183 @@ function Flow({ widget }) {
|
|
|
1436
1777
|
] });
|
|
1437
1778
|
}
|
|
1438
1779
|
|
|
1439
|
-
// src/components/Widgets/
|
|
1780
|
+
// src/components/Widgets/widget-library/Kpi.tsx
|
|
1440
1781
|
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1782
|
+
var trendIcons = {
|
|
1783
|
+
up: { symbol: "\u2191", color: "text-emerald-500" },
|
|
1784
|
+
down: { symbol: "\u2193", color: "text-red-500" },
|
|
1785
|
+
flat: { symbol: "\u2192", color: "text-neutral-400" }
|
|
1786
|
+
};
|
|
1787
|
+
function Kpi({ widget, onAction }) {
|
|
1788
|
+
const { label = "", value = "", change, trend } = widget.props || {};
|
|
1789
|
+
const trendInfo = trend ? trendIcons[trend] : null;
|
|
1790
|
+
return /* @__PURE__ */ jsxs7("div", { className: "border border-neutral-200 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 p-5", children: [
|
|
1791
|
+
/* @__PURE__ */ jsx9("div", { className: "!text-sm font-medium !text-neutral-500 dark:!text-neutral-400 mb-1", children: label }),
|
|
1792
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-end gap-2", children: [
|
|
1793
|
+
/* @__PURE__ */ jsx9("div", { className: "!text-2xl font-bold !text-neutral-900 dark:!text-white", children: value }),
|
|
1794
|
+
change && trendInfo && /* @__PURE__ */ jsxs7("div", { className: `flex items-center gap-0.5 !text-sm font-medium ${trendInfo.color} mb-0.5`, children: [
|
|
1795
|
+
/* @__PURE__ */ jsx9("span", { children: trendInfo.symbol }),
|
|
1796
|
+
/* @__PURE__ */ jsx9("span", { children: change })
|
|
1797
|
+
] }),
|
|
1798
|
+
change && !trendInfo && /* @__PURE__ */ jsx9("div", { className: "!text-sm font-medium !text-neutral-400 mb-0.5", children: change })
|
|
1799
|
+
] }),
|
|
1800
|
+
widget.actions && widget.actions.length > 0 && /* @__PURE__ */ jsx9("div", { className: "flex gap-2 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700", children: widget.actions.map((action, idx) => /* @__PURE__ */ jsx9(
|
|
1801
|
+
"button",
|
|
1802
|
+
{
|
|
1803
|
+
onClick: () => onAction?.({
|
|
1804
|
+
type: action.type,
|
|
1805
|
+
payload: action.payload,
|
|
1806
|
+
widgetId: widget.id,
|
|
1807
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1808
|
+
}),
|
|
1809
|
+
className: "px-2 py-1 !text-xs rounded font-medium transition-colors bg-neutral-100 dark:bg-neutral-800 !text-neutral-600 dark:!text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700",
|
|
1810
|
+
children: action.label
|
|
1811
|
+
},
|
|
1812
|
+
idx
|
|
1813
|
+
)) })
|
|
1814
|
+
] });
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
// src/components/Widgets/widget-library/TextBlock.tsx
|
|
1818
|
+
import { Fragment, jsx as jsx10 } from "react/jsx-runtime";
|
|
1819
|
+
function TextBlock({ widget }) {
|
|
1820
|
+
const { content = "", variant = "body" } = widget.props || {};
|
|
1821
|
+
const variantClasses = {
|
|
1822
|
+
heading: "!text-xl font-bold !text-neutral-900 dark:!text-white",
|
|
1823
|
+
body: "!text-sm !text-neutral-700 dark:!text-neutral-300 leading-relaxed",
|
|
1824
|
+
caption: "!text-xs !text-neutral-500 dark:!text-neutral-400"
|
|
1825
|
+
};
|
|
1826
|
+
const renderMarkdown = (text) => {
|
|
1827
|
+
const lines = text.split("\n");
|
|
1828
|
+
const elements = [];
|
|
1829
|
+
let i = 0;
|
|
1830
|
+
while (i < lines.length) {
|
|
1831
|
+
const line = lines[i];
|
|
1832
|
+
if (line.startsWith("### ")) {
|
|
1833
|
+
elements.push(
|
|
1834
|
+
/* @__PURE__ */ jsx10("h3", { className: "!text-base font-semibold !text-neutral-900 dark:!text-white mt-3 mb-1", children: renderInline(line.slice(4)) }, i)
|
|
1835
|
+
);
|
|
1836
|
+
} else if (line.startsWith("## ")) {
|
|
1837
|
+
elements.push(
|
|
1838
|
+
/* @__PURE__ */ jsx10("h2", { className: "!text-lg font-bold !text-neutral-900 dark:!text-white mt-4 mb-1", children: renderInline(line.slice(3)) }, i)
|
|
1839
|
+
);
|
|
1840
|
+
} else if (/^[-*+]\s/.test(line)) {
|
|
1841
|
+
const listItems = [];
|
|
1842
|
+
while (i < lines.length && /^[-*+]\s/.test(lines[i])) {
|
|
1843
|
+
listItems.push(
|
|
1844
|
+
/* @__PURE__ */ jsx10("li", { className: "ml-4 list-disc", children: renderInline(lines[i].slice(2)) }, i)
|
|
1845
|
+
);
|
|
1846
|
+
i++;
|
|
1847
|
+
}
|
|
1848
|
+
elements.push(/* @__PURE__ */ jsx10("ul", { className: "my-1 space-y-0.5", children: listItems }, `list-${i}`));
|
|
1849
|
+
continue;
|
|
1850
|
+
} else if (line.trim() === "") {
|
|
1851
|
+
elements.push(/* @__PURE__ */ jsx10("div", { className: "h-2" }, i));
|
|
1852
|
+
} else {
|
|
1853
|
+
elements.push(/* @__PURE__ */ jsx10("p", { className: "my-0.5", children: renderInline(line) }, i));
|
|
1854
|
+
}
|
|
1855
|
+
i++;
|
|
1856
|
+
}
|
|
1857
|
+
return elements;
|
|
1858
|
+
};
|
|
1859
|
+
const renderInline = (text) => {
|
|
1860
|
+
const parts = [];
|
|
1861
|
+
let remaining = text;
|
|
1862
|
+
let key = 0;
|
|
1863
|
+
while (remaining.length > 0) {
|
|
1864
|
+
const boldMatch = remaining.match(/\*\*(.+?)\*\*/);
|
|
1865
|
+
const codeMatch = remaining.match(/`(.+?)`/);
|
|
1866
|
+
const linkMatch = remaining.match(/\[(.+?)\]\((.+?)\)/);
|
|
1867
|
+
const matches = [
|
|
1868
|
+
boldMatch ? { type: "bold", index: boldMatch.index, match: boldMatch } : null,
|
|
1869
|
+
codeMatch ? { type: "code", index: codeMatch.index, match: codeMatch } : null,
|
|
1870
|
+
linkMatch ? { type: "link", index: linkMatch.index, match: linkMatch } : null
|
|
1871
|
+
].filter(Boolean).sort((a, b) => a.index - b.index);
|
|
1872
|
+
if (matches.length === 0) {
|
|
1873
|
+
parts.push(remaining);
|
|
1874
|
+
break;
|
|
1875
|
+
}
|
|
1876
|
+
const first = matches[0];
|
|
1877
|
+
if (first.index > 0) {
|
|
1878
|
+
parts.push(remaining.slice(0, first.index));
|
|
1879
|
+
}
|
|
1880
|
+
if (first.type === "bold") {
|
|
1881
|
+
parts.push(/* @__PURE__ */ jsx10("strong", { className: "font-semibold", children: first.match[1] }, key++));
|
|
1882
|
+
remaining = remaining.slice(first.index + first.match[0].length);
|
|
1883
|
+
} else if (first.type === "code") {
|
|
1884
|
+
parts.push(
|
|
1885
|
+
/* @__PURE__ */ jsx10("code", { className: "px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded text-xs font-mono", children: first.match[1] }, key++)
|
|
1886
|
+
);
|
|
1887
|
+
remaining = remaining.slice(first.index + first.match[0].length);
|
|
1888
|
+
} else if (first.type === "link") {
|
|
1889
|
+
parts.push(
|
|
1890
|
+
/* @__PURE__ */ jsx10("a", { href: first.match[2], className: "text-blue-500 hover:underline", target: "_blank", rel: "noopener noreferrer", children: first.match[1] }, key++)
|
|
1891
|
+
);
|
|
1892
|
+
remaining = remaining.slice(first.index + first.match[0].length);
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
return parts.length === 1 ? parts[0] : /* @__PURE__ */ jsx10(Fragment, { children: parts });
|
|
1896
|
+
};
|
|
1897
|
+
return /* @__PURE__ */ jsx10("div", { className: variantClasses[variant] || variantClasses.body, children: renderMarkdown(content) });
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
// src/components/Widgets/widget-library/Spacer.tsx
|
|
1901
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1902
|
+
var heightClasses = {
|
|
1903
|
+
sm: "h-2",
|
|
1904
|
+
md: "h-4",
|
|
1905
|
+
lg: "h-8"
|
|
1906
|
+
};
|
|
1907
|
+
function Spacer({ widget }) {
|
|
1908
|
+
const { height = "md", variant = "space" } = widget.props || {};
|
|
1909
|
+
if (variant === "line") {
|
|
1910
|
+
return /* @__PURE__ */ jsx11("div", { className: heightClasses[height] || heightClasses.md + " flex items-center", children: /* @__PURE__ */ jsx11("hr", { className: "w-full border-neutral-200 dark:border-neutral-700" }) });
|
|
1911
|
+
}
|
|
1912
|
+
return /* @__PURE__ */ jsx11("div", { className: heightClasses[height] || heightClasses.md });
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
// src/components/Widgets/WidgetRenderer.tsx
|
|
1916
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1441
1917
|
function WidgetRenderer({ widget, onAction }) {
|
|
1442
1918
|
const renderWidget = () => {
|
|
1443
1919
|
switch (widget.type) {
|
|
1444
1920
|
case "card":
|
|
1445
|
-
return /* @__PURE__ */
|
|
1921
|
+
return /* @__PURE__ */ jsx12(Card, { widget, onAction });
|
|
1446
1922
|
case "list":
|
|
1447
|
-
return /* @__PURE__ */
|
|
1923
|
+
return /* @__PURE__ */ jsx12(List, { widget, onAction });
|
|
1448
1924
|
case "button":
|
|
1449
|
-
return /* @__PURE__ */
|
|
1925
|
+
return /* @__PURE__ */ jsx12(Button, { widget, onAction });
|
|
1450
1926
|
case "button_group":
|
|
1451
|
-
return /* @__PURE__ */
|
|
1927
|
+
return /* @__PURE__ */ jsx12(ButtonGroup, { widget, onAction });
|
|
1452
1928
|
case "table":
|
|
1453
|
-
return /* @__PURE__ */
|
|
1929
|
+
return /* @__PURE__ */ jsx12(Table, { widget, onAction });
|
|
1454
1930
|
case "form":
|
|
1455
|
-
return /* @__PURE__ */
|
|
1931
|
+
return /* @__PURE__ */ jsx12(Form, { widget, onAction });
|
|
1456
1932
|
case "image":
|
|
1457
|
-
return /* @__PURE__ */
|
|
1933
|
+
return /* @__PURE__ */ jsx12(Image, { widget });
|
|
1458
1934
|
case "flow":
|
|
1459
|
-
return /* @__PURE__ */
|
|
1935
|
+
return /* @__PURE__ */ jsx12(Flow, { widget });
|
|
1936
|
+
case "kpi":
|
|
1937
|
+
return /* @__PURE__ */ jsx12(Kpi, { widget, onAction });
|
|
1938
|
+
case "text_block":
|
|
1939
|
+
return /* @__PURE__ */ jsx12(TextBlock, { widget });
|
|
1940
|
+
case "spacer":
|
|
1941
|
+
return /* @__PURE__ */ jsx12(Spacer, { widget });
|
|
1460
1942
|
default:
|
|
1461
|
-
return /* @__PURE__ */
|
|
1462
|
-
/* @__PURE__ */
|
|
1943
|
+
return /* @__PURE__ */ jsxs8("div", { className: "p-4 border border-yellow-300 bg-yellow-50 rounded-lg", children: [
|
|
1944
|
+
/* @__PURE__ */ jsxs8("p", { className: "text-sm text-yellow-800", children: [
|
|
1463
1945
|
"Unknown widget type: ",
|
|
1464
1946
|
widget.type
|
|
1465
1947
|
] }),
|
|
1466
|
-
/* @__PURE__ */
|
|
1948
|
+
/* @__PURE__ */ jsx12("pre", { className: "text-xs mt-2 overflow-auto", children: JSON.stringify(widget, null, 2) })
|
|
1467
1949
|
] });
|
|
1468
1950
|
}
|
|
1469
1951
|
};
|
|
1470
|
-
return /* @__PURE__ */
|
|
1952
|
+
return /* @__PURE__ */ jsx12("div", { className: "apteva-widget", children: renderWidget() });
|
|
1471
1953
|
}
|
|
1472
1954
|
|
|
1473
1955
|
// src/components/Widgets/Widgets.tsx
|
|
1474
|
-
import { jsx as
|
|
1956
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1475
1957
|
function Widgets({
|
|
1476
1958
|
widgets,
|
|
1477
1959
|
onAction,
|
|
@@ -1496,85 +1978,85 @@ function Widgets({
|
|
|
1496
1978
|
normal: "gap-4",
|
|
1497
1979
|
loose: "gap-6"
|
|
1498
1980
|
};
|
|
1499
|
-
return /* @__PURE__ */
|
|
1981
|
+
return /* @__PURE__ */ jsx13("div", { className: cn(layoutClasses[layout], spacingClasses[spacing], className), children: widgets.map((widget) => /* @__PURE__ */ jsx13(WidgetRenderer, { widget, onAction }, widget.id)) });
|
|
1500
1982
|
}
|
|
1501
1983
|
|
|
1502
1984
|
// src/components/Widgets/WidgetSkeleton.tsx
|
|
1503
|
-
import { jsx as
|
|
1985
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1504
1986
|
function WidgetSkeleton({ type, className }) {
|
|
1505
1987
|
switch (type) {
|
|
1506
1988
|
case "card":
|
|
1507
|
-
return /* @__PURE__ */
|
|
1508
|
-
/* @__PURE__ */
|
|
1509
|
-
/* @__PURE__ */
|
|
1510
|
-
/* @__PURE__ */
|
|
1989
|
+
return /* @__PURE__ */ jsx14("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden", className), children: /* @__PURE__ */ jsxs9("div", { className: "p-4 space-y-3", children: [
|
|
1990
|
+
/* @__PURE__ */ jsx14("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-3/4" }),
|
|
1991
|
+
/* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-full" }),
|
|
1992
|
+
/* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-5/6" })
|
|
1511
1993
|
] }) });
|
|
1512
1994
|
case "list":
|
|
1513
|
-
return /* @__PURE__ */
|
|
1514
|
-
/* @__PURE__ */
|
|
1515
|
-
/* @__PURE__ */
|
|
1516
|
-
/* @__PURE__ */
|
|
1517
|
-
/* @__PURE__ */
|
|
1995
|
+
return /* @__PURE__ */ jsx14("div", { className: cn("apteva-widget-skeleton animate-pulse space-y-2", className), children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-3 p-3 rounded-lg border border-neutral-200 dark:border-neutral-800", children: [
|
|
1996
|
+
/* @__PURE__ */ jsx14("div", { className: "w-10 h-10 bg-neutral-200 dark:bg-neutral-700 rounded-full flex-shrink-0" }),
|
|
1997
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex-1 space-y-2", children: [
|
|
1998
|
+
/* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2" }),
|
|
1999
|
+
/* @__PURE__ */ jsx14("div", { className: "h-2 bg-neutral-200 dark:bg-neutral-700 rounded w-3/4" })
|
|
1518
2000
|
] })
|
|
1519
2001
|
] }, i)) });
|
|
1520
2002
|
case "button_group":
|
|
1521
|
-
return /* @__PURE__ */
|
|
1522
|
-
/* @__PURE__ */
|
|
1523
|
-
/* @__PURE__ */
|
|
1524
|
-
/* @__PURE__ */
|
|
2003
|
+
return /* @__PURE__ */ jsxs9("div", { className: cn("apteva-widget-skeleton animate-pulse flex gap-2", className), children: [
|
|
2004
|
+
/* @__PURE__ */ jsx14("div", { className: "h-9 bg-neutral-200 dark:bg-neutral-700 rounded-lg w-20" }),
|
|
2005
|
+
/* @__PURE__ */ jsx14("div", { className: "h-9 bg-neutral-200 dark:bg-neutral-700 rounded-lg w-20" }),
|
|
2006
|
+
/* @__PURE__ */ jsx14("div", { className: "h-9 bg-neutral-200 dark:bg-neutral-700 rounded-lg w-20" })
|
|
1525
2007
|
] });
|
|
1526
2008
|
case "form":
|
|
1527
|
-
return /* @__PURE__ */
|
|
1528
|
-
/* @__PURE__ */
|
|
1529
|
-
/* @__PURE__ */
|
|
1530
|
-
/* @__PURE__ */
|
|
1531
|
-
/* @__PURE__ */
|
|
2009
|
+
return /* @__PURE__ */ jsxs9("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 p-4 space-y-4", className), children: [
|
|
2010
|
+
/* @__PURE__ */ jsx14("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/3" }),
|
|
2011
|
+
/* @__PURE__ */ jsxs9("div", { className: "space-y-3", children: [
|
|
2012
|
+
/* @__PURE__ */ jsx14("div", { className: "h-10 bg-neutral-200 dark:bg-neutral-700 rounded" }),
|
|
2013
|
+
/* @__PURE__ */ jsx14("div", { className: "h-10 bg-neutral-200 dark:bg-neutral-700 rounded" })
|
|
1532
2014
|
] }),
|
|
1533
|
-
/* @__PURE__ */
|
|
2015
|
+
/* @__PURE__ */ jsx14("div", { className: "h-9 bg-neutral-200 dark:bg-neutral-700 rounded w-24" })
|
|
1534
2016
|
] });
|
|
1535
2017
|
case "chart":
|
|
1536
|
-
return /* @__PURE__ */
|
|
1537
|
-
/* @__PURE__ */
|
|
1538
|
-
/* @__PURE__ */
|
|
1539
|
-
/* @__PURE__ */
|
|
1540
|
-
/* @__PURE__ */
|
|
1541
|
-
/* @__PURE__ */
|
|
1542
|
-
/* @__PURE__ */
|
|
1543
|
-
/* @__PURE__ */
|
|
2018
|
+
return /* @__PURE__ */ jsxs9("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 p-4", className), children: [
|
|
2019
|
+
/* @__PURE__ */ jsx14("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/4 mb-4" }),
|
|
2020
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-end gap-2 h-32", children: [
|
|
2021
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-1/2" }),
|
|
2022
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-3/4" }),
|
|
2023
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-1/3" }),
|
|
2024
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-full" }),
|
|
2025
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-2/3" })
|
|
1544
2026
|
] })
|
|
1545
2027
|
] });
|
|
1546
2028
|
case "image":
|
|
1547
|
-
return /* @__PURE__ */
|
|
2029
|
+
return /* @__PURE__ */ jsx14("div", { className: cn("apteva-widget-skeleton animate-pulse", className), children: /* @__PURE__ */ jsx14("div", { className: "aspect-video bg-neutral-200 dark:bg-neutral-700 rounded-lg" }) });
|
|
1548
2030
|
case "gallery":
|
|
1549
|
-
return /* @__PURE__ */
|
|
2031
|
+
return /* @__PURE__ */ jsx14("div", { className: cn("apteva-widget-skeleton animate-pulse grid grid-cols-3 gap-2", className), children: [1, 2, 3].map((i) => /* @__PURE__ */ jsx14("div", { className: "aspect-square bg-neutral-200 dark:bg-neutral-700 rounded-lg" }, i)) });
|
|
1550
2032
|
case "map":
|
|
1551
|
-
return /* @__PURE__ */
|
|
1552
|
-
/* @__PURE__ */
|
|
1553
|
-
/* @__PURE__ */
|
|
2033
|
+
return /* @__PURE__ */ jsx14("div", { className: cn("apteva-widget-skeleton animate-pulse", className), children: /* @__PURE__ */ jsx14("div", { className: "h-48 bg-neutral-200 dark:bg-neutral-700 rounded-lg flex items-center justify-center", children: /* @__PURE__ */ jsxs9("svg", { className: "w-8 h-8 text-neutral-400 dark:text-neutral-500", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: [
|
|
2034
|
+
/* @__PURE__ */ jsx14("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" }),
|
|
2035
|
+
/* @__PURE__ */ jsx14("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z" })
|
|
1554
2036
|
] }) }) });
|
|
1555
2037
|
case "table":
|
|
1556
|
-
return /* @__PURE__ */
|
|
1557
|
-
/* @__PURE__ */
|
|
1558
|
-
/* @__PURE__ */
|
|
1559
|
-
/* @__PURE__ */
|
|
1560
|
-
/* @__PURE__ */
|
|
2038
|
+
return /* @__PURE__ */ jsxs9("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden", className), children: [
|
|
2039
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex bg-neutral-100 dark:bg-neutral-800 border-b border-neutral-200 dark:border-neutral-700", children: [
|
|
2040
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-300 dark:bg-neutral-600 rounded w-16" }) }),
|
|
2041
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-300 dark:bg-neutral-600 rounded w-20" }) }),
|
|
2042
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-300 dark:bg-neutral-600 rounded w-14" }) })
|
|
1561
2043
|
] }),
|
|
1562
|
-
[1, 2, 3].map((i) => /* @__PURE__ */
|
|
1563
|
-
/* @__PURE__ */
|
|
1564
|
-
/* @__PURE__ */
|
|
1565
|
-
/* @__PURE__ */
|
|
2044
|
+
[1, 2, 3].map((i) => /* @__PURE__ */ jsxs9("div", { className: "flex border-b border-neutral-200 dark:border-neutral-800 last:border-b-0", children: [
|
|
2045
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-24" }) }),
|
|
2046
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-16" }) }),
|
|
2047
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-1 px-4 py-3", children: /* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-20" }) })
|
|
1566
2048
|
] }, i))
|
|
1567
2049
|
] });
|
|
1568
2050
|
default:
|
|
1569
|
-
return /* @__PURE__ */
|
|
1570
|
-
/* @__PURE__ */
|
|
1571
|
-
/* @__PURE__ */
|
|
2051
|
+
return /* @__PURE__ */ jsxs9("div", { className: cn("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 p-4", className), children: [
|
|
2052
|
+
/* @__PURE__ */ jsx14("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2 mb-2" }),
|
|
2053
|
+
/* @__PURE__ */ jsx14("div", { className: "h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-full" })
|
|
1572
2054
|
] });
|
|
1573
2055
|
}
|
|
1574
2056
|
}
|
|
1575
2057
|
|
|
1576
2058
|
// src/components/Chat/MarkdownContent.tsx
|
|
1577
|
-
import { jsx as
|
|
2059
|
+
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1578
2060
|
function isImageUrl(url) {
|
|
1579
2061
|
const imageExtensions = /\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)(\?.*)?$/i;
|
|
1580
2062
|
return imageExtensions.test(url);
|
|
@@ -1593,7 +2075,7 @@ function parseInlineMarkdown(text, keyPrefix = "") {
|
|
|
1593
2075
|
const alt = match[1] || "";
|
|
1594
2076
|
const src = match[2];
|
|
1595
2077
|
result.push(
|
|
1596
|
-
/* @__PURE__ */
|
|
2078
|
+
/* @__PURE__ */ jsx15(
|
|
1597
2079
|
"img",
|
|
1598
2080
|
{
|
|
1599
2081
|
src,
|
|
@@ -1608,7 +2090,7 @@ function parseInlineMarkdown(text, keyPrefix = "") {
|
|
|
1608
2090
|
const href = match[4];
|
|
1609
2091
|
if (isImageUrl(href)) {
|
|
1610
2092
|
result.push(
|
|
1611
|
-
/* @__PURE__ */
|
|
2093
|
+
/* @__PURE__ */ jsx15(
|
|
1612
2094
|
"img",
|
|
1613
2095
|
{
|
|
1614
2096
|
src: href,
|
|
@@ -1620,7 +2102,7 @@ function parseInlineMarkdown(text, keyPrefix = "") {
|
|
|
1620
2102
|
);
|
|
1621
2103
|
} else {
|
|
1622
2104
|
result.push(
|
|
1623
|
-
/* @__PURE__ */
|
|
2105
|
+
/* @__PURE__ */ jsx15(
|
|
1624
2106
|
"a",
|
|
1625
2107
|
{
|
|
1626
2108
|
href,
|
|
@@ -1634,10 +2116,10 @@ function parseInlineMarkdown(text, keyPrefix = "") {
|
|
|
1634
2116
|
);
|
|
1635
2117
|
}
|
|
1636
2118
|
} else if (match[5] !== void 0) {
|
|
1637
|
-
result.push(/* @__PURE__ */
|
|
2119
|
+
result.push(/* @__PURE__ */ jsx15("strong", { children: match[6] }, `${keyPrefix}b${key++}`));
|
|
1638
2120
|
} else if (match[7] !== void 0) {
|
|
1639
2121
|
result.push(
|
|
1640
|
-
/* @__PURE__ */
|
|
2122
|
+
/* @__PURE__ */ jsx15("code", { className: "apteva-md-inline-code", children: match[7] }, `${keyPrefix}code${key++}`)
|
|
1641
2123
|
);
|
|
1642
2124
|
}
|
|
1643
2125
|
lastIndex = match.index + match[0].length;
|
|
@@ -1657,7 +2139,7 @@ function parseMarkdown(content) {
|
|
|
1657
2139
|
const h2Match = line.match(/^##\s+(.*)$/);
|
|
1658
2140
|
if (h2Match) {
|
|
1659
2141
|
result.push(
|
|
1660
|
-
/* @__PURE__ */
|
|
2142
|
+
/* @__PURE__ */ jsx15("h2", { className: "apteva-md-h2", children: parseInlineMarkdown(h2Match[1], `${key}`) }, `h2${key++}`)
|
|
1661
2143
|
);
|
|
1662
2144
|
i++;
|
|
1663
2145
|
continue;
|
|
@@ -1665,7 +2147,7 @@ function parseMarkdown(content) {
|
|
|
1665
2147
|
const h3Match = line.match(/^###\s+(.*)$/);
|
|
1666
2148
|
if (h3Match) {
|
|
1667
2149
|
result.push(
|
|
1668
|
-
/* @__PURE__ */
|
|
2150
|
+
/* @__PURE__ */ jsx15("h3", { className: "apteva-md-h3", children: parseInlineMarkdown(h3Match[1], `${key}`) }, `h3${key++}`)
|
|
1669
2151
|
);
|
|
1670
2152
|
i++;
|
|
1671
2153
|
continue;
|
|
@@ -1678,7 +2160,7 @@ function parseMarkdown(content) {
|
|
|
1678
2160
|
const itemMatch = lines[i].match(/^(\s*)([-*+])\s+(.*)$/);
|
|
1679
2161
|
if (itemMatch && itemMatch[1].length === indent) {
|
|
1680
2162
|
listItems.push(
|
|
1681
|
-
/* @__PURE__ */
|
|
2163
|
+
/* @__PURE__ */ jsx15("li", { className: "apteva-md-li", children: parseInlineMarkdown(itemMatch[3], `${key}`) }, `li${key++}`)
|
|
1682
2164
|
);
|
|
1683
2165
|
i++;
|
|
1684
2166
|
} else {
|
|
@@ -1686,7 +2168,7 @@ function parseMarkdown(content) {
|
|
|
1686
2168
|
}
|
|
1687
2169
|
}
|
|
1688
2170
|
result.push(
|
|
1689
|
-
/* @__PURE__ */
|
|
2171
|
+
/* @__PURE__ */ jsx15("ul", { className: "apteva-md-ul", children: listItems }, `ul${key++}`)
|
|
1690
2172
|
);
|
|
1691
2173
|
continue;
|
|
1692
2174
|
}
|
|
@@ -1698,7 +2180,7 @@ function parseMarkdown(content) {
|
|
|
1698
2180
|
const itemMatch = lines[i].match(/^(\s*)(\d+)\.\s+(.*)$/);
|
|
1699
2181
|
if (itemMatch && itemMatch[1].length === indent) {
|
|
1700
2182
|
listItems.push(
|
|
1701
|
-
/* @__PURE__ */
|
|
2183
|
+
/* @__PURE__ */ jsx15("li", { className: "apteva-md-li", children: parseInlineMarkdown(itemMatch[3], `${key}`) }, `li${key++}`)
|
|
1702
2184
|
);
|
|
1703
2185
|
i++;
|
|
1704
2186
|
} else {
|
|
@@ -1706,7 +2188,7 @@ function parseMarkdown(content) {
|
|
|
1706
2188
|
}
|
|
1707
2189
|
}
|
|
1708
2190
|
result.push(
|
|
1709
|
-
/* @__PURE__ */
|
|
2191
|
+
/* @__PURE__ */ jsx15("ol", { className: "apteva-md-ol", children: listItems }, `ol${key++}`)
|
|
1710
2192
|
);
|
|
1711
2193
|
continue;
|
|
1712
2194
|
}
|
|
@@ -1729,19 +2211,19 @@ function parseMarkdown(content) {
|
|
|
1729
2211
|
}
|
|
1730
2212
|
}
|
|
1731
2213
|
result.push(
|
|
1732
|
-
/* @__PURE__ */
|
|
1733
|
-
/* @__PURE__ */
|
|
1734
|
-
/* @__PURE__ */
|
|
2214
|
+
/* @__PURE__ */ jsx15("div", { className: "apteva-md-table-wrapper", children: /* @__PURE__ */ jsxs10("table", { className: "apteva-md-table", children: [
|
|
2215
|
+
/* @__PURE__ */ jsx15("thead", { children: /* @__PURE__ */ jsx15("tr", { children: headerCells.map((cell, idx) => /* @__PURE__ */ jsx15("th", { className: "apteva-md-th", children: parseInlineMarkdown(cell, `th${key}${idx}`) }, `th${idx}`)) }) }),
|
|
2216
|
+
/* @__PURE__ */ jsx15("tbody", { children: bodyRows.map((row, rowIdx) => /* @__PURE__ */ jsx15("tr", { children: row.map((cell, cellIdx) => /* @__PURE__ */ jsx15("td", { className: "apteva-md-td", children: parseInlineMarkdown(cell, `td${key}${rowIdx}${cellIdx}`) }, `td${cellIdx}`)) }, `tr${rowIdx}`)) })
|
|
1735
2217
|
] }) }, `table-wrapper${key++}`)
|
|
1736
2218
|
);
|
|
1737
2219
|
continue;
|
|
1738
2220
|
}
|
|
1739
2221
|
}
|
|
1740
2222
|
if (line === "") {
|
|
1741
|
-
result.push(/* @__PURE__ */
|
|
2223
|
+
result.push(/* @__PURE__ */ jsx15("br", {}, `br${key++}`));
|
|
1742
2224
|
} else {
|
|
1743
2225
|
result.push(
|
|
1744
|
-
/* @__PURE__ */
|
|
2226
|
+
/* @__PURE__ */ jsxs10("span", { children: [
|
|
1745
2227
|
parseInlineMarkdown(line, `${key}`),
|
|
1746
2228
|
i < lines.length - 1 ? "\n" : ""
|
|
1747
2229
|
] }, `p${key++}`)
|
|
@@ -1752,53 +2234,53 @@ function parseMarkdown(content) {
|
|
|
1752
2234
|
return result;
|
|
1753
2235
|
}
|
|
1754
2236
|
function MarkdownContent({ content, className = "" }) {
|
|
1755
|
-
return /* @__PURE__ */
|
|
2237
|
+
return /* @__PURE__ */ jsx15("div", { className: `apteva-md ${className}`, children: parseMarkdown(content) });
|
|
1756
2238
|
}
|
|
1757
2239
|
|
|
1758
2240
|
// src/components/Chat/ToolCall.tsx
|
|
1759
|
-
import { Fragment, jsx as
|
|
2241
|
+
import { Fragment as Fragment2, jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1760
2242
|
function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOutput }) {
|
|
1761
2243
|
if (status === "preparing") {
|
|
1762
|
-
return /* @__PURE__ */
|
|
1763
|
-
/* @__PURE__ */
|
|
1764
|
-
/* @__PURE__ */
|
|
1765
|
-
/* @__PURE__ */
|
|
2244
|
+
return /* @__PURE__ */ jsxs11("div", { className: "apteva-tool-card apteva-tool-card-preparing", children: [
|
|
2245
|
+
/* @__PURE__ */ jsxs11("svg", { className: "apteva-tool-icon apteva-tool-icon-spin", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2246
|
+
/* @__PURE__ */ jsx16("circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2247
|
+
/* @__PURE__ */ jsx16("path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
1766
2248
|
] }),
|
|
1767
|
-
/* @__PURE__ */
|
|
1768
|
-
/* @__PURE__ */
|
|
1769
|
-
/* @__PURE__ */
|
|
2249
|
+
/* @__PURE__ */ jsxs11("span", { className: "apteva-tool-label", children: [
|
|
2250
|
+
/* @__PURE__ */ jsx16("strong", { children: name }),
|
|
2251
|
+
/* @__PURE__ */ jsx16("span", { className: "apteva-tool-status-text", children: " preparing..." })
|
|
1770
2252
|
] })
|
|
1771
2253
|
] });
|
|
1772
2254
|
}
|
|
1773
2255
|
if (status === "running") {
|
|
1774
|
-
return /* @__PURE__ */
|
|
1775
|
-
/* @__PURE__ */
|
|
1776
|
-
/* @__PURE__ */
|
|
1777
|
-
/* @__PURE__ */
|
|
2256
|
+
return /* @__PURE__ */ jsxs11("div", { className: "apteva-tool-card apteva-tool-card-running", children: [
|
|
2257
|
+
/* @__PURE__ */ jsxs11("svg", { className: "apteva-tool-icon apteva-tool-icon-spin", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2258
|
+
/* @__PURE__ */ jsx16("circle", { className: "apteva-tool-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2259
|
+
/* @__PURE__ */ jsx16("path", { className: "apteva-tool-spinner-fill", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
1778
2260
|
] }),
|
|
1779
|
-
/* @__PURE__ */
|
|
1780
|
-
/* @__PURE__ */
|
|
1781
|
-
streamOutput ? /* @__PURE__ */
|
|
1782
|
-
streamOutput ? /* @__PURE__ */
|
|
1783
|
-
/* @__PURE__ */
|
|
1784
|
-
/* @__PURE__ */
|
|
1785
|
-
/* @__PURE__ */
|
|
1786
|
-
/* @__PURE__ */
|
|
1787
|
-
/* @__PURE__ */
|
|
2261
|
+
/* @__PURE__ */ jsxs11("span", { className: "apteva-tool-label", children: [
|
|
2262
|
+
/* @__PURE__ */ jsx16("strong", { children: name }),
|
|
2263
|
+
streamOutput ? /* @__PURE__ */ jsx16("span", { className: "apteva-tool-stream-separator", children: " \xB7 " }) : null,
|
|
2264
|
+
streamOutput ? /* @__PURE__ */ jsx16("span", { className: "apteva-tool-stream-output", children: streamOutput }) : /* @__PURE__ */ jsxs11(Fragment2, { children: [
|
|
2265
|
+
/* @__PURE__ */ jsx16("span", { className: "apteva-tool-status-text", children: " running" }),
|
|
2266
|
+
/* @__PURE__ */ jsxs11("span", { className: "apteva-tool-dots", children: [
|
|
2267
|
+
/* @__PURE__ */ jsx16("span", { children: "." }),
|
|
2268
|
+
/* @__PURE__ */ jsx16("span", { children: "." }),
|
|
2269
|
+
/* @__PURE__ */ jsx16("span", { children: "." })
|
|
1788
2270
|
] })
|
|
1789
2271
|
] })
|
|
1790
2272
|
] })
|
|
1791
2273
|
] });
|
|
1792
2274
|
}
|
|
1793
2275
|
if (status === "completed") {
|
|
1794
|
-
return /* @__PURE__ */
|
|
1795
|
-
/* @__PURE__ */
|
|
1796
|
-
/* @__PURE__ */
|
|
2276
|
+
return /* @__PURE__ */ jsxs11("div", { className: "apteva-tool-card apteva-tool-card-completed", children: [
|
|
2277
|
+
/* @__PURE__ */ jsx16("svg", { className: "apteva-tool-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx16("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }),
|
|
2278
|
+
/* @__PURE__ */ jsx16("span", { className: "apteva-tool-label", children: name })
|
|
1797
2279
|
] });
|
|
1798
2280
|
}
|
|
1799
|
-
return /* @__PURE__ */
|
|
1800
|
-
/* @__PURE__ */
|
|
1801
|
-
/* @__PURE__ */
|
|
2281
|
+
return /* @__PURE__ */ jsxs11("div", { className: "apteva-tool-card apteva-tool-card-error", children: [
|
|
2282
|
+
/* @__PURE__ */ jsx16("svg", { className: "apteva-tool-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx16("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }),
|
|
2283
|
+
/* @__PURE__ */ jsxs11("span", { className: "apteva-tool-label", children: [
|
|
1802
2284
|
name,
|
|
1803
2285
|
" failed"
|
|
1804
2286
|
] })
|
|
@@ -1806,7 +2288,7 @@ function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOu
|
|
|
1806
2288
|
}
|
|
1807
2289
|
|
|
1808
2290
|
// src/components/Chat/Message.tsx
|
|
1809
|
-
import { jsx as
|
|
2291
|
+
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1810
2292
|
function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
1811
2293
|
const isUser = message.role === "user";
|
|
1812
2294
|
const contentSegments = message.metadata?.content_segments;
|
|
@@ -1842,14 +2324,14 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1842
2324
|
}, [parsedWidgets, onWidgetRender]);
|
|
1843
2325
|
const renderTextContent = (text) => {
|
|
1844
2326
|
if (!enableWidgets || isUser) {
|
|
1845
|
-
return /* @__PURE__ */
|
|
2327
|
+
return /* @__PURE__ */ jsx17(MarkdownContent, { content: text });
|
|
1846
2328
|
}
|
|
1847
2329
|
const parsed = parseWidgetsFromText(text);
|
|
1848
2330
|
const cleanedText = parsed.segments.filter((seg) => seg.type === "text" && seg.content).map((seg) => seg.content).join("");
|
|
1849
2331
|
if (!cleanedText.trim()) {
|
|
1850
2332
|
return null;
|
|
1851
2333
|
}
|
|
1852
|
-
return /* @__PURE__ */
|
|
2334
|
+
return /* @__PURE__ */ jsx17(MarkdownContent, { content: cleanedText });
|
|
1853
2335
|
};
|
|
1854
2336
|
const renderContentWithWidgets = () => {
|
|
1855
2337
|
if (!enableWidgets || isUser || !message.content) {
|
|
@@ -1864,28 +2346,28 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1864
2346
|
} else if (segment.type === "widget" && segment.widget) {
|
|
1865
2347
|
if (textBuffer.trim()) {
|
|
1866
2348
|
elements.push(
|
|
1867
|
-
/* @__PURE__ */
|
|
2349
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx17("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx17(MarkdownContent, { content: textBuffer }) }) }, `text-${index}`)
|
|
1868
2350
|
);
|
|
1869
2351
|
textBuffer = "";
|
|
1870
2352
|
}
|
|
1871
2353
|
elements.push(
|
|
1872
|
-
/* @__PURE__ */
|
|
2354
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx17(WidgetRenderer, { widget: segment.widget, onAction }) }, `widget-${index}`)
|
|
1873
2355
|
);
|
|
1874
2356
|
} else if (segment.type === "widget_pending" && segment.pendingType) {
|
|
1875
2357
|
if (textBuffer.trim()) {
|
|
1876
2358
|
elements.push(
|
|
1877
|
-
/* @__PURE__ */
|
|
2359
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx17("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx17(MarkdownContent, { content: textBuffer }) }) }, `text-${index}`)
|
|
1878
2360
|
);
|
|
1879
2361
|
textBuffer = "";
|
|
1880
2362
|
}
|
|
1881
2363
|
elements.push(
|
|
1882
|
-
/* @__PURE__ */
|
|
2364
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx17(WidgetSkeleton, { type: segment.pendingType }) }, `pending-${index}`)
|
|
1883
2365
|
);
|
|
1884
2366
|
}
|
|
1885
2367
|
});
|
|
1886
2368
|
if (textBuffer.trim()) {
|
|
1887
2369
|
elements.push(
|
|
1888
|
-
/* @__PURE__ */
|
|
2370
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx17("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx17(MarkdownContent, { content: textBuffer }) }) }, "text-final")
|
|
1889
2371
|
);
|
|
1890
2372
|
}
|
|
1891
2373
|
return elements.length > 0 ? elements : null;
|
|
@@ -1894,11 +2376,11 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1894
2376
|
const hasAttachments = attachments.length > 0;
|
|
1895
2377
|
const renderAttachments = () => {
|
|
1896
2378
|
if (!hasAttachments) return null;
|
|
1897
|
-
return /* @__PURE__ */
|
|
2379
|
+
return /* @__PURE__ */ jsx17("div", { className: "apteva-message-attachments flex flex-wrap gap-2 mb-2 justify-end", children: attachments.map((att, index) => {
|
|
1898
2380
|
const isImage = att.type.startsWith("image/");
|
|
1899
2381
|
const isPdf = att.type === "application/pdf";
|
|
1900
2382
|
if (isImage && att.preview) {
|
|
1901
|
-
return /* @__PURE__ */
|
|
2383
|
+
return /* @__PURE__ */ jsx17("div", { className: "apteva-attachment-image relative rounded-lg overflow-hidden shadow-sm", children: /* @__PURE__ */ jsx17(
|
|
1902
2384
|
"img",
|
|
1903
2385
|
{
|
|
1904
2386
|
src: att.preview,
|
|
@@ -1907,15 +2389,15 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1907
2389
|
}
|
|
1908
2390
|
) }, index);
|
|
1909
2391
|
}
|
|
1910
|
-
return /* @__PURE__ */
|
|
2392
|
+
return /* @__PURE__ */ jsxs12(
|
|
1911
2393
|
"div",
|
|
1912
2394
|
{
|
|
1913
2395
|
className: "apteva-attachment-doc flex items-center gap-3 px-4 py-3 bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-xl shadow-sm",
|
|
1914
2396
|
children: [
|
|
1915
|
-
/* @__PURE__ */
|
|
1916
|
-
/* @__PURE__ */
|
|
1917
|
-
/* @__PURE__ */
|
|
1918
|
-
/* @__PURE__ */
|
|
2397
|
+
/* @__PURE__ */ jsx17("div", { className: "w-10 h-10 flex items-center justify-center bg-red-100 dark:bg-red-900/30 rounded-lg text-red-600 dark:text-red-400", children: isPdf ? /* @__PURE__ */ jsx17("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx17("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" }) }) : /* @__PURE__ */ jsx17("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx17("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" }) }) }),
|
|
2398
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col min-w-0", children: [
|
|
2399
|
+
/* @__PURE__ */ jsx17("span", { className: "text-sm font-medium text-neutral-800 dark:text-neutral-200 truncate max-w-[180px]", children: att.name }),
|
|
2400
|
+
/* @__PURE__ */ jsxs12("span", { className: "text-xs text-neutral-500 dark:text-neutral-400", children: [
|
|
1919
2401
|
isPdf ? "PDF" : "Document",
|
|
1920
2402
|
" \xB7 ",
|
|
1921
2403
|
formatFileSize(att.size)
|
|
@@ -1929,13 +2411,13 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1929
2411
|
};
|
|
1930
2412
|
const renderContent = () => {
|
|
1931
2413
|
if (isUser) {
|
|
1932
|
-
return /* @__PURE__ */
|
|
2414
|
+
return /* @__PURE__ */ jsx17("div", { className: "apteva-message-text", children: message.content });
|
|
1933
2415
|
}
|
|
1934
2416
|
if (isStreaming && !hasContent) {
|
|
1935
|
-
return /* @__PURE__ */
|
|
1936
|
-
/* @__PURE__ */
|
|
1937
|
-
/* @__PURE__ */
|
|
1938
|
-
/* @__PURE__ */
|
|
2417
|
+
return /* @__PURE__ */ jsxs12("div", { className: "apteva-typing-indicator", children: [
|
|
2418
|
+
/* @__PURE__ */ jsx17("span", {}),
|
|
2419
|
+
/* @__PURE__ */ jsx17("span", {}),
|
|
2420
|
+
/* @__PURE__ */ jsx17("span", {})
|
|
1939
2421
|
] });
|
|
1940
2422
|
}
|
|
1941
2423
|
if (contentSegments && contentSegments.length > 0) {
|
|
@@ -1945,7 +2427,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1945
2427
|
};
|
|
1946
2428
|
const renderTextSegmentWithWidgets = (text, keyPrefix) => {
|
|
1947
2429
|
if (!enableWidgets) {
|
|
1948
|
-
return /* @__PURE__ */
|
|
2430
|
+
return /* @__PURE__ */ jsx17("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx17("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx17(MarkdownContent, { content: text }) }) }, keyPrefix);
|
|
1949
2431
|
}
|
|
1950
2432
|
const parsed = parseWidgetsFromText(text);
|
|
1951
2433
|
const elements = [];
|
|
@@ -1956,28 +2438,28 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1956
2438
|
} else if (seg.type === "widget" && seg.widget) {
|
|
1957
2439
|
if (textBuffer.trim()) {
|
|
1958
2440
|
elements.push(
|
|
1959
|
-
/* @__PURE__ */
|
|
2441
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx17("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx17(MarkdownContent, { content: textBuffer }) }) }, `${keyPrefix}-text-${idx}`)
|
|
1960
2442
|
);
|
|
1961
2443
|
textBuffer = "";
|
|
1962
2444
|
}
|
|
1963
2445
|
elements.push(
|
|
1964
|
-
/* @__PURE__ */
|
|
2446
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx17(WidgetRenderer, { widget: seg.widget, onAction }) }, `${keyPrefix}-widget-${idx}`)
|
|
1965
2447
|
);
|
|
1966
2448
|
} else if (seg.type === "widget_pending" && seg.pendingType) {
|
|
1967
2449
|
if (textBuffer.trim()) {
|
|
1968
2450
|
elements.push(
|
|
1969
|
-
/* @__PURE__ */
|
|
2451
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx17("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx17(MarkdownContent, { content: textBuffer }) }) }, `${keyPrefix}-text-${idx}`)
|
|
1970
2452
|
);
|
|
1971
2453
|
textBuffer = "";
|
|
1972
2454
|
}
|
|
1973
2455
|
elements.push(
|
|
1974
|
-
/* @__PURE__ */
|
|
2456
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx17(WidgetSkeleton, { type: seg.pendingType }) }, `${keyPrefix}-pending-${idx}`)
|
|
1975
2457
|
);
|
|
1976
2458
|
}
|
|
1977
2459
|
});
|
|
1978
2460
|
if (textBuffer.trim()) {
|
|
1979
2461
|
elements.push(
|
|
1980
|
-
/* @__PURE__ */
|
|
2462
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-message-bubble apteva-message-assistant", children: /* @__PURE__ */ jsx17("div", { className: "apteva-message-content-assistant", children: /* @__PURE__ */ jsx17(MarkdownContent, { content: textBuffer }) }) }, `${keyPrefix}-text-final`)
|
|
1981
2463
|
);
|
|
1982
2464
|
}
|
|
1983
2465
|
return elements;
|
|
@@ -1997,7 +2479,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
1997
2479
|
}
|
|
1998
2480
|
} else if (segment.type === "tool") {
|
|
1999
2481
|
elements.push(
|
|
2000
|
-
/* @__PURE__ */
|
|
2482
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-tool-call-standalone", children: /* @__PURE__ */ jsx17(
|
|
2001
2483
|
ToolCall,
|
|
2002
2484
|
{
|
|
2003
2485
|
name: segment.name,
|
|
@@ -2013,28 +2495,28 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2013
2495
|
return elements;
|
|
2014
2496
|
};
|
|
2015
2497
|
if (!isUser && (contentSegments && contentSegments.length > 0)) {
|
|
2016
|
-
return /* @__PURE__ */
|
|
2498
|
+
return /* @__PURE__ */ jsxs12("div", { className: "apteva-message-segmented", children: [
|
|
2017
2499
|
renderSegmentedContent(),
|
|
2018
|
-
message.widgets && message.widgets.length > 0 && /* @__PURE__ */
|
|
2019
|
-
/* @__PURE__ */
|
|
2500
|
+
message.widgets && message.widgets.length > 0 && /* @__PURE__ */ jsx17("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx17(Widgets, { widgets: message.widgets, onAction, layout: "stack" }) }),
|
|
2501
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-message-timestamp apteva-message-timestamp-assistant", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
2020
2502
|
] });
|
|
2021
2503
|
}
|
|
2022
2504
|
const widgetContent = renderContentWithWidgets();
|
|
2023
2505
|
if (!isUser && enableWidgets && widgetContent) {
|
|
2024
|
-
return /* @__PURE__ */
|
|
2506
|
+
return /* @__PURE__ */ jsxs12("div", { className: "apteva-message-segmented", children: [
|
|
2025
2507
|
widgetContent,
|
|
2026
|
-
message.widgets && message.widgets.length > 0 && /* @__PURE__ */
|
|
2027
|
-
/* @__PURE__ */
|
|
2508
|
+
message.widgets && message.widgets.length > 0 && /* @__PURE__ */ jsx17("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx17(Widgets, { widgets: message.widgets, onAction, layout: "stack" }) }),
|
|
2509
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-message-timestamp apteva-message-timestamp-assistant", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
2028
2510
|
] });
|
|
2029
2511
|
}
|
|
2030
2512
|
if (isUser && hasAttachments) {
|
|
2031
|
-
return /* @__PURE__ */
|
|
2513
|
+
return /* @__PURE__ */ jsxs12("div", { className: "apteva-message-segmented apteva-message-user-with-attachments flex flex-col items-end", children: [
|
|
2032
2514
|
renderAttachments(),
|
|
2033
|
-
message.content && /* @__PURE__ */
|
|
2034
|
-
/* @__PURE__ */
|
|
2515
|
+
message.content && /* @__PURE__ */ jsx17("div", { className: "apteva-message-bubble apteva-message-user", children: /* @__PURE__ */ jsx17("div", { className: "apteva-message-content-user", children: /* @__PURE__ */ jsx17("div", { className: "apteva-message-text", children: message.content }) }) }),
|
|
2516
|
+
/* @__PURE__ */ jsx17("div", { className: "apteva-message-timestamp apteva-message-timestamp-user", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
2035
2517
|
] });
|
|
2036
2518
|
}
|
|
2037
|
-
return /* @__PURE__ */
|
|
2519
|
+
return /* @__PURE__ */ jsxs12(
|
|
2038
2520
|
"div",
|
|
2039
2521
|
{
|
|
2040
2522
|
className: cn(
|
|
@@ -2042,17 +2524,17 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
|
|
|
2042
2524
|
isUser ? "apteva-message-user" : "apteva-message-assistant"
|
|
2043
2525
|
),
|
|
2044
2526
|
children: [
|
|
2045
|
-
/* @__PURE__ */
|
|
2046
|
-
message.widgets && message.widgets.length > 0 && /* @__PURE__ */
|
|
2047
|
-
/* @__PURE__ */
|
|
2527
|
+
/* @__PURE__ */ jsx17("div", { className: isUser ? "apteva-message-content-user" : "apteva-message-content-assistant", children: renderContent() }),
|
|
2528
|
+
message.widgets && message.widgets.length > 0 && /* @__PURE__ */ jsx17("div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ jsx17(Widgets, { widgets: message.widgets, onAction, layout: "stack" }) }),
|
|
2529
|
+
/* @__PURE__ */ jsx17("div", { className: cn("apteva-message-timestamp", isUser ? "apteva-message-timestamp-user" : "apteva-message-timestamp-assistant"), suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
2048
2530
|
]
|
|
2049
2531
|
}
|
|
2050
2532
|
);
|
|
2051
2533
|
}
|
|
2052
2534
|
|
|
2053
2535
|
// src/components/Chat/WelcomeScreen.tsx
|
|
2054
|
-
import { jsx as
|
|
2055
|
-
var DefaultIcon = () => /* @__PURE__ */
|
|
2536
|
+
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2537
|
+
var DefaultIcon = () => /* @__PURE__ */ jsx18("svg", { className: "w-12 h-12 sm:w-16 sm:h-16", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx18(
|
|
2056
2538
|
"path",
|
|
2057
2539
|
{
|
|
2058
2540
|
strokeLinecap: "round",
|
|
@@ -2061,16 +2543,7 @@ var DefaultIcon = () => /* @__PURE__ */ jsx15("svg", { className: "w-12 h-12 sm:
|
|
|
2061
2543
|
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"
|
|
2062
2544
|
}
|
|
2063
2545
|
) });
|
|
2064
|
-
var
|
|
2065
|
-
"path",
|
|
2066
|
-
{
|
|
2067
|
-
strokeLinecap: "round",
|
|
2068
|
-
strokeLinejoin: "round",
|
|
2069
|
-
strokeWidth: 1.5,
|
|
2070
|
-
d: "M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
2071
|
-
}
|
|
2072
|
-
) });
|
|
2073
|
-
var ArrowIcon = () => /* @__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: "M13 7l5 5m0 0l-5 5m5-5H6" }) });
|
|
2546
|
+
var ArrowIcon = () => /* @__PURE__ */ jsx18("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 7l5 5m0 0l-5 5m5-5H6" }) });
|
|
2074
2547
|
function WelcomeScreen({
|
|
2075
2548
|
title,
|
|
2076
2549
|
subtitle,
|
|
@@ -2080,25 +2553,24 @@ function WelcomeScreen({
|
|
|
2080
2553
|
chatVariant = "default",
|
|
2081
2554
|
onPromptClick
|
|
2082
2555
|
}) {
|
|
2083
|
-
const WelcomeIcon = chatVariant === "terminal" ? TerminalIcon : DefaultIcon;
|
|
2084
2556
|
const normalizedPrompts = (prompts || []).map(
|
|
2085
2557
|
(p) => typeof p === "string" ? { text: p } : p
|
|
2086
2558
|
);
|
|
2087
2559
|
const hasPrompts = normalizedPrompts.length > 0;
|
|
2088
2560
|
const hasHeader = title || subtitle || icon;
|
|
2089
2561
|
if (!hasHeader && !hasPrompts) {
|
|
2090
|
-
return /* @__PURE__ */
|
|
2091
|
-
/* @__PURE__ */
|
|
2092
|
-
/* @__PURE__ */
|
|
2562
|
+
return /* @__PURE__ */ jsx18("div", { className: "flex items-center justify-center h-full !text-neutral-500 dark:!text-neutral-400", children: /* @__PURE__ */ jsxs13("div", { className: "text-center space-y-2", children: [
|
|
2563
|
+
/* @__PURE__ */ jsx18("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx18(DefaultIcon, {}) }),
|
|
2564
|
+
/* @__PURE__ */ jsx18("p", { className: "text-sm", children: "No messages yet. Start a conversation!" })
|
|
2093
2565
|
] }) });
|
|
2094
2566
|
}
|
|
2095
2567
|
if (variant === "minimal") {
|
|
2096
|
-
return /* @__PURE__ */
|
|
2097
|
-
hasHeader && /* @__PURE__ */
|
|
2098
|
-
title && /* @__PURE__ */
|
|
2099
|
-
subtitle && /* @__PURE__ */
|
|
2568
|
+
return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col h-full px-4 py-4", children: [
|
|
2569
|
+
hasHeader && /* @__PURE__ */ jsxs13("div", { className: "mb-4", children: [
|
|
2570
|
+
title && /* @__PURE__ */ jsx18("h2", { className: "text-lg font-semibold !text-neutral-900 dark:!text-white", children: title }),
|
|
2571
|
+
subtitle && /* @__PURE__ */ jsx18("p", { className: "text-sm !text-neutral-500 dark:!text-neutral-400 mt-1", children: subtitle })
|
|
2100
2572
|
] }),
|
|
2101
|
-
hasPrompts && /* @__PURE__ */
|
|
2573
|
+
hasPrompts && /* @__PURE__ */ jsx18("div", { className: "flex-1 space-y-2", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx18(
|
|
2102
2574
|
"button",
|
|
2103
2575
|
{
|
|
2104
2576
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -2111,11 +2583,11 @@ function WelcomeScreen({
|
|
|
2111
2583
|
"transition-all duration-200",
|
|
2112
2584
|
"group"
|
|
2113
2585
|
),
|
|
2114
|
-
children: /* @__PURE__ */
|
|
2115
|
-
/* @__PURE__ */
|
|
2116
|
-
/* @__PURE__ */
|
|
2117
|
-
/* @__PURE__ */
|
|
2118
|
-
prompt.description && /* @__PURE__ */
|
|
2586
|
+
children: /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-3", children: [
|
|
2587
|
+
/* @__PURE__ */ jsx18("div", { className: "flex-shrink-0 !text-neutral-400 dark:!text-neutral-500 group-hover:!text-blue-500 dark:group-hover:!text-blue-400 transition-colors", children: prompt.icon || /* @__PURE__ */ jsx18(ArrowIcon, {}) }),
|
|
2588
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex-1 min-w-0", children: [
|
|
2589
|
+
/* @__PURE__ */ jsx18("p", { className: "text-sm font-medium !text-neutral-900 dark:!text-white truncate", children: prompt.text }),
|
|
2590
|
+
prompt.description && /* @__PURE__ */ jsx18("p", { className: "text-xs !text-neutral-500 dark:!text-neutral-400 mt-0.5 truncate", children: prompt.description })
|
|
2119
2591
|
] })
|
|
2120
2592
|
] })
|
|
2121
2593
|
},
|
|
@@ -2123,14 +2595,14 @@ function WelcomeScreen({
|
|
|
2123
2595
|
)) })
|
|
2124
2596
|
] });
|
|
2125
2597
|
}
|
|
2126
|
-
return /* @__PURE__ */
|
|
2127
|
-
/* @__PURE__ */
|
|
2128
|
-
/* @__PURE__ */
|
|
2129
|
-
title && /* @__PURE__ */
|
|
2130
|
-
subtitle && /* @__PURE__ */
|
|
2598
|
+
return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col items-center justify-center h-full px-4 py-6 sm:py-8", children: [
|
|
2599
|
+
/* @__PURE__ */ jsxs13("div", { className: "text-center mb-6 sm:mb-8 max-w-md", children: [
|
|
2600
|
+
/* @__PURE__ */ jsx18("div", { className: "mb-4 !text-neutral-400 dark:!text-neutral-500 flex justify-center", children: icon || /* @__PURE__ */ jsx18(DefaultIcon, {}) }),
|
|
2601
|
+
title && /* @__PURE__ */ jsx18("h1", { className: "text-xl sm:text-2xl font-semibold !text-neutral-900 dark:!text-white mb-2", children: title }),
|
|
2602
|
+
subtitle && /* @__PURE__ */ jsx18("p", { className: "text-sm sm:text-base !text-neutral-500 dark:!text-neutral-400", children: subtitle })
|
|
2131
2603
|
] }),
|
|
2132
|
-
hasPrompts && /* @__PURE__ */
|
|
2133
|
-
/* @__PURE__ */
|
|
2604
|
+
hasPrompts && /* @__PURE__ */ jsxs13("div", { className: "w-full max-w-2xl", children: [
|
|
2605
|
+
/* @__PURE__ */ jsx18("div", { className: "sm:hidden space-y-2", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx18(
|
|
2134
2606
|
"button",
|
|
2135
2607
|
{
|
|
2136
2608
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -2145,20 +2617,20 @@ function WelcomeScreen({
|
|
|
2145
2617
|
"shadow-sm hover:shadow",
|
|
2146
2618
|
"group"
|
|
2147
2619
|
),
|
|
2148
|
-
children: /* @__PURE__ */
|
|
2149
|
-
/* @__PURE__ */
|
|
2150
|
-
/* @__PURE__ */
|
|
2151
|
-
/* @__PURE__ */
|
|
2152
|
-
prompt.description && /* @__PURE__ */
|
|
2620
|
+
children: /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-3", children: [
|
|
2621
|
+
/* @__PURE__ */ jsx18("div", { className: "flex-shrink-0 w-8 h-8 rounded-lg bg-neutral-100 dark:bg-neutral-700 flex items-center justify-center !text-neutral-500 dark:!text-neutral-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__ */ jsx18(ArrowIcon, {}) }),
|
|
2622
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex-1 min-w-0", children: [
|
|
2623
|
+
/* @__PURE__ */ jsx18("p", { className: "text-sm font-medium !text-neutral-900 dark:!text-white", children: prompt.text }),
|
|
2624
|
+
prompt.description && /* @__PURE__ */ jsx18("p", { className: "text-xs !text-neutral-500 dark:!text-neutral-400 mt-0.5 line-clamp-1", children: prompt.description })
|
|
2153
2625
|
] }),
|
|
2154
|
-
/* @__PURE__ */
|
|
2626
|
+
/* @__PURE__ */ jsx18(
|
|
2155
2627
|
"svg",
|
|
2156
2628
|
{
|
|
2157
2629
|
className: "w-4 h-4 !text-neutral-400 group-hover:!text-blue-500 transition-colors flex-shrink-0",
|
|
2158
2630
|
fill: "none",
|
|
2159
2631
|
stroke: "currentColor",
|
|
2160
2632
|
viewBox: "0 0 24 24",
|
|
2161
|
-
children: /* @__PURE__ */
|
|
2633
|
+
children: /* @__PURE__ */ jsx18(
|
|
2162
2634
|
"path",
|
|
2163
2635
|
{
|
|
2164
2636
|
strokeLinecap: "round",
|
|
@@ -2173,7 +2645,7 @@ function WelcomeScreen({
|
|
|
2173
2645
|
},
|
|
2174
2646
|
index
|
|
2175
2647
|
)) }),
|
|
2176
|
-
/* @__PURE__ */
|
|
2648
|
+
/* @__PURE__ */ jsx18("div", { className: "hidden sm:grid sm:grid-cols-2 gap-3", children: normalizedPrompts.map((prompt, index) => /* @__PURE__ */ jsx18(
|
|
2177
2649
|
"button",
|
|
2178
2650
|
{
|
|
2179
2651
|
onClick: () => onPromptClick(prompt.text),
|
|
@@ -2188,11 +2660,11 @@ function WelcomeScreen({
|
|
|
2188
2660
|
"transition-all duration-200",
|
|
2189
2661
|
"group"
|
|
2190
2662
|
),
|
|
2191
|
-
children: /* @__PURE__ */
|
|
2192
|
-
/* @__PURE__ */
|
|
2193
|
-
/* @__PURE__ */
|
|
2194
|
-
/* @__PURE__ */
|
|
2195
|
-
prompt.description && /* @__PURE__ */
|
|
2663
|
+
children: /* @__PURE__ */ jsxs13("div", { className: "flex items-start gap-3", children: [
|
|
2664
|
+
/* @__PURE__ */ jsx18("div", { className: "flex-shrink-0 w-9 h-9 rounded-lg bg-neutral-100 dark:bg-neutral-700 flex items-center justify-center !text-neutral-500 dark:!text-neutral-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__ */ jsx18(ArrowIcon, {}) }),
|
|
2665
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex-1 min-w-0", children: [
|
|
2666
|
+
/* @__PURE__ */ jsx18("p", { className: "text-sm font-medium !text-neutral-900 dark:!text-white leading-snug", children: prompt.text }),
|
|
2667
|
+
prompt.description && /* @__PURE__ */ jsx18("p", { className: "text-xs !text-neutral-500 dark:!text-neutral-400 mt-1 line-clamp-2", children: prompt.description })
|
|
2196
2668
|
] })
|
|
2197
2669
|
] })
|
|
2198
2670
|
},
|
|
@@ -2203,7 +2675,7 @@ function WelcomeScreen({
|
|
|
2203
2675
|
}
|
|
2204
2676
|
|
|
2205
2677
|
// src/components/Chat/MessageList.tsx
|
|
2206
|
-
import { jsx as
|
|
2678
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
2207
2679
|
function MessageList({
|
|
2208
2680
|
messages,
|
|
2209
2681
|
onAction,
|
|
@@ -2235,7 +2707,7 @@ function MessageList({
|
|
|
2235
2707
|
}
|
|
2236
2708
|
}
|
|
2237
2709
|
}, [messages]);
|
|
2238
|
-
return /* @__PURE__ */
|
|
2710
|
+
return /* @__PURE__ */ jsx19("div", { ref: listRef, className: "apteva-message-list apteva-scrollbar-hidden", onScroll: handleScroll, children: messages.length === 0 ? /* @__PURE__ */ jsx19(
|
|
2239
2711
|
WelcomeScreen,
|
|
2240
2712
|
{
|
|
2241
2713
|
title: welcomeTitle,
|
|
@@ -2247,12 +2719,12 @@ function MessageList({
|
|
|
2247
2719
|
onPromptClick: onPromptClick || (() => {
|
|
2248
2720
|
})
|
|
2249
2721
|
}
|
|
2250
|
-
) : messages.map((message) => /* @__PURE__ */
|
|
2722
|
+
) : messages.map((message) => /* @__PURE__ */ jsx19("div", { className: message.role === "user" ? "apteva-message-row-user" : "apteva-message-row-assistant", children: /* @__PURE__ */ jsx19(Message, { message, onAction, enableWidgets, onWidgetRender }) }, message.id)) });
|
|
2251
2723
|
}
|
|
2252
2724
|
|
|
2253
2725
|
// src/components/Chat/Composer.tsx
|
|
2254
2726
|
import { useState as useState4, useRef as useRef5 } from "react";
|
|
2255
|
-
import { Fragment as
|
|
2727
|
+
import { Fragment as Fragment3, jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2256
2728
|
function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, isLoading = false, onStop, onFileUpload, onSwitchMode }) {
|
|
2257
2729
|
const [text, setText] = useState4("");
|
|
2258
2730
|
const [showMenu, setShowMenu] = useState4(false);
|
|
@@ -2337,42 +2809,35 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2337
2809
|
};
|
|
2338
2810
|
const getFileIcon = (mimeType) => {
|
|
2339
2811
|
if (mimeType.startsWith("image/")) {
|
|
2340
|
-
return /* @__PURE__ */
|
|
2812
|
+
return /* @__PURE__ */ jsx20("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx20("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" }) });
|
|
2341
2813
|
}
|
|
2342
2814
|
if (mimeType === "application/pdf") {
|
|
2343
|
-
return /* @__PURE__ */
|
|
2815
|
+
return /* @__PURE__ */ jsx20("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx20("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" }) });
|
|
2344
2816
|
}
|
|
2345
|
-
return /* @__PURE__ */
|
|
2817
|
+
return /* @__PURE__ */ jsx20("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx20("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" }) });
|
|
2346
2818
|
};
|
|
2347
|
-
return /* @__PURE__ */
|
|
2348
|
-
fileError && /* @__PURE__ */
|
|
2349
|
-
/* @__PURE__ */
|
|
2350
|
-
/* @__PURE__ */
|
|
2819
|
+
return /* @__PURE__ */ jsxs14("div", { className: "px-4 py-3 relative", children: [
|
|
2820
|
+
fileError && /* @__PURE__ */ jsx20("div", { className: "apteva-file-error", children: /* @__PURE__ */ jsxs14("div", { className: "apteva-file-error-content", children: [
|
|
2821
|
+
/* @__PURE__ */ jsx20("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx20("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
2822
|
+
/* @__PURE__ */ jsx20("span", { children: fileError })
|
|
2351
2823
|
] }) }),
|
|
2352
|
-
pendingFiles.length > 0 && /* @__PURE__ */
|
|
2353
|
-
"div",
|
|
2354
|
-
{
|
|
2355
|
-
|
|
2356
|
-
children:
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
}
|
|
2370
|
-
)
|
|
2371
|
-
]
|
|
2372
|
-
},
|
|
2373
|
-
index
|
|
2374
|
-
)) }),
|
|
2375
|
-
/* @__PURE__ */ jsxs13(
|
|
2824
|
+
pendingFiles.length > 0 && /* @__PURE__ */ jsx20("div", { className: "apteva-file-preview", children: pendingFiles.map((pf, index) => /* @__PURE__ */ jsxs14("div", { className: "apteva-file-item", children: [
|
|
2825
|
+
pf.preview ? /* @__PURE__ */ jsx20("img", { src: pf.preview, alt: pf.file.name, className: "apteva-file-thumb" }) : /* @__PURE__ */ jsx20("div", { className: "apteva-file-icon", children: getFileIcon(pf.file.type) }),
|
|
2826
|
+
/* @__PURE__ */ jsxs14("div", { className: "apteva-file-info", children: [
|
|
2827
|
+
/* @__PURE__ */ jsx20("span", { className: "apteva-file-name", children: pf.file.name }),
|
|
2828
|
+
/* @__PURE__ */ jsx20("span", { className: "apteva-file-size", children: formatFileSize(pf.file.size) })
|
|
2829
|
+
] }),
|
|
2830
|
+
/* @__PURE__ */ jsx20(
|
|
2831
|
+
"button",
|
|
2832
|
+
{
|
|
2833
|
+
onClick: () => removeFile(index),
|
|
2834
|
+
className: "apteva-file-remove",
|
|
2835
|
+
title: "Remove file",
|
|
2836
|
+
children: /* @__PURE__ */ jsx20("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx20("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
2837
|
+
}
|
|
2838
|
+
)
|
|
2839
|
+
] }, index)) }),
|
|
2840
|
+
/* @__PURE__ */ jsxs14(
|
|
2376
2841
|
"div",
|
|
2377
2842
|
{
|
|
2378
2843
|
className: "apteva-composer",
|
|
@@ -2382,20 +2847,20 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2382
2847
|
alignItems: "end"
|
|
2383
2848
|
},
|
|
2384
2849
|
children: [
|
|
2385
|
-
/* @__PURE__ */
|
|
2386
|
-
/* @__PURE__ */
|
|
2850
|
+
/* @__PURE__ */ jsxs14("div", { className: "relative flex-shrink-0 self-end", style: { gridArea: "plus" }, children: [
|
|
2851
|
+
/* @__PURE__ */ jsx20(
|
|
2387
2852
|
"button",
|
|
2388
2853
|
{
|
|
2389
2854
|
ref: menuButtonRef,
|
|
2390
2855
|
onClick: () => setShowMenu(!showMenu),
|
|
2391
2856
|
className: "apteva-composer-menu-btn w-8 h-8 rounded-lg flex items-center justify-center transition-all !text-neutral-700 dark:!text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
2392
2857
|
title: "More options",
|
|
2393
|
-
children: /* @__PURE__ */
|
|
2858
|
+
children: /* @__PURE__ */ jsx20("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx20("path", { d: "M10 5v10M5 10h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2394
2859
|
}
|
|
2395
2860
|
),
|
|
2396
|
-
showMenu && /* @__PURE__ */
|
|
2397
|
-
/* @__PURE__ */
|
|
2398
|
-
/* @__PURE__ */
|
|
2861
|
+
showMenu && /* @__PURE__ */ jsxs14(Fragment3, { children: [
|
|
2862
|
+
/* @__PURE__ */ jsx20("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
2863
|
+
/* @__PURE__ */ jsxs14(
|
|
2399
2864
|
"div",
|
|
2400
2865
|
{
|
|
2401
2866
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
@@ -2404,7 +2869,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2404
2869
|
bottom: window.innerHeight - (menuButtonRef.current?.getBoundingClientRect().top ?? 0) + 8
|
|
2405
2870
|
},
|
|
2406
2871
|
children: [
|
|
2407
|
-
/* @__PURE__ */
|
|
2872
|
+
/* @__PURE__ */ jsxs14(
|
|
2408
2873
|
"button",
|
|
2409
2874
|
{
|
|
2410
2875
|
onClick: () => {
|
|
@@ -2413,12 +2878,12 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2413
2878
|
},
|
|
2414
2879
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
|
|
2415
2880
|
children: [
|
|
2416
|
-
/* @__PURE__ */
|
|
2417
|
-
/* @__PURE__ */
|
|
2881
|
+
/* @__PURE__ */ jsx20("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx20("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)" }) }),
|
|
2882
|
+
/* @__PURE__ */ jsx20("span", { className: "!text-sm font-medium", children: "Add photos & files" })
|
|
2418
2883
|
]
|
|
2419
2884
|
}
|
|
2420
2885
|
),
|
|
2421
|
-
onSwitchMode && /* @__PURE__ */
|
|
2886
|
+
onSwitchMode && /* @__PURE__ */ jsxs14(
|
|
2422
2887
|
"button",
|
|
2423
2888
|
{
|
|
2424
2889
|
onClick: () => {
|
|
@@ -2427,8 +2892,8 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2427
2892
|
},
|
|
2428
2893
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left border-t border-neutral-700 dark:border-neutral-700",
|
|
2429
2894
|
children: [
|
|
2430
|
-
/* @__PURE__ */
|
|
2431
|
-
/* @__PURE__ */
|
|
2895
|
+
/* @__PURE__ */ jsx20("svg", { className: "w-4.5 h-4.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx20("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }),
|
|
2896
|
+
/* @__PURE__ */ jsx20("span", { className: "!text-sm font-medium", children: "Switch to command mode" })
|
|
2432
2897
|
]
|
|
2433
2898
|
}
|
|
2434
2899
|
)
|
|
@@ -2437,7 +2902,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2437
2902
|
)
|
|
2438
2903
|
] })
|
|
2439
2904
|
] }),
|
|
2440
|
-
/* @__PURE__ */
|
|
2905
|
+
/* @__PURE__ */ jsx20(
|
|
2441
2906
|
"textarea",
|
|
2442
2907
|
{
|
|
2443
2908
|
ref: textareaRef,
|
|
@@ -2451,28 +2916,28 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2451
2916
|
rows: 1
|
|
2452
2917
|
}
|
|
2453
2918
|
),
|
|
2454
|
-
/* @__PURE__ */
|
|
2919
|
+
/* @__PURE__ */ jsx20("div", { className: "self-end", style: { gridArea: "send" }, children: isLoading && onStop ? /* @__PURE__ */ jsx20(
|
|
2455
2920
|
"button",
|
|
2456
2921
|
{
|
|
2457
2922
|
onClick: onStop,
|
|
2458
2923
|
className: "apteva-composer-stop-btn",
|
|
2459
2924
|
title: "Stop generation",
|
|
2460
|
-
children: /* @__PURE__ */
|
|
2925
|
+
children: /* @__PURE__ */ jsx20("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx20("rect", { x: "2", y: "2", width: "10", height: "10", rx: "1", fill: "currentColor" }) })
|
|
2461
2926
|
}
|
|
2462
|
-
) : /* @__PURE__ */
|
|
2927
|
+
) : /* @__PURE__ */ jsx20(
|
|
2463
2928
|
"button",
|
|
2464
2929
|
{
|
|
2465
2930
|
onClick: handleSend,
|
|
2466
2931
|
disabled: !text.trim() && pendingFiles.length === 0 || disabled,
|
|
2467
2932
|
className: "apteva-composer-send-btn w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all flex-shrink-0 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 !text-neutral-700 dark:!text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed !text-lg",
|
|
2468
2933
|
title: "Send message",
|
|
2469
|
-
children: /* @__PURE__ */
|
|
2934
|
+
children: /* @__PURE__ */ jsx20("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx20("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2470
2935
|
}
|
|
2471
2936
|
) })
|
|
2472
2937
|
]
|
|
2473
2938
|
}
|
|
2474
2939
|
),
|
|
2475
|
-
/* @__PURE__ */
|
|
2940
|
+
/* @__PURE__ */ jsx20(
|
|
2476
2941
|
"input",
|
|
2477
2942
|
{
|
|
2478
2943
|
ref: fileInputRef,
|
|
@@ -2488,7 +2953,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
2488
2953
|
|
|
2489
2954
|
// src/components/Chat/CommandComposer.tsx
|
|
2490
2955
|
import { useState as useState5, useRef as useRef6 } from "react";
|
|
2491
|
-
import { Fragment as
|
|
2956
|
+
import { Fragment as Fragment4, jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2492
2957
|
function CommandComposer({
|
|
2493
2958
|
onExecute,
|
|
2494
2959
|
state,
|
|
@@ -2578,12 +3043,12 @@ function CommandComposer({
|
|
|
2578
3043
|
};
|
|
2579
3044
|
const getFileIcon = (mimeType) => {
|
|
2580
3045
|
if (mimeType.startsWith("image/")) {
|
|
2581
|
-
return /* @__PURE__ */
|
|
3046
|
+
return /* @__PURE__ */ jsx21("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21("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" }) });
|
|
2582
3047
|
}
|
|
2583
3048
|
if (mimeType === "application/pdf") {
|
|
2584
|
-
return /* @__PURE__ */
|
|
3049
|
+
return /* @__PURE__ */ jsx21("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21("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" }) });
|
|
2585
3050
|
}
|
|
2586
|
-
return /* @__PURE__ */
|
|
3051
|
+
return /* @__PURE__ */ jsx21("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21("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" }) });
|
|
2587
3052
|
};
|
|
2588
3053
|
const getDisplayContent = () => {
|
|
2589
3054
|
if (state === "loading") {
|
|
@@ -2608,12 +3073,12 @@ function CommandComposer({
|
|
|
2608
3073
|
};
|
|
2609
3074
|
const isShowingResult = state !== "idle";
|
|
2610
3075
|
const { text: displayContent, isToolCall } = getDisplayContent();
|
|
2611
|
-
return /* @__PURE__ */
|
|
2612
|
-
fileError && /* @__PURE__ */
|
|
2613
|
-
/* @__PURE__ */
|
|
2614
|
-
/* @__PURE__ */
|
|
3076
|
+
return /* @__PURE__ */ jsxs15("div", { className: "w-full relative", children: [
|
|
3077
|
+
fileError && /* @__PURE__ */ jsx21("div", { className: "apteva-file-error", style: { top: "-3rem", bottom: "auto" }, children: /* @__PURE__ */ jsxs15("div", { className: "apteva-file-error-content", children: [
|
|
3078
|
+
/* @__PURE__ */ jsx21("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
3079
|
+
/* @__PURE__ */ jsx21("span", { children: fileError })
|
|
2615
3080
|
] }) }),
|
|
2616
|
-
/* @__PURE__ */
|
|
3081
|
+
/* @__PURE__ */ jsxs15(
|
|
2617
3082
|
"div",
|
|
2618
3083
|
{
|
|
2619
3084
|
className: cn(
|
|
@@ -2625,21 +3090,21 @@ function CommandComposer({
|
|
|
2625
3090
|
state === "error" && "border-red-400 dark:border-red-500"
|
|
2626
3091
|
),
|
|
2627
3092
|
children: [
|
|
2628
|
-
/* @__PURE__ */
|
|
2629
|
-
state === "idle" && /* @__PURE__ */
|
|
2630
|
-
/* @__PURE__ */
|
|
3093
|
+
/* @__PURE__ */ jsxs15("div", { className: "w-8 h-8 flex items-center justify-center flex-shrink-0", children: [
|
|
3094
|
+
state === "idle" && /* @__PURE__ */ jsxs15("div", { className: "relative", children: [
|
|
3095
|
+
/* @__PURE__ */ jsx21(
|
|
2631
3096
|
"button",
|
|
2632
3097
|
{
|
|
2633
3098
|
ref: menuButtonRef,
|
|
2634
3099
|
onClick: () => setShowMenu(!showMenu),
|
|
2635
3100
|
className: "apteva-composer-menu-btn w-8 h-8 rounded-lg flex items-center justify-center transition-all !text-neutral-500 dark:!text-neutral-400 hover:!text-neutral-700 dark:hover:!text-neutral-200 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
2636
3101
|
title: "More options",
|
|
2637
|
-
children: /* @__PURE__ */
|
|
3102
|
+
children: /* @__PURE__ */ jsx21("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx21("path", { d: "M10 5v10M5 10h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
2638
3103
|
}
|
|
2639
3104
|
),
|
|
2640
|
-
showMenu && /* @__PURE__ */
|
|
2641
|
-
/* @__PURE__ */
|
|
2642
|
-
/* @__PURE__ */
|
|
3105
|
+
showMenu && /* @__PURE__ */ jsxs15(Fragment4, { children: [
|
|
3106
|
+
/* @__PURE__ */ jsx21("div", { className: "fixed inset-0 z-[9998]", onClick: () => setShowMenu(false) }),
|
|
3107
|
+
/* @__PURE__ */ jsxs15(
|
|
2643
3108
|
"div",
|
|
2644
3109
|
{
|
|
2645
3110
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
@@ -2648,7 +3113,7 @@ function CommandComposer({
|
|
|
2648
3113
|
top: (menuButtonRef.current?.getBoundingClientRect().bottom ?? 0) + 8
|
|
2649
3114
|
},
|
|
2650
3115
|
children: [
|
|
2651
|
-
/* @__PURE__ */
|
|
3116
|
+
/* @__PURE__ */ jsxs15(
|
|
2652
3117
|
"button",
|
|
2653
3118
|
{
|
|
2654
3119
|
onClick: () => {
|
|
@@ -2657,12 +3122,12 @@ function CommandComposer({
|
|
|
2657
3122
|
},
|
|
2658
3123
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
|
|
2659
3124
|
children: [
|
|
2660
|
-
/* @__PURE__ */
|
|
2661
|
-
/* @__PURE__ */
|
|
3125
|
+
/* @__PURE__ */ jsx21("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx21("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)" }) }),
|
|
3126
|
+
/* @__PURE__ */ jsx21("span", { className: "!text-sm font-medium", children: "Add photos & files" })
|
|
2662
3127
|
]
|
|
2663
3128
|
}
|
|
2664
3129
|
),
|
|
2665
|
-
onExpand && /* @__PURE__ */
|
|
3130
|
+
onExpand && /* @__PURE__ */ jsxs15(
|
|
2666
3131
|
"button",
|
|
2667
3132
|
{
|
|
2668
3133
|
onClick: () => {
|
|
@@ -2671,8 +3136,8 @@ function CommandComposer({
|
|
|
2671
3136
|
},
|
|
2672
3137
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left border-t border-neutral-700 dark:border-neutral-700",
|
|
2673
3138
|
children: [
|
|
2674
|
-
/* @__PURE__ */
|
|
2675
|
-
/* @__PURE__ */
|
|
3139
|
+
/* @__PURE__ */ jsx21("svg", { className: "w-4.5 h-4.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21("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" }) }),
|
|
3140
|
+
/* @__PURE__ */ jsx21("span", { className: "!text-sm font-medium", children: "Expand to chat" })
|
|
2676
3141
|
]
|
|
2677
3142
|
}
|
|
2678
3143
|
)
|
|
@@ -2681,30 +3146,22 @@ function CommandComposer({
|
|
|
2681
3146
|
)
|
|
2682
3147
|
] })
|
|
2683
3148
|
] }),
|
|
2684
|
-
state === "loading" && !toolName && /* @__PURE__ */
|
|
2685
|
-
state === "loading" && toolName && /* @__PURE__ */
|
|
3149
|
+
state === "loading" && !toolName && /* @__PURE__ */ jsx21("div", { className: "w-4 h-4 border-2 border-blue-200 border-t-blue-500 rounded-full animate-spin" }),
|
|
3150
|
+
state === "loading" && toolName && /* @__PURE__ */ jsx21("div", { className: "w-2 h-2 rounded-full bg-blue-500 animate-pulse" })
|
|
2686
3151
|
] }),
|
|
2687
|
-
pendingFiles.length > 0 && state === "idle" && /* @__PURE__ */
|
|
2688
|
-
"
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
children: /* @__PURE__ */ jsx18("svg", { className: "w-3 h-3 text-white", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx18("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
2701
|
-
}
|
|
2702
|
-
)
|
|
2703
|
-
]
|
|
2704
|
-
},
|
|
2705
|
-
index
|
|
2706
|
-
)) }),
|
|
2707
|
-
state === "idle" ? /* @__PURE__ */ jsx18(
|
|
3152
|
+
pendingFiles.length > 0 && state === "idle" && /* @__PURE__ */ jsx21("div", { className: "apteva-file-badges", children: pendingFiles.map((pf, index) => /* @__PURE__ */ jsxs15("div", { className: "apteva-file-badge", title: pf.file.name, children: [
|
|
3153
|
+
pf.preview ? /* @__PURE__ */ jsx21("img", { src: pf.preview, alt: pf.file.name, className: "apteva-file-badge-img" }) : /* @__PURE__ */ jsx21("span", { className: "apteva-file-badge-icon", children: getFileIcon(pf.file.type) }),
|
|
3154
|
+
/* @__PURE__ */ jsx21(
|
|
3155
|
+
"button",
|
|
3156
|
+
{
|
|
3157
|
+
onClick: () => removeFile(index),
|
|
3158
|
+
className: "apteva-file-badge-remove",
|
|
3159
|
+
title: "Remove",
|
|
3160
|
+
children: /* @__PURE__ */ jsx21("svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
3161
|
+
}
|
|
3162
|
+
)
|
|
3163
|
+
] }, index)) }),
|
|
3164
|
+
state === "idle" ? /* @__PURE__ */ jsx21(
|
|
2708
3165
|
"textarea",
|
|
2709
3166
|
{
|
|
2710
3167
|
ref: inputRef,
|
|
@@ -2722,7 +3179,7 @@ function CommandComposer({
|
|
|
2722
3179
|
),
|
|
2723
3180
|
style: { minHeight: "24px", maxHeight: "120px" }
|
|
2724
3181
|
}
|
|
2725
|
-
) : /* @__PURE__ */
|
|
3182
|
+
) : /* @__PURE__ */ jsx21(
|
|
2726
3183
|
"div",
|
|
2727
3184
|
{
|
|
2728
3185
|
className: cn(
|
|
@@ -2733,14 +3190,14 @@ function CommandComposer({
|
|
|
2733
3190
|
state === "error" && "!text-red-600 dark:!text-red-400",
|
|
2734
3191
|
state === "plan-pending" && "!text-amber-700 dark:!text-amber-300"
|
|
2735
3192
|
),
|
|
2736
|
-
children: isToolCall ? /* @__PURE__ */
|
|
2737
|
-
/* @__PURE__ */
|
|
2738
|
-
/* @__PURE__ */
|
|
3193
|
+
children: isToolCall ? /* @__PURE__ */ jsxs15(Fragment4, { children: [
|
|
3194
|
+
/* @__PURE__ */ jsx21("span", { className: "font-mono", children: displayContent }),
|
|
3195
|
+
/* @__PURE__ */ jsx21("span", { className: "text-neutral-400 dark:text-neutral-500", children: "Running..." })
|
|
2739
3196
|
] }) : displayContent
|
|
2740
3197
|
}
|
|
2741
3198
|
),
|
|
2742
|
-
/* @__PURE__ */
|
|
2743
|
-
/* @__PURE__ */
|
|
3199
|
+
/* @__PURE__ */ jsx21("div", { className: "w-8 h-8 flex items-center justify-center flex-shrink-0", children: state === "plan-pending" ? /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-1", children: [
|
|
3200
|
+
/* @__PURE__ */ jsx21(
|
|
2744
3201
|
"button",
|
|
2745
3202
|
{
|
|
2746
3203
|
onClick: onApprove,
|
|
@@ -2748,7 +3205,7 @@ function CommandComposer({
|
|
|
2748
3205
|
children: "Approve"
|
|
2749
3206
|
}
|
|
2750
3207
|
),
|
|
2751
|
-
/* @__PURE__ */
|
|
3208
|
+
/* @__PURE__ */ jsx21(
|
|
2752
3209
|
"button",
|
|
2753
3210
|
{
|
|
2754
3211
|
onClick: onReject,
|
|
@@ -2756,26 +3213,26 @@ function CommandComposer({
|
|
|
2756
3213
|
children: "Modify"
|
|
2757
3214
|
}
|
|
2758
3215
|
)
|
|
2759
|
-
] }) : /* @__PURE__ */
|
|
2760
|
-
state === "loading" && onStop && /* @__PURE__ */
|
|
3216
|
+
] }) : /* @__PURE__ */ jsxs15(Fragment4, { children: [
|
|
3217
|
+
state === "loading" && onStop && /* @__PURE__ */ jsx21(
|
|
2761
3218
|
"button",
|
|
2762
3219
|
{
|
|
2763
3220
|
onClick: onStop,
|
|
2764
3221
|
className: "apteva-composer-stop-btn",
|
|
2765
3222
|
title: "Stop generation",
|
|
2766
|
-
children: /* @__PURE__ */
|
|
3223
|
+
children: /* @__PURE__ */ jsx21("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx21("rect", { x: "2", y: "2", width: "10", height: "10", rx: "1", fill: "currentColor" }) })
|
|
2767
3224
|
}
|
|
2768
3225
|
),
|
|
2769
|
-
(state === "success" || state === "error") && /* @__PURE__ */
|
|
3226
|
+
(state === "success" || state === "error") && /* @__PURE__ */ jsx21(
|
|
2770
3227
|
"button",
|
|
2771
3228
|
{
|
|
2772
3229
|
onClick: handleNewCommand,
|
|
2773
3230
|
className: "w-8 h-8 rounded-lg flex items-center justify-center !text-neutral-400 hover:!text-neutral-600 dark:hover:!text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors",
|
|
2774
3231
|
title: "New command",
|
|
2775
|
-
children: /* @__PURE__ */
|
|
3232
|
+
children: /* @__PURE__ */ jsx21("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
2776
3233
|
}
|
|
2777
3234
|
),
|
|
2778
|
-
state === "idle" && /* @__PURE__ */
|
|
3235
|
+
state === "idle" && /* @__PURE__ */ jsx21(
|
|
2779
3236
|
"button",
|
|
2780
3237
|
{
|
|
2781
3238
|
onClick: handleSubmit,
|
|
@@ -2787,14 +3244,14 @@ function CommandComposer({
|
|
|
2787
3244
|
input.trim() || pendingFiles.length > 0 ? "bg-neutral-900 dark:bg-white !text-white dark:!text-neutral-900 border-neutral-900 dark:border-white" : "bg-white dark:bg-neutral-800 !text-neutral-400"
|
|
2788
3245
|
),
|
|
2789
3246
|
title: "Execute command",
|
|
2790
|
-
children: /* @__PURE__ */
|
|
3247
|
+
children: /* @__PURE__ */ jsx21("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx21("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 12h14M12 5l7 7-7 7" }) })
|
|
2791
3248
|
}
|
|
2792
3249
|
)
|
|
2793
3250
|
] }) })
|
|
2794
3251
|
]
|
|
2795
3252
|
}
|
|
2796
3253
|
),
|
|
2797
|
-
/* @__PURE__ */
|
|
3254
|
+
/* @__PURE__ */ jsx21(
|
|
2798
3255
|
"input",
|
|
2799
3256
|
{
|
|
2800
3257
|
ref: fileInputRef,
|
|
@@ -2809,22 +3266,20 @@ function CommandComposer({
|
|
|
2809
3266
|
}
|
|
2810
3267
|
|
|
2811
3268
|
// src/lib/apteva-client.ts
|
|
2812
|
-
var DEFAULT_API_URL = "http://91.99.200.48:3000/agents";
|
|
2813
|
-
var DEFAULT_API_KEY = "agt_894abd5966bc9f1e9f8f17f2a6f6b5e0";
|
|
2814
3269
|
var AptevaClient = class {
|
|
2815
|
-
constructor() {
|
|
3270
|
+
constructor(config) {
|
|
2816
3271
|
__publicField(this, "config");
|
|
2817
3272
|
this.config = {
|
|
2818
|
-
apiUrl:
|
|
2819
|
-
apiKey:
|
|
3273
|
+
apiUrl: config?.apiUrl ?? "",
|
|
3274
|
+
apiKey: config?.apiKey ?? ""
|
|
2820
3275
|
};
|
|
2821
3276
|
}
|
|
2822
3277
|
/**
|
|
2823
3278
|
* Update client configuration (optional - users can override defaults)
|
|
2824
3279
|
*/
|
|
2825
3280
|
configure(config) {
|
|
2826
|
-
if (config.apiUrl) this.config.apiUrl = config.apiUrl;
|
|
2827
|
-
if (config.apiKey) this.config.apiKey = config.apiKey;
|
|
3281
|
+
if (config.apiUrl !== void 0) this.config.apiUrl = config.apiUrl;
|
|
3282
|
+
if (config.apiKey !== void 0) this.config.apiKey = config.apiKey;
|
|
2828
3283
|
}
|
|
2829
3284
|
/**
|
|
2830
3285
|
* Get current configuration
|
|
@@ -2994,7 +3449,7 @@ var AptevaClient = class {
|
|
|
2994
3449
|
var aptevaClient = new AptevaClient();
|
|
2995
3450
|
|
|
2996
3451
|
// src/components/Chat/Chat.tsx
|
|
2997
|
-
import { Fragment as
|
|
3452
|
+
import { Fragment as Fragment5, jsx as jsx22, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2998
3453
|
var Chat = forwardRef(function Chat2({
|
|
2999
3454
|
agentId,
|
|
3000
3455
|
threadId,
|
|
@@ -3034,6 +3489,7 @@ var Chat = forwardRef(function Chat2({
|
|
|
3034
3489
|
placeholder,
|
|
3035
3490
|
showHeader = true,
|
|
3036
3491
|
headerTitle = "Chat",
|
|
3492
|
+
onHeaderBack,
|
|
3037
3493
|
// Widget detection
|
|
3038
3494
|
enableWidgets = false,
|
|
3039
3495
|
availableWidgets,
|
|
@@ -3148,7 +3604,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3148
3604
|
let responseThreadId = currentThreadId;
|
|
3149
3605
|
const toolInputBuffers = {};
|
|
3150
3606
|
const receivingTimeouts = {};
|
|
3151
|
-
const streamingMessageId = `msg-${Date.now()}`;
|
|
3607
|
+
const streamingMessageId = `msg-${Date.now()}-res`;
|
|
3152
3608
|
const updateMessage = () => {
|
|
3153
3609
|
const segments = [...contentSegments];
|
|
3154
3610
|
if (currentTextBuffer) {
|
|
@@ -3599,16 +4055,19 @@ ${planToExecute}`;
|
|
|
3599
4055
|
setCurrentRequestId(null);
|
|
3600
4056
|
};
|
|
3601
4057
|
const isCompact = commandVariant === "compact";
|
|
3602
|
-
return /* @__PURE__ */
|
|
3603
|
-
showHeader && mode === "chat" && /* @__PURE__ */
|
|
3604
|
-
/* @__PURE__ */
|
|
3605
|
-
/* @__PURE__ */
|
|
3606
|
-
"apteva-chat-
|
|
3607
|
-
|
|
3608
|
-
|
|
4058
|
+
return /* @__PURE__ */ jsxs16("div", { className: cn("apteva-chat flex flex-col h-full", variant !== "default" && `apteva-chat-${variant}`, className), children: [
|
|
4059
|
+
showHeader && mode === "chat" && /* @__PURE__ */ jsx22("div", { className: "apteva-chat-header px-4 py-3", children: /* @__PURE__ */ jsxs16("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
4060
|
+
onHeaderBack && /* @__PURE__ */ jsx22("button", { onClick: onHeaderBack, className: "apteva-chat-back", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx22("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx22("path", { d: "M10 12L6 8l4-4" }) }) }),
|
|
4061
|
+
/* @__PURE__ */ jsxs16("div", { children: [
|
|
4062
|
+
/* @__PURE__ */ jsx22("div", { className: "apteva-chat-title", children: headerTitle }),
|
|
4063
|
+
/* @__PURE__ */ jsx22("div", { className: cn(
|
|
4064
|
+
"apteva-chat-status",
|
|
4065
|
+
isLoading ? chatToolName ? "apteva-chat-status-tool" : "apteva-chat-status-thinking" : "apteva-chat-status-ready"
|
|
4066
|
+
), children: isLoading ? chatToolName ? `Using ${chatToolName}...` : "Thinking..." : "Ready" })
|
|
4067
|
+
] })
|
|
3609
4068
|
] }) }),
|
|
3610
|
-
mode === "chat" && /* @__PURE__ */
|
|
3611
|
-
/* @__PURE__ */
|
|
4069
|
+
mode === "chat" && /* @__PURE__ */ jsxs16(Fragment5, { children: [
|
|
4070
|
+
/* @__PURE__ */ jsx22(
|
|
3612
4071
|
MessageList,
|
|
3613
4072
|
{
|
|
3614
4073
|
messages,
|
|
@@ -3624,7 +4083,7 @@ ${planToExecute}`;
|
|
|
3624
4083
|
onWidgetRender
|
|
3625
4084
|
}
|
|
3626
4085
|
),
|
|
3627
|
-
/* @__PURE__ */
|
|
4086
|
+
/* @__PURE__ */ jsx22(
|
|
3628
4087
|
Composer,
|
|
3629
4088
|
{
|
|
3630
4089
|
onSendMessage: handleSendMessage,
|
|
@@ -3637,7 +4096,7 @@ ${planToExecute}`;
|
|
|
3637
4096
|
}
|
|
3638
4097
|
)
|
|
3639
4098
|
] }),
|
|
3640
|
-
mode === "command" && /* @__PURE__ */
|
|
4099
|
+
mode === "command" && /* @__PURE__ */ jsx22("div", { className: "w-full", children: /* @__PURE__ */ jsx22(
|
|
3641
4100
|
CommandComposer,
|
|
3642
4101
|
{
|
|
3643
4102
|
onExecute: (text, files) => {
|
|
@@ -3658,7 +4117,7 @@ ${planToExecute}`;
|
|
|
3658
4117
|
placeholder: placeholder || "Enter your command..."
|
|
3659
4118
|
}
|
|
3660
4119
|
) }),
|
|
3661
|
-
/* @__PURE__ */
|
|
4120
|
+
/* @__PURE__ */ jsx22("style", { dangerouslySetInnerHTML: {
|
|
3662
4121
|
__html: `
|
|
3663
4122
|
@keyframes pulse-border {
|
|
3664
4123
|
0%, 100% { border-color: rgb(59, 130, 246); }
|
|
@@ -3677,11 +4136,11 @@ ${planToExecute}`;
|
|
|
3677
4136
|
|
|
3678
4137
|
// src/components/Chat/CommandOutput.tsx
|
|
3679
4138
|
import { useState as useState7 } from "react";
|
|
3680
|
-
import { jsx as
|
|
4139
|
+
import { jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3681
4140
|
|
|
3682
4141
|
// src/components/Command/Command.tsx
|
|
3683
4142
|
import React, { useState as useState8, useEffect as useEffect7 } from "react";
|
|
3684
|
-
import { Fragment as
|
|
4143
|
+
import { Fragment as Fragment6, jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3685
4144
|
function Command({
|
|
3686
4145
|
agentId,
|
|
3687
4146
|
command: initialCommand,
|
|
@@ -4131,7 +4590,7 @@ ${planToExecute}`;
|
|
|
4131
4590
|
setUploadedFiles((prev) => prev.filter((_, i) => i !== index));
|
|
4132
4591
|
};
|
|
4133
4592
|
const isCompact = variant === "compact";
|
|
4134
|
-
return /* @__PURE__ */
|
|
4593
|
+
return /* @__PURE__ */ jsxs18(
|
|
4135
4594
|
"div",
|
|
4136
4595
|
{
|
|
4137
4596
|
className: cn(
|
|
@@ -4146,9 +4605,9 @@ ${planToExecute}`;
|
|
|
4146
4605
|
),
|
|
4147
4606
|
style: { minHeight: isCompact ? "auto" : "180px" },
|
|
4148
4607
|
children: [
|
|
4149
|
-
/* @__PURE__ */
|
|
4150
|
-
state === "idle" && allowInput && !isCompact && /* @__PURE__ */
|
|
4151
|
-
/* @__PURE__ */
|
|
4608
|
+
/* @__PURE__ */ jsxs18("div", { className: cn("flex-1 flex", isCompact ? "flex-row items-center p-3 gap-3" : "flex-col p-4"), children: [
|
|
4609
|
+
state === "idle" && allowInput && !isCompact && /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
4610
|
+
/* @__PURE__ */ jsx24(
|
|
4152
4611
|
"textarea",
|
|
4153
4612
|
{
|
|
4154
4613
|
value: command,
|
|
@@ -4164,42 +4623,42 @@ ${planToExecute}`;
|
|
|
4164
4623
|
rows: 6
|
|
4165
4624
|
}
|
|
4166
4625
|
),
|
|
4167
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
4168
|
-
file.type === "image" ? /* @__PURE__ */
|
|
4626
|
+
uploadedFiles.length > 0 && /* @__PURE__ */ jsx24("div", { className: "flex flex-wrap gap-2 mt-2", children: uploadedFiles.map((file, index) => /* @__PURE__ */ jsxs18("div", { className: "relative group", children: [
|
|
4627
|
+
file.type === "image" ? /* @__PURE__ */ jsx24(
|
|
4169
4628
|
"img",
|
|
4170
4629
|
{
|
|
4171
4630
|
src: file.preview,
|
|
4172
4631
|
alt: file.name,
|
|
4173
4632
|
className: "w-20 h-20 object-cover rounded-lg border-2 border-neutral-300 dark:border-neutral-600"
|
|
4174
4633
|
}
|
|
4175
|
-
) : /* @__PURE__ */
|
|
4176
|
-
/* @__PURE__ */
|
|
4177
|
-
/* @__PURE__ */
|
|
4634
|
+
) : /* @__PURE__ */ jsxs18("div", { className: "w-20 h-20 flex flex-col items-center justify-center rounded-lg border-2 border-neutral-300 dark:border-neutral-600 bg-neutral-50 dark:bg-neutral-800", children: [
|
|
4635
|
+
/* @__PURE__ */ jsx24("svg", { className: "w-8 h-8 text-neutral-500 dark:text-neutral-400", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx24("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" }) }),
|
|
4636
|
+
/* @__PURE__ */ jsx24("span", { className: "text-[8px] text-neutral-500 dark:text-neutral-400 mt-1 px-1 truncate max-w-full", children: file.name.length > 12 ? file.name.slice(0, 12) + "..." : file.name })
|
|
4178
4637
|
] }),
|
|
4179
|
-
/* @__PURE__ */
|
|
4638
|
+
/* @__PURE__ */ jsx24(
|
|
4180
4639
|
"button",
|
|
4181
4640
|
{
|
|
4182
4641
|
onClick: () => removeFile(index),
|
|
4183
4642
|
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",
|
|
4184
4643
|
title: `Remove ${file.type}`,
|
|
4185
|
-
children: /* @__PURE__ */
|
|
4644
|
+
children: /* @__PURE__ */ jsx24("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
4186
4645
|
}
|
|
4187
4646
|
)
|
|
4188
4647
|
] }, index)) })
|
|
4189
4648
|
] }),
|
|
4190
|
-
state === "idle" && allowInput && isCompact && /* @__PURE__ */
|
|
4191
|
-
/* @__PURE__ */
|
|
4192
|
-
enableFileUpload && /* @__PURE__ */
|
|
4649
|
+
state === "idle" && allowInput && isCompact && /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
4650
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-0.5 flex-shrink-0", children: [
|
|
4651
|
+
enableFileUpload && /* @__PURE__ */ jsx24(
|
|
4193
4652
|
"button",
|
|
4194
4653
|
{
|
|
4195
4654
|
onClick: () => fileInputRef.current?.click(),
|
|
4196
4655
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
4197
4656
|
title: "Attach file",
|
|
4198
|
-
children: /* @__PURE__ */
|
|
4657
|
+
children: /* @__PURE__ */ jsx24("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("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)" }) })
|
|
4199
4658
|
}
|
|
4200
4659
|
),
|
|
4201
|
-
planMode && /* @__PURE__ */
|
|
4202
|
-
/* @__PURE__ */
|
|
4660
|
+
planMode && /* @__PURE__ */ jsxs18("div", { className: "relative settings-menu-container", children: [
|
|
4661
|
+
/* @__PURE__ */ jsx24(
|
|
4203
4662
|
"button",
|
|
4204
4663
|
{
|
|
4205
4664
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -4208,28 +4667,28 @@ ${planToExecute}`;
|
|
|
4208
4667
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-neutral-500 dark:!text-neutral-500"
|
|
4209
4668
|
),
|
|
4210
4669
|
title: "Settings",
|
|
4211
|
-
children: /* @__PURE__ */
|
|
4212
|
-
/* @__PURE__ */
|
|
4213
|
-
/* @__PURE__ */
|
|
4214
|
-
/* @__PURE__ */
|
|
4215
|
-
/* @__PURE__ */
|
|
4216
|
-
/* @__PURE__ */
|
|
4217
|
-
/* @__PURE__ */
|
|
4218
|
-
/* @__PURE__ */
|
|
4219
|
-
/* @__PURE__ */
|
|
4220
|
-
/* @__PURE__ */
|
|
4670
|
+
children: /* @__PURE__ */ jsxs18("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4671
|
+
/* @__PURE__ */ jsx24("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
4672
|
+
/* @__PURE__ */ jsx24("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
4673
|
+
/* @__PURE__ */ jsx24("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
4674
|
+
/* @__PURE__ */ jsx24("line", { x1: "12", y1: "8", x2: "12", y2: "3" }),
|
|
4675
|
+
/* @__PURE__ */ jsx24("line", { x1: "20", y1: "21", x2: "20", y2: "16" }),
|
|
4676
|
+
/* @__PURE__ */ jsx24("line", { x1: "20", y1: "12", x2: "20", y2: "3" }),
|
|
4677
|
+
/* @__PURE__ */ jsx24("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
4678
|
+
/* @__PURE__ */ jsx24("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
4679
|
+
/* @__PURE__ */ jsx24("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
4221
4680
|
] })
|
|
4222
4681
|
}
|
|
4223
4682
|
),
|
|
4224
|
-
showSettingsMenu && /* @__PURE__ */
|
|
4225
|
-
/* @__PURE__ */
|
|
4226
|
-
/* @__PURE__ */
|
|
4227
|
-
/* @__PURE__ */
|
|
4228
|
-
/* @__PURE__ */
|
|
4229
|
-
/* @__PURE__ */
|
|
4683
|
+
showSettingsMenu && /* @__PURE__ */ jsx24("div", { className: "absolute top-10 left-0 z-50 w-56 bg-white dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-lg shadow-lg p-2.5 settings-menu-container", children: /* @__PURE__ */ jsxs18("label", { className: "flex items-center justify-between cursor-pointer group", children: [
|
|
4684
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
4685
|
+
/* @__PURE__ */ jsx24("svg", { className: "w-3.5 h-3.5 text-neutral-500 dark:text-neutral-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx24("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" }) }),
|
|
4686
|
+
/* @__PURE__ */ jsxs18("div", { children: [
|
|
4687
|
+
/* @__PURE__ */ jsx24("div", { className: "text-xs font-medium text-neutral-700 dark:text-neutral-300", children: "Plan Mode" }),
|
|
4688
|
+
/* @__PURE__ */ jsx24("div", { className: "text-[10px] text-neutral-500 dark:text-neutral-400", children: "Review first" })
|
|
4230
4689
|
] })
|
|
4231
4690
|
] }),
|
|
4232
|
-
/* @__PURE__ */
|
|
4691
|
+
/* @__PURE__ */ jsx24(
|
|
4233
4692
|
"button",
|
|
4234
4693
|
{
|
|
4235
4694
|
onClick: (e) => {
|
|
@@ -4241,7 +4700,7 @@ ${planToExecute}`;
|
|
|
4241
4700
|
internalPlanMode ? "bg-blue-600" : "bg-neutral-300 dark:bg-neutral-600"
|
|
4242
4701
|
),
|
|
4243
4702
|
type: "button",
|
|
4244
|
-
children: /* @__PURE__ */
|
|
4703
|
+
children: /* @__PURE__ */ jsx24(
|
|
4245
4704
|
"span",
|
|
4246
4705
|
{
|
|
4247
4706
|
className: cn(
|
|
@@ -4255,26 +4714,26 @@ ${planToExecute}`;
|
|
|
4255
4714
|
] }) })
|
|
4256
4715
|
] })
|
|
4257
4716
|
] }),
|
|
4258
|
-
uploadedFiles.length > 0 && /* @__PURE__ */
|
|
4259
|
-
file.type === "image" ? /* @__PURE__ */
|
|
4717
|
+
uploadedFiles.length > 0 && /* @__PURE__ */ jsx24("div", { className: "flex gap-1 flex-shrink-0", children: uploadedFiles.map((file, index) => /* @__PURE__ */ jsxs18("div", { className: "relative group", children: [
|
|
4718
|
+
file.type === "image" ? /* @__PURE__ */ jsx24(
|
|
4260
4719
|
"img",
|
|
4261
4720
|
{
|
|
4262
4721
|
src: file.preview,
|
|
4263
4722
|
alt: file.name,
|
|
4264
4723
|
className: "w-8 h-8 object-cover rounded border border-neutral-300 dark:border-neutral-600"
|
|
4265
4724
|
}
|
|
4266
|
-
) : /* @__PURE__ */
|
|
4267
|
-
/* @__PURE__ */
|
|
4725
|
+
) : /* @__PURE__ */ jsx24("div", { className: "w-8 h-8 flex items-center justify-center rounded border border-neutral-300 dark:border-neutral-600 bg-neutral-50 dark:bg-neutral-800", title: file.name, children: /* @__PURE__ */ jsx24("svg", { className: "w-4 h-4 text-neutral-500 dark:text-neutral-400", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx24("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" }) }) }),
|
|
4726
|
+
/* @__PURE__ */ jsx24(
|
|
4268
4727
|
"button",
|
|
4269
4728
|
{
|
|
4270
4729
|
onClick: () => removeFile(index),
|
|
4271
4730
|
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",
|
|
4272
4731
|
title: "Remove",
|
|
4273
|
-
children: /* @__PURE__ */
|
|
4732
|
+
children: /* @__PURE__ */ jsx24("svg", { className: "w-2.5 h-2.5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 3, children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
|
|
4274
4733
|
}
|
|
4275
4734
|
)
|
|
4276
4735
|
] }, index)) }),
|
|
4277
|
-
/* @__PURE__ */
|
|
4736
|
+
/* @__PURE__ */ jsx24(
|
|
4278
4737
|
"input",
|
|
4279
4738
|
{
|
|
4280
4739
|
type: "text",
|
|
@@ -4290,7 +4749,7 @@ ${planToExecute}`;
|
|
|
4290
4749
|
className: "flex-1 bg-transparent border-none focus:outline-none !text-neutral-900 dark:!text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 py-1"
|
|
4291
4750
|
}
|
|
4292
4751
|
),
|
|
4293
|
-
/* @__PURE__ */
|
|
4752
|
+
/* @__PURE__ */ jsx24(
|
|
4294
4753
|
"button",
|
|
4295
4754
|
{
|
|
4296
4755
|
onClick: () => executeCommand(),
|
|
@@ -4306,33 +4765,33 @@ ${planToExecute}`;
|
|
|
4306
4765
|
!command.trim() && "border-neutral-200 dark:border-neutral-700 !text-neutral-400 dark:!text-neutral-600"
|
|
4307
4766
|
),
|
|
4308
4767
|
title: "Execute",
|
|
4309
|
-
children: /* @__PURE__ */
|
|
4768
|
+
children: /* @__PURE__ */ jsx24("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
4310
4769
|
}
|
|
4311
4770
|
)
|
|
4312
4771
|
] }),
|
|
4313
|
-
state === "loading" && !isCompact && /* @__PURE__ */
|
|
4314
|
-
/* @__PURE__ */
|
|
4315
|
-
/* @__PURE__ */
|
|
4316
|
-
showProgress && /* @__PURE__ */
|
|
4317
|
-
/* @__PURE__ */
|
|
4772
|
+
state === "loading" && !isCompact && /* @__PURE__ */ jsxs18("div", { className: "flex-1 flex flex-col items-center justify-center space-y-4 py-8", children: [
|
|
4773
|
+
/* @__PURE__ */ jsx24("div", { className: "w-6 h-6 border-2 border-neutral-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
4774
|
+
/* @__PURE__ */ jsx24("div", { className: "text-neutral-600 dark:text-neutral-400 text-sm text-center max-w-md", children: enableStreaming && streamedContent ? streamedContent : loadingText }),
|
|
4775
|
+
showProgress && /* @__PURE__ */ jsxs18("div", { className: "w-full max-w-sm", children: [
|
|
4776
|
+
/* @__PURE__ */ jsx24("div", { className: "w-full bg-neutral-200 dark:bg-neutral-700 rounded-full h-1.5", children: /* @__PURE__ */ jsx24(
|
|
4318
4777
|
"div",
|
|
4319
4778
|
{
|
|
4320
4779
|
className: "bg-blue-500 h-1.5 rounded-full transition-all duration-300",
|
|
4321
4780
|
style: { width: `${progress}%` }
|
|
4322
4781
|
}
|
|
4323
4782
|
) }),
|
|
4324
|
-
/* @__PURE__ */
|
|
4783
|
+
/* @__PURE__ */ jsxs18("p", { className: "text-xs text-neutral-500 mt-2 text-center", children: [
|
|
4325
4784
|
progress,
|
|
4326
4785
|
"%"
|
|
4327
4786
|
] })
|
|
4328
4787
|
] })
|
|
4329
4788
|
] }),
|
|
4330
|
-
state === "loading" && isCompact && /* @__PURE__ */
|
|
4331
|
-
/* @__PURE__ */
|
|
4332
|
-
/* @__PURE__ */
|
|
4333
|
-
/* @__PURE__ */
|
|
4789
|
+
state === "loading" && isCompact && /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
4790
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1 flex items-center gap-3 py-1", children: [
|
|
4791
|
+
/* @__PURE__ */ jsx24("div", { className: "w-4 h-4 border-2 border-neutral-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
4792
|
+
/* @__PURE__ */ jsx24("div", { className: "text-neutral-600 dark:text-neutral-400 text-sm truncate", children: enableStreaming && streamedContent ? streamedContent : loadingText })
|
|
4334
4793
|
] }),
|
|
4335
|
-
/* @__PURE__ */
|
|
4794
|
+
/* @__PURE__ */ jsx24(
|
|
4336
4795
|
"button",
|
|
4337
4796
|
{
|
|
4338
4797
|
disabled: true,
|
|
@@ -4344,20 +4803,20 @@ ${planToExecute}`;
|
|
|
4344
4803
|
"!text-lg",
|
|
4345
4804
|
"opacity-30 cursor-not-allowed"
|
|
4346
4805
|
),
|
|
4347
|
-
children: /* @__PURE__ */
|
|
4806
|
+
children: /* @__PURE__ */ jsx24("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
4348
4807
|
}
|
|
4349
4808
|
)
|
|
4350
4809
|
] }),
|
|
4351
|
-
state === "plan-pending" && !isCompact && /* @__PURE__ */
|
|
4352
|
-
/* @__PURE__ */
|
|
4353
|
-
/* @__PURE__ */
|
|
4354
|
-
/* @__PURE__ */
|
|
4355
|
-
/* @__PURE__ */
|
|
4356
|
-
/* @__PURE__ */
|
|
4810
|
+
state === "plan-pending" && !isCompact && /* @__PURE__ */ jsx24("div", { className: "flex-1 flex flex-col", children: /* @__PURE__ */ jsxs18("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: [
|
|
4811
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-start gap-2 mb-3", children: [
|
|
4812
|
+
/* @__PURE__ */ jsx24("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__ */ jsx24("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" }) }),
|
|
4813
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1", children: [
|
|
4814
|
+
/* @__PURE__ */ jsx24("h3", { className: "text-sm font-semibold text-blue-800 dark:text-blue-300 mb-1", children: "Proposed Plan" }),
|
|
4815
|
+
/* @__PURE__ */ jsx24("div", { className: "text-blue-700 dark:text-blue-300 text-sm whitespace-pre-line leading-relaxed", children: plan })
|
|
4357
4816
|
] })
|
|
4358
4817
|
] }),
|
|
4359
|
-
/* @__PURE__ */
|
|
4360
|
-
/* @__PURE__ */
|
|
4818
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex gap-2 mt-4", children: [
|
|
4819
|
+
/* @__PURE__ */ jsx24(
|
|
4361
4820
|
"button",
|
|
4362
4821
|
{
|
|
4363
4822
|
onClick: approvePlan,
|
|
@@ -4365,7 +4824,7 @@ ${planToExecute}`;
|
|
|
4365
4824
|
children: "Approve & Execute"
|
|
4366
4825
|
}
|
|
4367
4826
|
),
|
|
4368
|
-
/* @__PURE__ */
|
|
4827
|
+
/* @__PURE__ */ jsx24(
|
|
4369
4828
|
"button",
|
|
4370
4829
|
{
|
|
4371
4830
|
onClick: rejectPlan,
|
|
@@ -4375,20 +4834,20 @@ ${planToExecute}`;
|
|
|
4375
4834
|
)
|
|
4376
4835
|
] })
|
|
4377
4836
|
] }) }),
|
|
4378
|
-
state === "plan-pending" && isCompact && /* @__PURE__ */
|
|
4379
|
-
/* @__PURE__ */
|
|
4837
|
+
state === "plan-pending" && isCompact && /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
4838
|
+
/* @__PURE__ */ jsxs18(
|
|
4380
4839
|
"button",
|
|
4381
4840
|
{
|
|
4382
4841
|
onClick: () => setShowPlanDetails(true),
|
|
4383
4842
|
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",
|
|
4384
4843
|
children: [
|
|
4385
|
-
/* @__PURE__ */
|
|
4386
|
-
/* @__PURE__ */
|
|
4844
|
+
/* @__PURE__ */ jsx24("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__ */ jsx24("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" }) }),
|
|
4845
|
+
/* @__PURE__ */ jsx24("span", { className: "text-sm font-medium text-blue-700 dark:text-blue-300 truncate flex-1", children: "View Execution Plan" })
|
|
4387
4846
|
]
|
|
4388
4847
|
}
|
|
4389
4848
|
),
|
|
4390
|
-
/* @__PURE__ */
|
|
4391
|
-
/* @__PURE__ */
|
|
4849
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex gap-2 flex-shrink-0", children: [
|
|
4850
|
+
/* @__PURE__ */ jsx24(
|
|
4392
4851
|
"button",
|
|
4393
4852
|
{
|
|
4394
4853
|
onClick: approvePlan,
|
|
@@ -4396,7 +4855,7 @@ ${planToExecute}`;
|
|
|
4396
4855
|
children: "Approve"
|
|
4397
4856
|
}
|
|
4398
4857
|
),
|
|
4399
|
-
/* @__PURE__ */
|
|
4858
|
+
/* @__PURE__ */ jsx24(
|
|
4400
4859
|
"button",
|
|
4401
4860
|
{
|
|
4402
4861
|
onClick: rejectPlan,
|
|
@@ -4406,15 +4865,15 @@ ${planToExecute}`;
|
|
|
4406
4865
|
)
|
|
4407
4866
|
] })
|
|
4408
4867
|
] }),
|
|
4409
|
-
state === "error" && /* @__PURE__ */
|
|
4410
|
-
/* @__PURE__ */
|
|
4411
|
-
/* @__PURE__ */
|
|
4412
|
-
/* @__PURE__ */
|
|
4413
|
-
/* @__PURE__ */
|
|
4414
|
-
/* @__PURE__ */
|
|
4868
|
+
state === "error" && /* @__PURE__ */ jsxs18("div", { className: "flex-1 flex flex-col", children: [
|
|
4869
|
+
/* @__PURE__ */ jsx24("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__ */ jsxs18("div", { className: "flex items-start gap-2", children: [
|
|
4870
|
+
/* @__PURE__ */ jsx24("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__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
4871
|
+
/* @__PURE__ */ jsxs18("div", { children: [
|
|
4872
|
+
/* @__PURE__ */ jsx24("h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
|
|
4873
|
+
/* @__PURE__ */ jsx24("p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: error?.message })
|
|
4415
4874
|
] })
|
|
4416
4875
|
] }) }),
|
|
4417
|
-
allowInput && /* @__PURE__ */
|
|
4876
|
+
allowInput && /* @__PURE__ */ jsx24(
|
|
4418
4877
|
"textarea",
|
|
4419
4878
|
{
|
|
4420
4879
|
value: command,
|
|
@@ -4431,16 +4890,16 @@ ${planToExecute}`;
|
|
|
4431
4890
|
}
|
|
4432
4891
|
)
|
|
4433
4892
|
] }),
|
|
4434
|
-
state === "success" && result && !isCompact && /* @__PURE__ */
|
|
4435
|
-
/* @__PURE__ */
|
|
4436
|
-
/* @__PURE__ */
|
|
4437
|
-
/* @__PURE__ */
|
|
4438
|
-
/* @__PURE__ */
|
|
4439
|
-
/* @__PURE__ */
|
|
4893
|
+
state === "success" && result && !isCompact && /* @__PURE__ */ jsx24("div", { className: "flex-1 overflow-auto", children: resultRenderer ? resultRenderer(result.data) : /* @__PURE__ */ jsxs18("div", { className: "space-y-4", children: [
|
|
4894
|
+
/* @__PURE__ */ jsxs18("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: [
|
|
4895
|
+
/* @__PURE__ */ jsx24("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__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
4896
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex-1", children: [
|
|
4897
|
+
/* @__PURE__ */ jsx24("h3", { className: "text-sm font-semibold text-green-800 dark:text-green-400 mb-1", children: "Success" }),
|
|
4898
|
+
/* @__PURE__ */ jsx24("p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
4440
4899
|
] })
|
|
4441
4900
|
] }),
|
|
4442
|
-
result.data?.summary && /* @__PURE__ */
|
|
4443
|
-
result.widgets && result.widgets.length > 0 && /* @__PURE__ */
|
|
4901
|
+
result.data?.summary && /* @__PURE__ */ jsx24("div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
|
|
4902
|
+
result.widgets && result.widgets.length > 0 && /* @__PURE__ */ jsx24("div", { className: "space-y-3", children: result.widgets.map((widget) => /* @__PURE__ */ jsx24(
|
|
4444
4903
|
WidgetRenderer,
|
|
4445
4904
|
{
|
|
4446
4905
|
widget,
|
|
@@ -4449,8 +4908,8 @@ ${planToExecute}`;
|
|
|
4449
4908
|
widget.id
|
|
4450
4909
|
)) })
|
|
4451
4910
|
] }) }),
|
|
4452
|
-
state === "success" && result && isCompact && /* @__PURE__ */
|
|
4453
|
-
/* @__PURE__ */
|
|
4911
|
+
state === "success" && result && isCompact && /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
4912
|
+
/* @__PURE__ */ jsxs18(
|
|
4454
4913
|
"div",
|
|
4455
4914
|
{
|
|
4456
4915
|
className: "flex-1 flex items-center gap-2 py-1 cursor-text min-w-0",
|
|
@@ -4459,12 +4918,12 @@ ${planToExecute}`;
|
|
|
4459
4918
|
setResult(null);
|
|
4460
4919
|
},
|
|
4461
4920
|
children: [
|
|
4462
|
-
/* @__PURE__ */
|
|
4463
|
-
/* @__PURE__ */
|
|
4921
|
+
/* @__PURE__ */ jsx24("svg", { className: "w-4 h-4 text-green-600 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
4922
|
+
/* @__PURE__ */ jsx24("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" })
|
|
4464
4923
|
]
|
|
4465
4924
|
}
|
|
4466
4925
|
),
|
|
4467
|
-
/* @__PURE__ */
|
|
4926
|
+
/* @__PURE__ */ jsx24(
|
|
4468
4927
|
"button",
|
|
4469
4928
|
{
|
|
4470
4929
|
onClick: () => {
|
|
@@ -4480,24 +4939,24 @@ ${planToExecute}`;
|
|
|
4480
4939
|
"!text-lg"
|
|
4481
4940
|
),
|
|
4482
4941
|
title: "New command",
|
|
4483
|
-
children: /* @__PURE__ */
|
|
4942
|
+
children: /* @__PURE__ */ jsx24("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
4484
4943
|
}
|
|
4485
4944
|
)
|
|
4486
4945
|
] })
|
|
4487
4946
|
] }),
|
|
4488
|
-
!isCompact && /* @__PURE__ */
|
|
4489
|
-
/* @__PURE__ */
|
|
4490
|
-
enableFileUpload && /* @__PURE__ */
|
|
4947
|
+
!isCompact && /* @__PURE__ */ jsxs18("div", { className: "p-3 flex items-center justify-between gap-2", children: [
|
|
4948
|
+
/* @__PURE__ */ jsx24("div", { className: "flex items-center gap-1", children: state === "idle" && allowInput && /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
4949
|
+
enableFileUpload && /* @__PURE__ */ jsx24(
|
|
4491
4950
|
"button",
|
|
4492
4951
|
{
|
|
4493
4952
|
onClick: () => fileInputRef.current?.click(),
|
|
4494
4953
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
4495
4954
|
title: "Attach file",
|
|
4496
|
-
children: /* @__PURE__ */
|
|
4955
|
+
children: /* @__PURE__ */ jsx24("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("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)" }) })
|
|
4497
4956
|
}
|
|
4498
4957
|
),
|
|
4499
|
-
planMode && /* @__PURE__ */
|
|
4500
|
-
/* @__PURE__ */
|
|
4958
|
+
planMode && /* @__PURE__ */ jsxs18("div", { className: "relative settings-menu-container", children: [
|
|
4959
|
+
/* @__PURE__ */ jsx24(
|
|
4501
4960
|
"button",
|
|
4502
4961
|
{
|
|
4503
4962
|
onClick: () => setShowSettingsMenu(!showSettingsMenu),
|
|
@@ -4506,28 +4965,28 @@ ${planToExecute}`;
|
|
|
4506
4965
|
internalPlanMode ? "!text-blue-600 dark:!text-blue-400" : "!text-neutral-500 dark:!text-neutral-500"
|
|
4507
4966
|
),
|
|
4508
4967
|
title: "Settings",
|
|
4509
|
-
children: /* @__PURE__ */
|
|
4510
|
-
/* @__PURE__ */
|
|
4511
|
-
/* @__PURE__ */
|
|
4512
|
-
/* @__PURE__ */
|
|
4513
|
-
/* @__PURE__ */
|
|
4514
|
-
/* @__PURE__ */
|
|
4515
|
-
/* @__PURE__ */
|
|
4516
|
-
/* @__PURE__ */
|
|
4517
|
-
/* @__PURE__ */
|
|
4518
|
-
/* @__PURE__ */
|
|
4968
|
+
children: /* @__PURE__ */ jsxs18("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4969
|
+
/* @__PURE__ */ jsx24("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
4970
|
+
/* @__PURE__ */ jsx24("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
4971
|
+
/* @__PURE__ */ jsx24("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
4972
|
+
/* @__PURE__ */ jsx24("line", { x1: "12", y1: "8", x2: "12", y2: "3" }),
|
|
4973
|
+
/* @__PURE__ */ jsx24("line", { x1: "20", y1: "21", x2: "20", y2: "16" }),
|
|
4974
|
+
/* @__PURE__ */ jsx24("line", { x1: "20", y1: "12", x2: "20", y2: "3" }),
|
|
4975
|
+
/* @__PURE__ */ jsx24("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
4976
|
+
/* @__PURE__ */ jsx24("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
4977
|
+
/* @__PURE__ */ jsx24("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
4519
4978
|
] })
|
|
4520
4979
|
}
|
|
4521
4980
|
),
|
|
4522
|
-
showSettingsMenu && /* @__PURE__ */
|
|
4523
|
-
/* @__PURE__ */
|
|
4524
|
-
/* @__PURE__ */
|
|
4525
|
-
/* @__PURE__ */
|
|
4526
|
-
/* @__PURE__ */
|
|
4527
|
-
/* @__PURE__ */
|
|
4981
|
+
showSettingsMenu && /* @__PURE__ */ jsx24("div", { className: "absolute top-10 left-0 z-50 w-64 bg-white dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-lg shadow-lg p-3 settings-menu-container", children: /* @__PURE__ */ jsxs18("label", { className: "flex items-center justify-between cursor-pointer group", children: [
|
|
4982
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
4983
|
+
/* @__PURE__ */ jsx24("svg", { className: "w-4 h-4 text-neutral-500 dark:text-neutral-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx24("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" }) }),
|
|
4984
|
+
/* @__PURE__ */ jsxs18("div", { children: [
|
|
4985
|
+
/* @__PURE__ */ jsx24("div", { className: "text-sm font-medium text-neutral-700 dark:text-neutral-300", children: "Plan Mode" }),
|
|
4986
|
+
/* @__PURE__ */ jsx24("div", { className: "text-xs text-neutral-500 dark:text-neutral-400", children: "Review before executing" })
|
|
4528
4987
|
] })
|
|
4529
4988
|
] }),
|
|
4530
|
-
/* @__PURE__ */
|
|
4989
|
+
/* @__PURE__ */ jsx24(
|
|
4531
4990
|
"button",
|
|
4532
4991
|
{
|
|
4533
4992
|
onClick: (e) => {
|
|
@@ -4539,7 +4998,7 @@ ${planToExecute}`;
|
|
|
4539
4998
|
internalPlanMode ? "bg-blue-600" : "bg-neutral-300 dark:bg-neutral-600"
|
|
4540
4999
|
),
|
|
4541
5000
|
type: "button",
|
|
4542
|
-
children: /* @__PURE__ */
|
|
5001
|
+
children: /* @__PURE__ */ jsx24(
|
|
4543
5002
|
"span",
|
|
4544
5003
|
{
|
|
4545
5004
|
className: cn(
|
|
@@ -4553,9 +5012,9 @@ ${planToExecute}`;
|
|
|
4553
5012
|
] }) })
|
|
4554
5013
|
] })
|
|
4555
5014
|
] }) }),
|
|
4556
|
-
!(state === "idle" && allowInput) && /* @__PURE__ */
|
|
4557
|
-
/* @__PURE__ */
|
|
4558
|
-
(state === "success" || state === "error") && allowInput && /* @__PURE__ */
|
|
5015
|
+
!(state === "idle" && allowInput) && /* @__PURE__ */ jsx24("div", {}),
|
|
5016
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
|
|
5017
|
+
(state === "success" || state === "error") && allowInput && /* @__PURE__ */ jsx24(
|
|
4559
5018
|
"button",
|
|
4560
5019
|
{
|
|
4561
5020
|
onClick: resetCommand,
|
|
@@ -4563,7 +5022,7 @@ ${planToExecute}`;
|
|
|
4563
5022
|
children: "Reset"
|
|
4564
5023
|
}
|
|
4565
5024
|
),
|
|
4566
|
-
(state === "idle" || state === "error") && /* @__PURE__ */
|
|
5025
|
+
(state === "idle" || state === "error") && /* @__PURE__ */ jsx24(
|
|
4567
5026
|
"button",
|
|
4568
5027
|
{
|
|
4569
5028
|
onClick: () => executeCommand(),
|
|
@@ -4579,29 +5038,29 @@ ${planToExecute}`;
|
|
|
4579
5038
|
!command.trim() && "border-neutral-200 dark:border-neutral-700 !text-neutral-400 dark:!text-neutral-600"
|
|
4580
5039
|
),
|
|
4581
5040
|
title: state === "error" ? "Retry" : "Execute",
|
|
4582
|
-
children: state === "error" ? /* @__PURE__ */
|
|
5041
|
+
children: state === "error" ? /* @__PURE__ */ jsx24("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("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__ */ jsx24("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx24("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
4583
5042
|
}
|
|
4584
5043
|
)
|
|
4585
5044
|
] })
|
|
4586
5045
|
] }),
|
|
4587
|
-
showPlanDetails && isCompact && state === "plan-pending" && /* @__PURE__ */
|
|
4588
|
-
/* @__PURE__ */
|
|
4589
|
-
/* @__PURE__ */
|
|
4590
|
-
/* @__PURE__ */
|
|
4591
|
-
/* @__PURE__ */
|
|
5046
|
+
showPlanDetails && isCompact && state === "plan-pending" && /* @__PURE__ */ jsx24("div", { className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4", onClick: () => setShowPlanDetails(false), children: /* @__PURE__ */ jsxs18("div", { className: "bg-white dark:bg-neutral-900 rounded-2xl shadow-2xl max-w-2xl w-full max-h-[80vh] overflow-hidden", onClick: (e) => e.stopPropagation(), children: [
|
|
5047
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center justify-between p-6 border-b border-neutral-200 dark:border-neutral-700", children: [
|
|
5048
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-3", children: [
|
|
5049
|
+
/* @__PURE__ */ jsx24("svg", { className: "w-6 h-6 text-blue-600 dark:text-blue-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx24("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" }) }),
|
|
5050
|
+
/* @__PURE__ */ jsx24("h2", { className: "text-xl font-semibold text-neutral-900 dark:text-white", children: "Proposed Execution Plan" })
|
|
4592
5051
|
] }),
|
|
4593
|
-
/* @__PURE__ */
|
|
5052
|
+
/* @__PURE__ */ jsx24(
|
|
4594
5053
|
"button",
|
|
4595
5054
|
{
|
|
4596
5055
|
onClick: () => setShowPlanDetails(false),
|
|
4597
5056
|
className: "text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 transition-colors",
|
|
4598
|
-
children: /* @__PURE__ */
|
|
5057
|
+
children: /* @__PURE__ */ jsx24("svg", { className: "w-6 h-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx24("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
4599
5058
|
}
|
|
4600
5059
|
)
|
|
4601
5060
|
] }),
|
|
4602
|
-
/* @__PURE__ */
|
|
4603
|
-
/* @__PURE__ */
|
|
4604
|
-
/* @__PURE__ */
|
|
5061
|
+
/* @__PURE__ */ jsx24("div", { className: "p-6 overflow-y-auto max-h-[calc(80vh-180px)]", children: /* @__PURE__ */ jsx24("div", { className: "prose prose-sm dark:prose-invert max-w-none", children: /* @__PURE__ */ jsx24("div", { className: "text-neutral-700 dark:text-neutral-300 whitespace-pre-line leading-relaxed", children: plan }) }) }),
|
|
5062
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex items-center justify-end gap-3 p-6 border-t border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800/50", children: [
|
|
5063
|
+
/* @__PURE__ */ jsx24(
|
|
4605
5064
|
"button",
|
|
4606
5065
|
{
|
|
4607
5066
|
onClick: rejectPlan,
|
|
@@ -4609,7 +5068,7 @@ ${planToExecute}`;
|
|
|
4609
5068
|
children: "Modify Command"
|
|
4610
5069
|
}
|
|
4611
5070
|
),
|
|
4612
|
-
/* @__PURE__ */
|
|
5071
|
+
/* @__PURE__ */ jsx24(
|
|
4613
5072
|
"button",
|
|
4614
5073
|
{
|
|
4615
5074
|
onClick: approvePlan,
|
|
@@ -4619,7 +5078,7 @@ ${planToExecute}`;
|
|
|
4619
5078
|
)
|
|
4620
5079
|
] })
|
|
4621
5080
|
] }) }),
|
|
4622
|
-
/* @__PURE__ */
|
|
5081
|
+
/* @__PURE__ */ jsx24(
|
|
4623
5082
|
"input",
|
|
4624
5083
|
{
|
|
4625
5084
|
ref: fileInputRef,
|
|
@@ -4630,7 +5089,7 @@ ${planToExecute}`;
|
|
|
4630
5089
|
accept: "image/*,application/pdf,.doc,.docx,.txt"
|
|
4631
5090
|
}
|
|
4632
5091
|
),
|
|
4633
|
-
/* @__PURE__ */
|
|
5092
|
+
/* @__PURE__ */ jsx24("style", { dangerouslySetInnerHTML: {
|
|
4634
5093
|
__html: `
|
|
4635
5094
|
@keyframes pulse-border {
|
|
4636
5095
|
0%, 100% {
|
|
@@ -4652,7 +5111,7 @@ ${planToExecute}`;
|
|
|
4652
5111
|
|
|
4653
5112
|
// src/components/Prompt/Prompt.tsx
|
|
4654
5113
|
import { useState as useState9 } from "react";
|
|
4655
|
-
import { jsx as
|
|
5114
|
+
import { jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4656
5115
|
function Prompt({
|
|
4657
5116
|
agentId,
|
|
4658
5117
|
placeholder = "Enter your prompt...",
|
|
@@ -4714,9 +5173,9 @@ function Prompt({
|
|
|
4714
5173
|
handleSubmit();
|
|
4715
5174
|
}
|
|
4716
5175
|
};
|
|
4717
|
-
return /* @__PURE__ */
|
|
4718
|
-
/* @__PURE__ */
|
|
4719
|
-
/* @__PURE__ */
|
|
5176
|
+
return /* @__PURE__ */ jsxs19("div", { className: cn("space-y-2", className), children: [
|
|
5177
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex gap-2", children: [
|
|
5178
|
+
/* @__PURE__ */ jsx25(
|
|
4720
5179
|
"input",
|
|
4721
5180
|
{
|
|
4722
5181
|
type: "text",
|
|
@@ -4729,7 +5188,7 @@ function Prompt({
|
|
|
4729
5188
|
className: "flex-1 px-4 py-2 border border-neutral-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-apteva-500 dark:bg-neutral-800 dark:border-neutral-600 dark:text-white"
|
|
4730
5189
|
}
|
|
4731
5190
|
),
|
|
4732
|
-
submitOn === "button" && /* @__PURE__ */
|
|
5191
|
+
submitOn === "button" && /* @__PURE__ */ jsx25(
|
|
4733
5192
|
"button",
|
|
4734
5193
|
{
|
|
4735
5194
|
onClick: handleSubmit,
|
|
@@ -4739,13 +5198,13 @@ function Prompt({
|
|
|
4739
5198
|
}
|
|
4740
5199
|
)
|
|
4741
5200
|
] }),
|
|
4742
|
-
maxLength && /* @__PURE__ */
|
|
5201
|
+
maxLength && /* @__PURE__ */ jsxs19("p", { className: "text-xs text-neutral-500", children: [
|
|
4743
5202
|
value.length,
|
|
4744
5203
|
" / ",
|
|
4745
5204
|
maxLength,
|
|
4746
5205
|
" characters"
|
|
4747
5206
|
] }),
|
|
4748
|
-
showSuggestions && !value && /* @__PURE__ */
|
|
5207
|
+
showSuggestions && !value && /* @__PURE__ */ jsx25("div", { className: "flex flex-wrap gap-2", children: suggestions.map((suggestion, idx) => /* @__PURE__ */ jsx25(
|
|
4749
5208
|
"button",
|
|
4750
5209
|
{
|
|
4751
5210
|
onClick: () => setValue(suggestion),
|
|
@@ -4754,16 +5213,16 @@ function Prompt({
|
|
|
4754
5213
|
},
|
|
4755
5214
|
idx
|
|
4756
5215
|
)) }),
|
|
4757
|
-
isLoading && /* @__PURE__ */
|
|
4758
|
-
/* @__PURE__ */
|
|
4759
|
-
/* @__PURE__ */
|
|
5216
|
+
isLoading && /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2 text-sm text-neutral-500", children: [
|
|
5217
|
+
/* @__PURE__ */ jsx25("div", { className: "w-4 h-4 border-2 border-apteva-500 border-t-transparent rounded-full animate-spin" }),
|
|
5218
|
+
/* @__PURE__ */ jsx25("span", { children: "AI is processing your request..." })
|
|
4760
5219
|
] })
|
|
4761
5220
|
] });
|
|
4762
5221
|
}
|
|
4763
5222
|
|
|
4764
5223
|
// src/components/Stream/Stream.tsx
|
|
4765
5224
|
import { useState as useState10, useEffect as useEffect8 } from "react";
|
|
4766
|
-
import { jsx as
|
|
5225
|
+
import { jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4767
5226
|
function Stream({
|
|
4768
5227
|
agentId,
|
|
4769
5228
|
prompt,
|
|
@@ -4843,7 +5302,7 @@ function Stream({
|
|
|
4843
5302
|
plain: "text-neutral-900 dark:text-neutral-100"
|
|
4844
5303
|
};
|
|
4845
5304
|
if (!isStreaming && !isComplete) {
|
|
4846
|
-
return /* @__PURE__ */
|
|
5305
|
+
return /* @__PURE__ */ jsx26("div", { className: cn("p-4", className), children: /* @__PURE__ */ jsx26(
|
|
4847
5306
|
"button",
|
|
4848
5307
|
{
|
|
4849
5308
|
onClick: startStreaming,
|
|
@@ -4852,9 +5311,9 @@ function Stream({
|
|
|
4852
5311
|
}
|
|
4853
5312
|
) });
|
|
4854
5313
|
}
|
|
4855
|
-
return /* @__PURE__ */
|
|
5314
|
+
return /* @__PURE__ */ jsxs20("div", { className: cn(variantClasses[variant], className), children: [
|
|
4856
5315
|
text,
|
|
4857
|
-
isStreaming && showCursor && /* @__PURE__ */
|
|
5316
|
+
isStreaming && showCursor && /* @__PURE__ */ jsx26("span", { className: "apteva-stream-cursor" })
|
|
4858
5317
|
] });
|
|
4859
5318
|
}
|
|
4860
5319
|
|
|
@@ -4862,9 +5321,9 @@ function Stream({
|
|
|
4862
5321
|
import { useState as useState11 } from "react";
|
|
4863
5322
|
|
|
4864
5323
|
// src/components/Threads/ThreadItem.tsx
|
|
4865
|
-
import { jsx as
|
|
5324
|
+
import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4866
5325
|
function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
4867
|
-
return /* @__PURE__ */
|
|
5326
|
+
return /* @__PURE__ */ jsxs21(
|
|
4868
5327
|
"div",
|
|
4869
5328
|
{
|
|
4870
5329
|
className: cn("apteva-thread-item", {
|
|
@@ -4872,19 +5331,19 @@ function ThreadItem({ thread, isActive = false, onSelect, onDelete }) {
|
|
|
4872
5331
|
}),
|
|
4873
5332
|
onClick: onSelect,
|
|
4874
5333
|
children: [
|
|
4875
|
-
/* @__PURE__ */
|
|
4876
|
-
/* @__PURE__ */
|
|
4877
|
-
thread.preview && /* @__PURE__ */
|
|
4878
|
-
/* @__PURE__ */
|
|
4879
|
-
/* @__PURE__ */
|
|
5334
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex-1 min-w-0", children: [
|
|
5335
|
+
/* @__PURE__ */ jsx27("h4", { className: "font-semibold text-neutral-900 dark:text-white truncate", children: thread.title }),
|
|
5336
|
+
thread.preview && /* @__PURE__ */ jsx27("p", { className: "text-sm text-neutral-600 dark:text-neutral-400 truncate", children: thread.preview }),
|
|
5337
|
+
/* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-2 mt-1 text-xs text-neutral-500", children: [
|
|
5338
|
+
/* @__PURE__ */ jsxs21("span", { children: [
|
|
4880
5339
|
thread.messageCount,
|
|
4881
5340
|
" messages"
|
|
4882
5341
|
] }),
|
|
4883
|
-
/* @__PURE__ */
|
|
4884
|
-
/* @__PURE__ */
|
|
5342
|
+
/* @__PURE__ */ jsx27("span", { children: "\u2022" }),
|
|
5343
|
+
/* @__PURE__ */ jsx27("span", { children: formatRelativeTime(thread.updatedAt) })
|
|
4885
5344
|
] })
|
|
4886
5345
|
] }),
|
|
4887
|
-
onDelete && /* @__PURE__ */
|
|
5346
|
+
onDelete && /* @__PURE__ */ jsx27(
|
|
4888
5347
|
"button",
|
|
4889
5348
|
{
|
|
4890
5349
|
onClick: (e) => {
|
|
@@ -4914,7 +5373,7 @@ function formatRelativeTime(date) {
|
|
|
4914
5373
|
}
|
|
4915
5374
|
|
|
4916
5375
|
// src/components/Threads/ThreadList.tsx
|
|
4917
|
-
import { jsx as
|
|
5376
|
+
import { jsx as jsx28, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4918
5377
|
function ThreadList({
|
|
4919
5378
|
threads,
|
|
4920
5379
|
currentThreadId,
|
|
@@ -4928,8 +5387,8 @@ function ThreadList({
|
|
|
4928
5387
|
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || thread.preview?.toLowerCase().includes(searchQuery.toLowerCase())
|
|
4929
5388
|
);
|
|
4930
5389
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
4931
|
-
return /* @__PURE__ */
|
|
4932
|
-
showSearch && /* @__PURE__ */
|
|
5390
|
+
return /* @__PURE__ */ jsxs22("div", { className: "flex flex-col h-full", children: [
|
|
5391
|
+
showSearch && /* @__PURE__ */ jsx28("div", { className: "p-3 border-b border-neutral-200 dark:border-neutral-700", children: /* @__PURE__ */ jsx28(
|
|
4933
5392
|
"input",
|
|
4934
5393
|
{
|
|
4935
5394
|
type: "text",
|
|
@@ -4939,10 +5398,10 @@ function ThreadList({
|
|
|
4939
5398
|
className: "w-full px-3 py-2 text-sm border border-neutral-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-apteva-500 dark:bg-neutral-800 dark:border-neutral-600 dark:text-white"
|
|
4940
5399
|
}
|
|
4941
5400
|
) }),
|
|
4942
|
-
/* @__PURE__ */
|
|
4943
|
-
Object.entries(groupedThreads).map(([group, groupThreads]) => /* @__PURE__ */
|
|
4944
|
-
groupBy !== "none" && /* @__PURE__ */
|
|
4945
|
-
groupThreads.map((thread) => /* @__PURE__ */
|
|
5401
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex-1 overflow-y-auto", children: [
|
|
5402
|
+
Object.entries(groupedThreads).map(([group, groupThreads]) => /* @__PURE__ */ jsxs22("div", { children: [
|
|
5403
|
+
groupBy !== "none" && /* @__PURE__ */ jsx28("div", { className: "px-3 py-2 text-xs font-semibold text-neutral-500 uppercase", children: group }),
|
|
5404
|
+
groupThreads.map((thread) => /* @__PURE__ */ jsx28(
|
|
4946
5405
|
ThreadItem,
|
|
4947
5406
|
{
|
|
4948
5407
|
thread,
|
|
@@ -4953,9 +5412,9 @@ function ThreadList({
|
|
|
4953
5412
|
thread.id
|
|
4954
5413
|
))
|
|
4955
5414
|
] }, group)),
|
|
4956
|
-
filteredThreads.length === 0 && /* @__PURE__ */
|
|
4957
|
-
/* @__PURE__ */
|
|
4958
|
-
/* @__PURE__ */
|
|
5415
|
+
filteredThreads.length === 0 && /* @__PURE__ */ jsxs22("div", { className: "p-8 text-center text-neutral-500", children: [
|
|
5416
|
+
/* @__PURE__ */ jsx28("svg", { className: "w-10 h-10 mx-auto mb-2 opacity-50", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx28("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" }) }),
|
|
5417
|
+
/* @__PURE__ */ jsx28("p", { children: "No conversations found" })
|
|
4959
5418
|
] })
|
|
4960
5419
|
] })
|
|
4961
5420
|
] });
|
|
@@ -4987,7 +5446,7 @@ function groupThreadsByDate(threads) {
|
|
|
4987
5446
|
}
|
|
4988
5447
|
|
|
4989
5448
|
// src/components/Threads/Threads.tsx
|
|
4990
|
-
import { jsx as
|
|
5449
|
+
import { jsx as jsx29, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4991
5450
|
function Threads({
|
|
4992
5451
|
threads,
|
|
4993
5452
|
currentThreadId,
|
|
@@ -5006,8 +5465,8 @@ function Threads({
|
|
|
5006
5465
|
tabs: "flex gap-2 border-b border-neutral-200 dark:border-neutral-700 overflow-x-auto"
|
|
5007
5466
|
};
|
|
5008
5467
|
if (variant === "tabs") {
|
|
5009
|
-
return /* @__PURE__ */
|
|
5010
|
-
threads.slice(0, 5).map((thread) => /* @__PURE__ */
|
|
5468
|
+
return /* @__PURE__ */ jsxs23("div", { className: cn(variantClasses[variant], className), children: [
|
|
5469
|
+
threads.slice(0, 5).map((thread) => /* @__PURE__ */ jsx29(
|
|
5011
5470
|
"button",
|
|
5012
5471
|
{
|
|
5013
5472
|
onClick: () => onThreadSelect?.(thread.id),
|
|
@@ -5019,7 +5478,7 @@ function Threads({
|
|
|
5019
5478
|
},
|
|
5020
5479
|
thread.id
|
|
5021
5480
|
)),
|
|
5022
|
-
showNewButton && onNewThread && /* @__PURE__ */
|
|
5481
|
+
showNewButton && onNewThread && /* @__PURE__ */ jsx29(
|
|
5023
5482
|
"button",
|
|
5024
5483
|
{
|
|
5025
5484
|
onClick: onNewThread,
|
|
@@ -5029,8 +5488,8 @@ function Threads({
|
|
|
5029
5488
|
)
|
|
5030
5489
|
] });
|
|
5031
5490
|
}
|
|
5032
|
-
return /* @__PURE__ */
|
|
5033
|
-
showNewButton && onNewThread && /* @__PURE__ */
|
|
5491
|
+
return /* @__PURE__ */ jsxs23("div", { className: cn(variantClasses[variant], "flex flex-col", className), children: [
|
|
5492
|
+
showNewButton && onNewThread && /* @__PURE__ */ jsx29("div", { className: "p-3 border-b border-neutral-200 dark:border-neutral-700", children: /* @__PURE__ */ jsx29(
|
|
5034
5493
|
"button",
|
|
5035
5494
|
{
|
|
5036
5495
|
onClick: onNewThread,
|
|
@@ -5038,7 +5497,7 @@ function Threads({
|
|
|
5038
5497
|
children: "+ New Conversation"
|
|
5039
5498
|
}
|
|
5040
5499
|
) }),
|
|
5041
|
-
/* @__PURE__ */
|
|
5500
|
+
/* @__PURE__ */ jsx29(
|
|
5042
5501
|
ThreadList,
|
|
5043
5502
|
{
|
|
5044
5503
|
threads,
|
|
@@ -5052,6 +5511,418 @@ function Threads({
|
|
|
5052
5511
|
] });
|
|
5053
5512
|
}
|
|
5054
5513
|
|
|
5514
|
+
// src/components/AutoInterface/AutoInterface.tsx
|
|
5515
|
+
import { useState as useState13, useRef as useRef8, useCallback, useEffect as useEffect9 } from "react";
|
|
5516
|
+
|
|
5517
|
+
// src/components/AutoInterface/LayoutRenderer.tsx
|
|
5518
|
+
import { useState as useState12 } from "react";
|
|
5519
|
+
import { Fragment as Fragment7, jsx as jsx30, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
5520
|
+
var gapClasses = {
|
|
5521
|
+
none: "gap-0",
|
|
5522
|
+
sm: "gap-2",
|
|
5523
|
+
md: "gap-4",
|
|
5524
|
+
lg: "gap-6"
|
|
5525
|
+
};
|
|
5526
|
+
var paddingClasses = {
|
|
5527
|
+
none: "p-0",
|
|
5528
|
+
sm: "p-2",
|
|
5529
|
+
md: "p-4",
|
|
5530
|
+
lg: "p-6"
|
|
5531
|
+
};
|
|
5532
|
+
var maxWidthClasses = {
|
|
5533
|
+
sm: "max-w-2xl",
|
|
5534
|
+
md: "max-w-4xl",
|
|
5535
|
+
lg: "max-w-6xl",
|
|
5536
|
+
xl: "max-w-7xl",
|
|
5537
|
+
full: "max-w-full"
|
|
5538
|
+
};
|
|
5539
|
+
function LayoutRenderer({ node, onAction, renderNode }) {
|
|
5540
|
+
const children = node.children || [];
|
|
5541
|
+
switch (node.layout) {
|
|
5542
|
+
case "page":
|
|
5543
|
+
return /* @__PURE__ */ jsx30(PageLayout, { node, renderNode });
|
|
5544
|
+
case "row":
|
|
5545
|
+
return /* @__PURE__ */ jsx30(RowLayout, { node, renderNode });
|
|
5546
|
+
case "columns":
|
|
5547
|
+
return /* @__PURE__ */ jsx30(ColumnsLayout, { node, renderNode });
|
|
5548
|
+
case "stack":
|
|
5549
|
+
return /* @__PURE__ */ jsx30(StackLayout, { node, renderNode });
|
|
5550
|
+
case "sidebar":
|
|
5551
|
+
return /* @__PURE__ */ jsx30(SidebarLayout, { node, renderNode });
|
|
5552
|
+
case "tabs":
|
|
5553
|
+
return /* @__PURE__ */ jsx30(TabsLayout, { node, renderNode });
|
|
5554
|
+
default:
|
|
5555
|
+
return /* @__PURE__ */ jsx30("div", { className: "space-y-4", children: children.map((child) => /* @__PURE__ */ jsx30("div", { children: renderNode(child) }, child.id)) });
|
|
5556
|
+
}
|
|
5557
|
+
}
|
|
5558
|
+
function PageLayout({ node, renderNode }) {
|
|
5559
|
+
const { title, padding = "md", maxWidth = "xl" } = node.props || {};
|
|
5560
|
+
const children = node.children || [];
|
|
5561
|
+
return /* @__PURE__ */ jsxs24("div", { className: cn("w-full mx-auto", paddingClasses[padding], maxWidthClasses[maxWidth]), children: [
|
|
5562
|
+
title && /* @__PURE__ */ jsx30("h1", { className: "!text-2xl font-bold !text-neutral-900 dark:!text-white mb-6", children: title }),
|
|
5563
|
+
/* @__PURE__ */ jsx30("div", { className: "space-y-6", children: children.map((child) => /* @__PURE__ */ jsx30("div", { children: renderNode(child) }, child.id)) })
|
|
5564
|
+
] });
|
|
5565
|
+
}
|
|
5566
|
+
function RowLayout({ node, renderNode }) {
|
|
5567
|
+
const { columns, gap = "md", align = "stretch" } = node.props || {};
|
|
5568
|
+
const children = node.children || [];
|
|
5569
|
+
const templateColumns = columns ? columns.map((c) => `${c}fr`).join(" ") : `repeat(${children.length}, 1fr)`;
|
|
5570
|
+
const alignClasses = {
|
|
5571
|
+
start: "items-start",
|
|
5572
|
+
center: "items-center",
|
|
5573
|
+
end: "items-end",
|
|
5574
|
+
stretch: "items-stretch"
|
|
5575
|
+
};
|
|
5576
|
+
return /* @__PURE__ */ jsx30(
|
|
5577
|
+
"div",
|
|
5578
|
+
{
|
|
5579
|
+
className: cn("grid", gapClasses[gap], alignClasses[align]),
|
|
5580
|
+
style: { gridTemplateColumns: templateColumns },
|
|
5581
|
+
children: children.map((child) => /* @__PURE__ */ jsx30("div", { children: renderNode(child) }, child.id))
|
|
5582
|
+
}
|
|
5583
|
+
);
|
|
5584
|
+
}
|
|
5585
|
+
function ColumnsLayout({ node, renderNode }) {
|
|
5586
|
+
const { count, gap = "md" } = node.props || {};
|
|
5587
|
+
const children = node.children || [];
|
|
5588
|
+
const colCount = count || children.length;
|
|
5589
|
+
return /* @__PURE__ */ jsx30(
|
|
5590
|
+
"div",
|
|
5591
|
+
{
|
|
5592
|
+
className: cn("grid", gapClasses[gap]),
|
|
5593
|
+
style: { gridTemplateColumns: `repeat(${colCount}, 1fr)` },
|
|
5594
|
+
children: children.map((child) => /* @__PURE__ */ jsx30("div", { children: renderNode(child) }, child.id))
|
|
5595
|
+
}
|
|
5596
|
+
);
|
|
5597
|
+
}
|
|
5598
|
+
function StackLayout({ node, renderNode }) {
|
|
5599
|
+
const { gap = "md", align = "stretch" } = node.props || {};
|
|
5600
|
+
const children = node.children || [];
|
|
5601
|
+
const alignClasses = {
|
|
5602
|
+
left: "items-start",
|
|
5603
|
+
center: "items-center",
|
|
5604
|
+
right: "items-end",
|
|
5605
|
+
stretch: "items-stretch"
|
|
5606
|
+
};
|
|
5607
|
+
return /* @__PURE__ */ jsx30("div", { className: cn("flex flex-col", gapClasses[gap], alignClasses[align]), children: children.map((child) => /* @__PURE__ */ jsx30("div", { children: renderNode(child) }, child.id)) });
|
|
5608
|
+
}
|
|
5609
|
+
function SidebarLayout({ node, renderNode }) {
|
|
5610
|
+
const { side = "left", width = "280px" } = node.props || {};
|
|
5611
|
+
const children = node.children || [];
|
|
5612
|
+
const [sidebarChild, ...mainChildren] = side === "left" ? children : [...children].reverse();
|
|
5613
|
+
if (!sidebarChild) return null;
|
|
5614
|
+
const sidebar = /* @__PURE__ */ jsx30(
|
|
5615
|
+
"div",
|
|
5616
|
+
{
|
|
5617
|
+
className: "flex-shrink-0 overflow-y-auto border-neutral-200 dark:border-neutral-700",
|
|
5618
|
+
style: { width },
|
|
5619
|
+
children: renderNode(sidebarChild)
|
|
5620
|
+
}
|
|
5621
|
+
);
|
|
5622
|
+
const main = /* @__PURE__ */ jsx30("div", { className: "flex-1 overflow-y-auto min-w-0", children: mainChildren.map((child) => /* @__PURE__ */ jsx30("div", { children: renderNode(child) }, child.id)) });
|
|
5623
|
+
return /* @__PURE__ */ jsx30("div", { className: "flex h-full gap-4", children: side === "left" ? /* @__PURE__ */ jsxs24(Fragment7, { children: [
|
|
5624
|
+
sidebar,
|
|
5625
|
+
main
|
|
5626
|
+
] }) : /* @__PURE__ */ jsxs24(Fragment7, { children: [
|
|
5627
|
+
main,
|
|
5628
|
+
sidebar
|
|
5629
|
+
] }) });
|
|
5630
|
+
}
|
|
5631
|
+
function TabsLayout({ node, renderNode }) {
|
|
5632
|
+
const { labels = [], defaultTab = 0 } = node.props || {};
|
|
5633
|
+
const children = node.children || [];
|
|
5634
|
+
const [activeTab, setActiveTab] = useState12(defaultTab);
|
|
5635
|
+
return /* @__PURE__ */ jsxs24("div", { children: [
|
|
5636
|
+
/* @__PURE__ */ jsx30("div", { className: "flex border-b border-neutral-200 dark:border-neutral-700 mb-4", children: labels.map((label, idx) => /* @__PURE__ */ jsx30(
|
|
5637
|
+
"button",
|
|
5638
|
+
{
|
|
5639
|
+
onClick: () => setActiveTab(idx),
|
|
5640
|
+
className: cn(
|
|
5641
|
+
"px-4 py-2 !text-sm font-medium transition-colors border-b-2 -mb-px",
|
|
5642
|
+
activeTab === idx ? "border-blue-500 !text-blue-600 dark:!text-blue-400" : "border-transparent !text-neutral-500 hover:!text-neutral-700 dark:hover:!text-neutral-300"
|
|
5643
|
+
),
|
|
5644
|
+
children: label
|
|
5645
|
+
},
|
|
5646
|
+
idx
|
|
5647
|
+
)) }),
|
|
5648
|
+
children[activeTab] && renderNode(children[activeTab])
|
|
5649
|
+
] });
|
|
5650
|
+
}
|
|
5651
|
+
|
|
5652
|
+
// src/components/AutoInterface/InterfaceRenderer.tsx
|
|
5653
|
+
import { Fragment as Fragment8, jsx as jsx31 } from "react/jsx-runtime";
|
|
5654
|
+
var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
|
|
5655
|
+
function normalizeNode(n) {
|
|
5656
|
+
let node = { ...n };
|
|
5657
|
+
if (node.type === "widget" && node.props?.widget) {
|
|
5658
|
+
node.type = node.props.widget;
|
|
5659
|
+
const { widget: _, ...rest } = node.props;
|
|
5660
|
+
node.props = rest;
|
|
5661
|
+
}
|
|
5662
|
+
const explicit = node.props || {};
|
|
5663
|
+
const extra = {};
|
|
5664
|
+
for (const key of Object.keys(node)) {
|
|
5665
|
+
if (!STRUCTURAL_KEYS.has(key)) {
|
|
5666
|
+
extra[key] = node[key];
|
|
5667
|
+
}
|
|
5668
|
+
}
|
|
5669
|
+
node.props = { ...extra, ...explicit };
|
|
5670
|
+
if (node.props.style && !node.props.variant) {
|
|
5671
|
+
node.props.variant = node.props.style;
|
|
5672
|
+
delete node.props.style;
|
|
5673
|
+
}
|
|
5674
|
+
if (node.children) {
|
|
5675
|
+
node.children = node.children.map(normalizeNode);
|
|
5676
|
+
}
|
|
5677
|
+
return node;
|
|
5678
|
+
}
|
|
5679
|
+
function InterfaceRenderer({ node, onAction }) {
|
|
5680
|
+
const renderNode = (rawNode) => {
|
|
5681
|
+
const n = normalizeNode(rawNode);
|
|
5682
|
+
if (n.type === "layout" && n.layout) {
|
|
5683
|
+
return /* @__PURE__ */ jsx31(
|
|
5684
|
+
LayoutRenderer,
|
|
5685
|
+
{
|
|
5686
|
+
node: n,
|
|
5687
|
+
onAction,
|
|
5688
|
+
renderNode
|
|
5689
|
+
},
|
|
5690
|
+
n.id
|
|
5691
|
+
);
|
|
5692
|
+
}
|
|
5693
|
+
return /* @__PURE__ */ jsx31(
|
|
5694
|
+
WidgetRenderer,
|
|
5695
|
+
{
|
|
5696
|
+
widget: {
|
|
5697
|
+
type: n.type,
|
|
5698
|
+
id: n.id,
|
|
5699
|
+
props: n.props || {},
|
|
5700
|
+
actions: n.actions,
|
|
5701
|
+
metadata: n.metadata,
|
|
5702
|
+
isStreaming: n.isStreaming
|
|
5703
|
+
},
|
|
5704
|
+
onAction
|
|
5705
|
+
},
|
|
5706
|
+
n.id
|
|
5707
|
+
);
|
|
5708
|
+
};
|
|
5709
|
+
return /* @__PURE__ */ jsx31(Fragment8, { children: renderNode(node) });
|
|
5710
|
+
}
|
|
5711
|
+
|
|
5712
|
+
// src/components/AutoInterface/InterfaceSkeleton.tsx
|
|
5713
|
+
import { jsx as jsx32, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5714
|
+
function InterfaceSkeleton({ className }) {
|
|
5715
|
+
return /* @__PURE__ */ jsxs25("div", { className: cn("animate-pulse space-y-6 p-6", className), children: [
|
|
5716
|
+
/* @__PURE__ */ jsx32("div", { className: "h-7 bg-neutral-200 dark:bg-neutral-700 rounded w-1/3" }),
|
|
5717
|
+
/* @__PURE__ */ jsx32("div", { className: "grid grid-cols-4 gap-4", children: [1, 2, 3, 4].map((i) => /* @__PURE__ */ jsxs25("div", { className: "border border-neutral-200 dark:border-neutral-700 rounded-xl p-5 space-y-2", children: [
|
|
5718
|
+
/* @__PURE__ */ jsx32("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-2/3" }),
|
|
5719
|
+
/* @__PURE__ */ jsx32("div", { className: "h-8 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2" })
|
|
5720
|
+
] }, i)) }),
|
|
5721
|
+
/* @__PURE__ */ jsxs25("div", { className: "grid grid-cols-3 gap-4", children: [
|
|
5722
|
+
/* @__PURE__ */ jsxs25("div", { className: "col-span-2 border border-neutral-200 dark:border-neutral-700 rounded-xl p-5 space-y-3", children: [
|
|
5723
|
+
/* @__PURE__ */ jsx32("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/4" }),
|
|
5724
|
+
/* @__PURE__ */ jsx32("div", { className: "h-40 bg-neutral-200 dark:bg-neutral-700 rounded" })
|
|
5725
|
+
] }),
|
|
5726
|
+
/* @__PURE__ */ jsxs25("div", { className: "border border-neutral-200 dark:border-neutral-700 rounded-xl p-5 space-y-3", children: [
|
|
5727
|
+
/* @__PURE__ */ jsx32("div", { className: "h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2" }),
|
|
5728
|
+
[1, 2, 3].map((i) => /* @__PURE__ */ jsx32("div", { className: "h-10 bg-neutral-200 dark:bg-neutral-700 rounded" }, i))
|
|
5729
|
+
] })
|
|
5730
|
+
] })
|
|
5731
|
+
] });
|
|
5732
|
+
}
|
|
5733
|
+
|
|
5734
|
+
// src/components/AutoInterface/AutoInterface.tsx
|
|
5735
|
+
import { jsx as jsx33, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5736
|
+
async function generateInitialInterface(apiUrl, apiKey, agentId, prompt) {
|
|
5737
|
+
const systemContext = generateCompactInterfaceContext();
|
|
5738
|
+
const message = `${systemContext}
|
|
5739
|
+
|
|
5740
|
+
Generate an interface for: ${prompt}`;
|
|
5741
|
+
const headers = { "Content-Type": "application/json" };
|
|
5742
|
+
if (apiKey) headers["X-API-Key"] = apiKey;
|
|
5743
|
+
const response = await fetch(`${apiUrl}/chat`, {
|
|
5744
|
+
method: "POST",
|
|
5745
|
+
headers,
|
|
5746
|
+
body: JSON.stringify({
|
|
5747
|
+
agent_id: agentId,
|
|
5748
|
+
message,
|
|
5749
|
+
stream: false
|
|
5750
|
+
})
|
|
5751
|
+
});
|
|
5752
|
+
if (!response.ok) {
|
|
5753
|
+
const err = await response.json().catch(() => ({ error: "Request failed" }));
|
|
5754
|
+
throw new Error(err.error || `Request failed with status ${response.status}`);
|
|
5755
|
+
}
|
|
5756
|
+
const data = await response.json();
|
|
5757
|
+
const text = data.response || data.message || "";
|
|
5758
|
+
console.log("[AutoInterface] Raw API response:", data);
|
|
5759
|
+
console.log("[AutoInterface] Extracted text (" + text.length + " chars):", text.substring(0, 500));
|
|
5760
|
+
const spec = parseInterfaceFromText(text);
|
|
5761
|
+
console.log("[AutoInterface] Parsed spec:", spec ? "OK" : "null", spec ? JSON.stringify(spec).substring(0, 300) + "..." : "");
|
|
5762
|
+
return { spec, threadId: data.thread_id || null };
|
|
5763
|
+
}
|
|
5764
|
+
function AutoInterface({
|
|
5765
|
+
agentId,
|
|
5766
|
+
threadId,
|
|
5767
|
+
initialPrompt,
|
|
5768
|
+
initialInterface,
|
|
5769
|
+
context,
|
|
5770
|
+
apiUrl,
|
|
5771
|
+
apiKey,
|
|
5772
|
+
onInterfaceChange,
|
|
5773
|
+
onAction,
|
|
5774
|
+
onThreadChange,
|
|
5775
|
+
onError,
|
|
5776
|
+
chatPosition = "right",
|
|
5777
|
+
chatWidth = "380px",
|
|
5778
|
+
chatCollapsible = true,
|
|
5779
|
+
chatPlaceholder = "Ask the AI to generate or update the interface...",
|
|
5780
|
+
chatWelcomeTitle = "Auto Interface",
|
|
5781
|
+
useMock,
|
|
5782
|
+
theme,
|
|
5783
|
+
className
|
|
5784
|
+
}) {
|
|
5785
|
+
const [interfaceSpec, setInterfaceSpec] = useState13(initialInterface || null);
|
|
5786
|
+
const [isGenerating, setIsGenerating] = useState13(false);
|
|
5787
|
+
const [chatCollapsed, setChatCollapsed] = useState13(false);
|
|
5788
|
+
const chatRef = useRef8(null);
|
|
5789
|
+
const systemContext = [
|
|
5790
|
+
generateInterfaceContext(),
|
|
5791
|
+
context || ""
|
|
5792
|
+
].filter(Boolean).join("\n\n");
|
|
5793
|
+
const updateInterface = useCallback((newSpec) => {
|
|
5794
|
+
setInterfaceSpec(newSpec);
|
|
5795
|
+
onInterfaceChange?.(newSpec);
|
|
5796
|
+
}, [onInterfaceChange]);
|
|
5797
|
+
const handleAction = useCallback((action) => {
|
|
5798
|
+
onAction?.(action);
|
|
5799
|
+
if (chatRef.current) {
|
|
5800
|
+
chatRef.current.sendMessage(
|
|
5801
|
+
`[Action: ${action.type} on widget ${action.widgetId || "unknown"}. Payload: ${JSON.stringify(action.payload)}]`
|
|
5802
|
+
);
|
|
5803
|
+
}
|
|
5804
|
+
}, [onAction]);
|
|
5805
|
+
const handleMessageComplete = useCallback((result) => {
|
|
5806
|
+
if (!result?.data) return;
|
|
5807
|
+
const text = typeof result.data === "string" ? result.data : result.data.message || "";
|
|
5808
|
+
console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
|
|
5809
|
+
const parsed = parseInterfaceFromText(text);
|
|
5810
|
+
if (parsed) {
|
|
5811
|
+
console.log("[AutoInterface] Parsed full interface from chat");
|
|
5812
|
+
updateInterface(parsed);
|
|
5813
|
+
setIsGenerating(false);
|
|
5814
|
+
return;
|
|
5815
|
+
}
|
|
5816
|
+
const updates = parseUpdatesFromText(text);
|
|
5817
|
+
if (updates.length > 0 && interfaceSpec) {
|
|
5818
|
+
console.log("[AutoInterface] Parsed", updates.length, "updates from chat");
|
|
5819
|
+
const newSpec = applyUpdates(interfaceSpec, updates);
|
|
5820
|
+
updateInterface(newSpec);
|
|
5821
|
+
} else {
|
|
5822
|
+
console.log("[AutoInterface] No interface or updates found in chat message");
|
|
5823
|
+
}
|
|
5824
|
+
setIsGenerating(false);
|
|
5825
|
+
}, [interfaceSpec, updateInterface]);
|
|
5826
|
+
useEffect9(() => {
|
|
5827
|
+
if (!initialPrompt || initialInterface || useMock) return;
|
|
5828
|
+
if (!apiUrl) return;
|
|
5829
|
+
let cancelled = false;
|
|
5830
|
+
setIsGenerating(true);
|
|
5831
|
+
console.log("[AutoInterface] Generating initial interface for prompt:", initialPrompt);
|
|
5832
|
+
console.log("[AutoInterface] API URL:", apiUrl, "| Agent:", agentId);
|
|
5833
|
+
generateInitialInterface(apiUrl, apiKey, agentId, initialPrompt).then(({ spec, threadId: threadId2 }) => {
|
|
5834
|
+
if (cancelled) return;
|
|
5835
|
+
console.log("[AutoInterface] Generation complete. Spec:", spec ? "parsed OK" : "null", "| Thread:", threadId2);
|
|
5836
|
+
if (spec) {
|
|
5837
|
+
console.log("[AutoInterface] Setting interface with", JSON.stringify(spec).length, "bytes");
|
|
5838
|
+
updateInterface(spec);
|
|
5839
|
+
} else {
|
|
5840
|
+
console.warn("[AutoInterface] Agent did not return a parseable @interface block");
|
|
5841
|
+
}
|
|
5842
|
+
setIsGenerating(false);
|
|
5843
|
+
}).catch((err) => {
|
|
5844
|
+
if (cancelled) return;
|
|
5845
|
+
console.error("[AutoInterface] Initial generation failed:", err);
|
|
5846
|
+
onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
5847
|
+
setIsGenerating(false);
|
|
5848
|
+
});
|
|
5849
|
+
return () => {
|
|
5850
|
+
cancelled = true;
|
|
5851
|
+
};
|
|
5852
|
+
}, [initialPrompt]);
|
|
5853
|
+
const hasInterface = interfaceSpec !== null;
|
|
5854
|
+
const showSkeleton = isGenerating && !hasInterface;
|
|
5855
|
+
return /* @__PURE__ */ jsxs26("div", { className: cn(
|
|
5856
|
+
"flex h-full bg-neutral-50 dark:bg-black",
|
|
5857
|
+
chatPosition === "bottom" ? "flex-col" : "flex-row",
|
|
5858
|
+
className
|
|
5859
|
+
), children: [
|
|
5860
|
+
/* @__PURE__ */ jsxs26("div", { className: cn(
|
|
5861
|
+
"flex-1 overflow-y-auto min-w-0",
|
|
5862
|
+
hasInterface || showSkeleton ? "" : "hidden"
|
|
5863
|
+
), children: [
|
|
5864
|
+
showSkeleton && /* @__PURE__ */ jsx33(InterfaceSkeleton, {}),
|
|
5865
|
+
hasInterface && interfaceSpec && /* @__PURE__ */ jsx33("div", { className: "p-4", children: /* @__PURE__ */ jsx33(
|
|
5866
|
+
InterfaceRenderer,
|
|
5867
|
+
{
|
|
5868
|
+
node: interfaceSpec.root,
|
|
5869
|
+
onAction: handleAction
|
|
5870
|
+
}
|
|
5871
|
+
) })
|
|
5872
|
+
] }),
|
|
5873
|
+
chatCollapsible && hasInterface && chatPosition === "right" && /* @__PURE__ */ jsx33(
|
|
5874
|
+
"button",
|
|
5875
|
+
{
|
|
5876
|
+
onClick: () => setChatCollapsed(!chatCollapsed),
|
|
5877
|
+
className: "flex-shrink-0 w-6 flex items-center justify-center border-l border-neutral-200 dark:border-neutral-700 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",
|
|
5878
|
+
title: chatCollapsed ? "Show chat" : "Hide chat",
|
|
5879
|
+
children: /* @__PURE__ */ jsx33("span", { className: "!text-xs !text-neutral-500 dark:!text-neutral-400", children: chatCollapsed ? "\u25C0" : "\u25B6" })
|
|
5880
|
+
}
|
|
5881
|
+
),
|
|
5882
|
+
/* @__PURE__ */ jsx33(
|
|
5883
|
+
"div",
|
|
5884
|
+
{
|
|
5885
|
+
className: cn(
|
|
5886
|
+
"flex-shrink-0 border-neutral-200 dark:border-neutral-700",
|
|
5887
|
+
chatPosition === "right" ? "border-l" : "border-t",
|
|
5888
|
+
chatCollapsed && "hidden",
|
|
5889
|
+
// When no interface is generated yet, chat takes full width
|
|
5890
|
+
!hasInterface && !showSkeleton && "flex-1"
|
|
5891
|
+
),
|
|
5892
|
+
style: hasInterface || showSkeleton ? chatPosition === "right" ? { width: chatWidth } : { height: "300px" } : void 0,
|
|
5893
|
+
children: /* @__PURE__ */ jsx33(
|
|
5894
|
+
Chat,
|
|
5895
|
+
{
|
|
5896
|
+
ref: chatRef,
|
|
5897
|
+
agentId,
|
|
5898
|
+
threadId,
|
|
5899
|
+
apiUrl,
|
|
5900
|
+
apiKey,
|
|
5901
|
+
useMock,
|
|
5902
|
+
context: systemContext,
|
|
5903
|
+
placeholder: chatPlaceholder,
|
|
5904
|
+
welcomeTitle: chatWelcomeTitle,
|
|
5905
|
+
welcomeSubtitle: "Describe the interface you want to create",
|
|
5906
|
+
enableStreaming: true,
|
|
5907
|
+
enableWidgets: true,
|
|
5908
|
+
showHeader: true,
|
|
5909
|
+
headerTitle: "Chat",
|
|
5910
|
+
onThreadChange,
|
|
5911
|
+
onComplete: handleMessageComplete,
|
|
5912
|
+
onError,
|
|
5913
|
+
className: "h-full",
|
|
5914
|
+
suggestedPrompts: !hasInterface ? [
|
|
5915
|
+
"Show me a sales dashboard",
|
|
5916
|
+
"Create a user management panel",
|
|
5917
|
+
"Build a project overview page"
|
|
5918
|
+
] : void 0
|
|
5919
|
+
}
|
|
5920
|
+
)
|
|
5921
|
+
}
|
|
5922
|
+
)
|
|
5923
|
+
] });
|
|
5924
|
+
}
|
|
5925
|
+
|
|
5055
5926
|
// src/utils/theme-script.ts
|
|
5056
5927
|
var themeScript = `
|
|
5057
5928
|
(function() {
|
|
@@ -5075,22 +5946,155 @@ var themeScript = `
|
|
|
5075
5946
|
function getThemeScript() {
|
|
5076
5947
|
return themeScript;
|
|
5077
5948
|
}
|
|
5949
|
+
|
|
5950
|
+
// src/hooks/useInterfaceState.ts
|
|
5951
|
+
import { useState as useState14, useCallback as useCallback2 } from "react";
|
|
5952
|
+
function useInterfaceState(initialSpec) {
|
|
5953
|
+
const [spec, setSpec] = useState14(initialSpec || null);
|
|
5954
|
+
const [isStreaming, setIsStreaming] = useState14(false);
|
|
5955
|
+
const setInterface = useCallback2((newSpec) => {
|
|
5956
|
+
setSpec(newSpec);
|
|
5957
|
+
}, []);
|
|
5958
|
+
const clearInterface = useCallback2(() => {
|
|
5959
|
+
setSpec(null);
|
|
5960
|
+
}, []);
|
|
5961
|
+
const applyInterfaceUpdate = useCallback2((update) => {
|
|
5962
|
+
setSpec((prev) => {
|
|
5963
|
+
if (!prev) return prev;
|
|
5964
|
+
return applyUpdate(prev, update);
|
|
5965
|
+
});
|
|
5966
|
+
}, []);
|
|
5967
|
+
const applyInterfaceUpdates = useCallback2((updates) => {
|
|
5968
|
+
setSpec((prev) => {
|
|
5969
|
+
if (!prev) return prev;
|
|
5970
|
+
return applyUpdates(prev, updates);
|
|
5971
|
+
});
|
|
5972
|
+
}, []);
|
|
5973
|
+
const getNode = useCallback2((id) => {
|
|
5974
|
+
if (!spec) return null;
|
|
5975
|
+
return findNode(spec.root, id);
|
|
5976
|
+
}, [spec]);
|
|
5977
|
+
return {
|
|
5978
|
+
spec,
|
|
5979
|
+
isStreaming,
|
|
5980
|
+
setInterface,
|
|
5981
|
+
clearInterface,
|
|
5982
|
+
applyInterfaceUpdate,
|
|
5983
|
+
applyInterfaceUpdates,
|
|
5984
|
+
setIsStreaming,
|
|
5985
|
+
getNode
|
|
5986
|
+
};
|
|
5987
|
+
}
|
|
5988
|
+
|
|
5989
|
+
// src/hooks/useInterfaceAI.ts
|
|
5990
|
+
import { useCallback as useCallback3, useRef as useRef9 } from "react";
|
|
5991
|
+
function useInterfaceAI({
|
|
5992
|
+
agentId,
|
|
5993
|
+
apiUrl,
|
|
5994
|
+
apiKey,
|
|
5995
|
+
context,
|
|
5996
|
+
onInterface,
|
|
5997
|
+
onUpdates,
|
|
5998
|
+
onError,
|
|
5999
|
+
onStreamStart,
|
|
6000
|
+
onStreamEnd
|
|
6001
|
+
}) {
|
|
6002
|
+
const threadIdRef = useRef9(null);
|
|
6003
|
+
const accumulatedTextRef = useRef9("");
|
|
6004
|
+
if (apiUrl || apiKey) {
|
|
6005
|
+
aptevaClient.configure({
|
|
6006
|
+
...apiUrl && { apiUrl },
|
|
6007
|
+
...apiKey && { apiKey }
|
|
6008
|
+
});
|
|
6009
|
+
}
|
|
6010
|
+
const sendMessage = useCallback3(async (message) => {
|
|
6011
|
+
accumulatedTextRef.current = "";
|
|
6012
|
+
onStreamStart?.();
|
|
6013
|
+
const systemPrompt = [
|
|
6014
|
+
generateInterfaceContext(),
|
|
6015
|
+
context || ""
|
|
6016
|
+
].filter(Boolean).join("\n\n");
|
|
6017
|
+
try {
|
|
6018
|
+
await aptevaClient.chatStream(
|
|
6019
|
+
{
|
|
6020
|
+
agent_id: agentId,
|
|
6021
|
+
message,
|
|
6022
|
+
thread_id: threadIdRef.current || void 0,
|
|
6023
|
+
stream: true,
|
|
6024
|
+
system: systemPrompt
|
|
6025
|
+
},
|
|
6026
|
+
// onChunk
|
|
6027
|
+
(chunk) => {
|
|
6028
|
+
if (chunk.thread_id) {
|
|
6029
|
+
threadIdRef.current = chunk.thread_id;
|
|
6030
|
+
}
|
|
6031
|
+
if (chunk.type === "content" || chunk.type === "token") {
|
|
6032
|
+
accumulatedTextRef.current += chunk.content || "";
|
|
6033
|
+
const parsed = parseInterfaceFromText(accumulatedTextRef.current);
|
|
6034
|
+
if (parsed) {
|
|
6035
|
+
onInterface?.(parsed);
|
|
6036
|
+
}
|
|
6037
|
+
const updates = parseUpdatesFromText(accumulatedTextRef.current);
|
|
6038
|
+
if (updates.length > 0) {
|
|
6039
|
+
onUpdates?.(updates);
|
|
6040
|
+
}
|
|
6041
|
+
}
|
|
6042
|
+
},
|
|
6043
|
+
// onComplete
|
|
6044
|
+
() => {
|
|
6045
|
+
onStreamEnd?.();
|
|
6046
|
+
},
|
|
6047
|
+
// onError
|
|
6048
|
+
(error) => {
|
|
6049
|
+
onError?.(error);
|
|
6050
|
+
onStreamEnd?.();
|
|
6051
|
+
}
|
|
6052
|
+
);
|
|
6053
|
+
} catch (error) {
|
|
6054
|
+
onError?.(error instanceof Error ? error : new Error("Unknown error"));
|
|
6055
|
+
onStreamEnd?.();
|
|
6056
|
+
}
|
|
6057
|
+
}, [agentId, context, onInterface, onUpdates, onError, onStreamStart, onStreamEnd]);
|
|
6058
|
+
return {
|
|
6059
|
+
sendMessage,
|
|
6060
|
+
threadId: threadIdRef.current
|
|
6061
|
+
};
|
|
6062
|
+
}
|
|
5078
6063
|
export {
|
|
5079
6064
|
AptevaClient,
|
|
6065
|
+
AutoInterface,
|
|
5080
6066
|
Button,
|
|
5081
6067
|
Card,
|
|
5082
6068
|
Chat,
|
|
5083
6069
|
Command,
|
|
6070
|
+
InterfaceRenderer,
|
|
6071
|
+
InterfaceSkeleton,
|
|
6072
|
+
Kpi,
|
|
6073
|
+
LayoutRenderer,
|
|
5084
6074
|
List,
|
|
5085
6075
|
Prompt,
|
|
6076
|
+
Spacer,
|
|
5086
6077
|
Stream,
|
|
6078
|
+
TextBlock,
|
|
5087
6079
|
Threads,
|
|
5088
6080
|
Widgets,
|
|
6081
|
+
applyUpdate,
|
|
6082
|
+
applyUpdates,
|
|
5089
6083
|
aptevaClient,
|
|
5090
6084
|
cn,
|
|
6085
|
+
containsInterface,
|
|
6086
|
+
convertApiMessages,
|
|
6087
|
+
findNode,
|
|
6088
|
+
generateCompactInterfaceContext,
|
|
6089
|
+
generateInterfaceContext,
|
|
5091
6090
|
getThemeScript,
|
|
5092
6091
|
mockMessages,
|
|
5093
6092
|
mockThreads,
|
|
5094
|
-
mockWidgets
|
|
6093
|
+
mockWidgets,
|
|
6094
|
+
parseInterfaceFromText,
|
|
6095
|
+
parseUpdatesFromText,
|
|
6096
|
+
stripInterface,
|
|
6097
|
+
useInterfaceAI,
|
|
6098
|
+
useInterfaceState
|
|
5095
6099
|
};
|
|
5096
6100
|
//# sourceMappingURL=index.mjs.map
|