@apteva/apteva-kit 0.1.3 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +227 -113
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +209 -95
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -190,14 +190,14 @@ import { useEffect } from "react";
|
|
|
190
190
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
191
191
|
function Card({ widget, onAction }) {
|
|
192
192
|
const { title, description, image, footer } = widget.props;
|
|
193
|
-
return /* @__PURE__ */ jsxs("div", { className: "
|
|
193
|
+
return /* @__PURE__ */ jsxs("div", { className: "border border-gray-200 dark:border-gray-700 rounded-xl bg-white dark:bg-gray-900 overflow-hidden", children: [
|
|
194
194
|
image && /* @__PURE__ */ jsx("img", { src: image, alt: title, className: "w-full h-48 object-cover" }),
|
|
195
195
|
/* @__PURE__ */ jsxs("div", { className: "p-4", children: [
|
|
196
|
-
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-gray-900 dark
|
|
197
|
-
description && /* @__PURE__ */ jsx("p", { className: "text-gray-600 dark
|
|
196
|
+
/* @__PURE__ */ jsx("h3", { className: "!text-lg font-semibold !text-gray-900 dark:!text-white", children: title }),
|
|
197
|
+
description && /* @__PURE__ */ jsx("p", { className: "!text-gray-600 dark:!text-gray-400 mt-2", children: description })
|
|
198
198
|
] }),
|
|
199
199
|
(footer || widget.actions && widget.actions.length > 0) && /* @__PURE__ */ jsxs("div", { className: "border-t border-gray-200 dark:border-gray-700 p-4 flex justify-between items-center", children: [
|
|
200
|
-
footer && /* @__PURE__ */ jsx("span", { className: "text-sm text-gray-600 dark
|
|
200
|
+
footer && /* @__PURE__ */ jsx("span", { className: "!text-sm !text-gray-600 dark:!text-gray-400", children: footer }),
|
|
201
201
|
widget.actions && widget.actions.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: widget.actions.map((action, idx) => /* @__PURE__ */ jsx(
|
|
202
202
|
"button",
|
|
203
203
|
{
|
|
@@ -207,7 +207,7 @@ function Card({ widget, onAction }) {
|
|
|
207
207
|
widgetId: widget.id,
|
|
208
208
|
timestamp: /* @__PURE__ */ new Date()
|
|
209
209
|
}),
|
|
210
|
-
className: "
|
|
210
|
+
className: "px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors bg-blue-500 !text-white hover:bg-blue-600",
|
|
211
211
|
children: action.label
|
|
212
212
|
},
|
|
213
213
|
idx
|
|
@@ -220,28 +220,35 @@ function Card({ widget, onAction }) {
|
|
|
220
220
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
221
221
|
function List({ widget, onAction }) {
|
|
222
222
|
const { items } = widget.props;
|
|
223
|
-
return /* @__PURE__ */ jsx2("div", { className: "
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
223
|
+
return /* @__PURE__ */ jsx2("div", { className: "border border-gray-200 dark:border-gray-700 rounded-xl bg-white dark:bg-gray-900 overflow-hidden", children: items.map((item, index) => /* @__PURE__ */ jsxs2(
|
|
224
|
+
"div",
|
|
225
|
+
{
|
|
226
|
+
className: `flex items-center p-4 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors ${index !== items.length - 1 ? "border-b border-gray-200 dark:border-gray-700" : ""}`,
|
|
227
|
+
children: [
|
|
228
|
+
item.image && /* @__PURE__ */ jsx2("img", { src: item.image, alt: item.title, className: "w-16 h-16 rounded object-cover" }),
|
|
229
|
+
/* @__PURE__ */ jsxs2("div", { className: `flex-1 ${item.image ? "ml-4" : ""}`, children: [
|
|
230
|
+
/* @__PURE__ */ jsx2("h4", { className: "font-semibold !text-gray-900 dark:!text-white", children: item.title }),
|
|
231
|
+
item.subtitle && /* @__PURE__ */ jsx2("p", { className: "!text-sm !text-gray-600 dark:!text-gray-400", children: item.subtitle }),
|
|
232
|
+
item.description && /* @__PURE__ */ jsx2("p", { className: "!text-xs !text-gray-500 dark:!text-gray-500 mt-1", children: item.description })
|
|
233
|
+
] }),
|
|
234
|
+
widget.actions && widget.actions.length > 0 && /* @__PURE__ */ jsx2("div", { className: "flex gap-2", children: widget.actions.map((action, idx) => /* @__PURE__ */ jsx2(
|
|
235
|
+
"button",
|
|
236
|
+
{
|
|
237
|
+
onClick: () => onAction?.({
|
|
238
|
+
type: action.type,
|
|
239
|
+
payload: item.metadata || item,
|
|
240
|
+
widgetId: widget.id,
|
|
241
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
242
|
+
}),
|
|
243
|
+
className: "px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors bg-blue-500 !text-white hover:bg-blue-600",
|
|
244
|
+
children: action.label
|
|
245
|
+
},
|
|
246
|
+
idx
|
|
247
|
+
)) })
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
item.id
|
|
251
|
+
)) });
|
|
245
252
|
}
|
|
246
253
|
|
|
247
254
|
// src/components/Widgets/widget-library/Button.tsx
|
|
@@ -249,10 +256,10 @@ import { jsx as jsx3 } from "react/jsx-runtime";
|
|
|
249
256
|
function Button({ widget, onAction }) {
|
|
250
257
|
const { label, variant = "primary", disabled = false } = widget.props;
|
|
251
258
|
const variantClasses = {
|
|
252
|
-
primary: "bg-
|
|
253
|
-
secondary: "bg-gray-500 text-white hover:bg-gray-600",
|
|
254
|
-
outline: "border-2 border-
|
|
255
|
-
ghost: "text-
|
|
259
|
+
primary: "bg-blue-500 !text-white hover:bg-blue-600",
|
|
260
|
+
secondary: "bg-gray-500 !text-white hover:bg-gray-600",
|
|
261
|
+
outline: "border-2 border-blue-500 !text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900",
|
|
262
|
+
ghost: "!text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900"
|
|
256
263
|
};
|
|
257
264
|
return /* @__PURE__ */ jsx3(
|
|
258
265
|
"button",
|
|
@@ -326,11 +333,20 @@ function Widgets({
|
|
|
326
333
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
327
334
|
function Message({ message, onAction }) {
|
|
328
335
|
const isUser = message.role === "user";
|
|
329
|
-
return /* @__PURE__ */ jsxs4(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
336
|
+
return /* @__PURE__ */ jsxs4(
|
|
337
|
+
"div",
|
|
338
|
+
{
|
|
339
|
+
className: cn(
|
|
340
|
+
"max-w-[80%]",
|
|
341
|
+
isUser ? "px-4 py-2.5 rounded-xl bg-gray-100 dark:bg-gray-800 !text-gray-900 dark:!text-gray-100 ml-auto" : "!text-gray-900 dark:!text-gray-100"
|
|
342
|
+
),
|
|
343
|
+
children: [
|
|
344
|
+
/* @__PURE__ */ jsx6("div", { className: "whitespace-pre-wrap !text-sm leading-relaxed", children: message.content }),
|
|
345
|
+
message.widgets && message.widgets.length > 0 && /* @__PURE__ */ jsx6("div", { className: cn(isUser ? "mt-3" : "mt-2"), children: /* @__PURE__ */ jsx6(Widgets, { widgets: message.widgets, onAction, layout: "stack" }) }),
|
|
346
|
+
/* @__PURE__ */ jsx6("div", { className: cn("!text-xs opacity-70", isUser ? "mt-1.5 !text-gray-500 dark:!text-gray-400" : "mt-1 !text-gray-500 dark:!text-gray-400"), suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
347
|
+
]
|
|
348
|
+
}
|
|
349
|
+
);
|
|
334
350
|
}
|
|
335
351
|
|
|
336
352
|
// src/components/Chat/MessageList.tsx
|
|
@@ -342,7 +358,7 @@ function MessageList({ messages, onAction }) {
|
|
|
342
358
|
listRef.current.scrollTop = listRef.current.scrollHeight;
|
|
343
359
|
}
|
|
344
360
|
}, [messages]);
|
|
345
|
-
return /* @__PURE__ */ jsx7("div", { ref: listRef, className: "
|
|
361
|
+
return /* @__PURE__ */ jsx7("div", { ref: listRef, className: "flex-1 overflow-y-auto px-4 py-4 space-y-3", children: messages.length === 0 ? /* @__PURE__ */ jsx7("div", { className: "flex items-center justify-center h-full !text-gray-500 dark:!text-gray-400", children: /* @__PURE__ */ jsxs5("div", { className: "text-center space-y-2", children: [
|
|
346
362
|
/* @__PURE__ */ jsx7("div", { className: "text-4xl", children: "\u{1F4AC}" }),
|
|
347
363
|
/* @__PURE__ */ jsx7("p", { children: "No messages yet. Start a conversation!" })
|
|
348
364
|
] }) }) : messages.map((message) => /* @__PURE__ */ jsx7(Message, { message, onAction }, message.id)) });
|
|
@@ -350,10 +366,12 @@ function MessageList({ messages, onAction }) {
|
|
|
350
366
|
|
|
351
367
|
// src/components/Chat/Composer.tsx
|
|
352
368
|
import { useState, useRef as useRef2 } from "react";
|
|
353
|
-
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
354
|
-
function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false }) {
|
|
369
|
+
import { Fragment, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
370
|
+
function Composer({ onSendMessage, placeholder = "Type a message...", disabled = false, onFileUpload }) {
|
|
355
371
|
const [text, setText] = useState("");
|
|
372
|
+
const [showMenu, setShowMenu] = useState(false);
|
|
356
373
|
const textareaRef = useRef2(null);
|
|
374
|
+
const fileInputRef = useRef2(null);
|
|
357
375
|
const handleKeyDown = (e) => {
|
|
358
376
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
359
377
|
e.preventDefault();
|
|
@@ -374,8 +392,37 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
374
392
|
e.target.style.height = "auto";
|
|
375
393
|
e.target.style.height = `${e.target.scrollHeight}px`;
|
|
376
394
|
};
|
|
377
|
-
|
|
378
|
-
|
|
395
|
+
const handleFileSelect = (e) => {
|
|
396
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
397
|
+
onFileUpload?.(e.target.files);
|
|
398
|
+
setShowMenu(false);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
return /* @__PURE__ */ jsxs6("div", { className: "px-4 py-3 bg-white dark:bg-gray-900 relative", children: [
|
|
402
|
+
showMenu && /* @__PURE__ */ jsxs6(Fragment, { children: [
|
|
403
|
+
/* @__PURE__ */ jsx8("div", { className: "fixed inset-0 z-10", onClick: () => setShowMenu(false) }),
|
|
404
|
+
/* @__PURE__ */ jsx8("div", { className: "absolute bottom-full left-4 mb-2 bg-gray-800 dark:bg-gray-700 rounded-xl shadow-lg overflow-hidden z-20 min-w-[240px]", children: /* @__PURE__ */ jsxs6(
|
|
405
|
+
"button",
|
|
406
|
+
{
|
|
407
|
+
onClick: () => fileInputRef.current?.click(),
|
|
408
|
+
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-gray-700 dark:hover:bg-gray-600 transition-colors !text-white text-left",
|
|
409
|
+
children: [
|
|
410
|
+
/* @__PURE__ */ jsx8("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx8("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)" }) }),
|
|
411
|
+
/* @__PURE__ */ jsx8("span", { className: "!text-sm font-medium", children: "Add photos & files" })
|
|
412
|
+
]
|
|
413
|
+
}
|
|
414
|
+
) })
|
|
415
|
+
] }),
|
|
416
|
+
/* @__PURE__ */ jsxs6("div", { className: "relative border-2 border-gray-300 dark:border-gray-700 rounded-xl bg-white dark:bg-gray-900 transition-all duration-300 flex items-center px-3 py-2 gap-3", children: [
|
|
417
|
+
/* @__PURE__ */ jsx8(
|
|
418
|
+
"button",
|
|
419
|
+
{
|
|
420
|
+
onClick: () => setShowMenu(!showMenu),
|
|
421
|
+
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-gray-700 dark:!text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
422
|
+
title: "More options",
|
|
423
|
+
children: /* @__PURE__ */ jsx8("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx8("path", { d: "M10 5v10M5 10h10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
424
|
+
}
|
|
425
|
+
),
|
|
379
426
|
/* @__PURE__ */ jsx8(
|
|
380
427
|
"textarea",
|
|
381
428
|
{
|
|
@@ -385,9 +432,9 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
385
432
|
onKeyDown: handleKeyDown,
|
|
386
433
|
placeholder,
|
|
387
434
|
disabled,
|
|
388
|
-
className: "
|
|
435
|
+
className: "flex-1 resize-none bg-transparent border-none focus:outline-none !text-gray-900 dark:!text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 py-1 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
389
436
|
rows: 1,
|
|
390
|
-
style: { maxHeight: "
|
|
437
|
+
style: { maxHeight: "120px" }
|
|
391
438
|
}
|
|
392
439
|
),
|
|
393
440
|
/* @__PURE__ */ jsx8(
|
|
@@ -395,12 +442,23 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
395
442
|
{
|
|
396
443
|
onClick: handleSend,
|
|
397
444
|
disabled: !text.trim() || disabled,
|
|
398
|
-
className: "
|
|
399
|
-
|
|
445
|
+
className: "w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all flex-shrink-0 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 !text-gray-700 dark:!text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-30 disabled:cursor-not-allowed !text-lg",
|
|
446
|
+
title: "Send message",
|
|
447
|
+
children: /* @__PURE__ */ jsx8("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx8("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
400
448
|
}
|
|
401
449
|
)
|
|
402
450
|
] }),
|
|
403
|
-
/* @__PURE__ */ jsx8(
|
|
451
|
+
/* @__PURE__ */ jsx8(
|
|
452
|
+
"input",
|
|
453
|
+
{
|
|
454
|
+
ref: fileInputRef,
|
|
455
|
+
type: "file",
|
|
456
|
+
multiple: true,
|
|
457
|
+
onChange: handleFileSelect,
|
|
458
|
+
className: "hidden",
|
|
459
|
+
accept: "image/*,application/pdf,.doc,.docx,.txt"
|
|
460
|
+
}
|
|
461
|
+
)
|
|
404
462
|
] });
|
|
405
463
|
}
|
|
406
464
|
|
|
@@ -413,6 +471,7 @@ function Chat({
|
|
|
413
471
|
onThreadChange,
|
|
414
472
|
onMessageSent,
|
|
415
473
|
onAction,
|
|
474
|
+
onFileUpload,
|
|
416
475
|
placeholder = "Type a message...",
|
|
417
476
|
showHeader = true,
|
|
418
477
|
headerTitle = "Chat",
|
|
@@ -445,23 +504,23 @@ function Chat({
|
|
|
445
504
|
setIsLoading(false);
|
|
446
505
|
}
|
|
447
506
|
};
|
|
448
|
-
return /* @__PURE__ */ jsxs7("div", { className: cn("
|
|
449
|
-
showHeader && /* @__PURE__ */ jsxs7("div", { className: "
|
|
450
|
-
/* @__PURE__ */ jsx9("h2", { className: "text-lg font-semibold text-gray-900 dark
|
|
451
|
-
/* @__PURE__ */ jsxs7("p", { className: "text-xs text-gray-500 dark
|
|
507
|
+
return /* @__PURE__ */ jsxs7("div", { className: cn("flex flex-col h-full bg-white dark:bg-gray-900", className), children: [
|
|
508
|
+
showHeader && /* @__PURE__ */ jsxs7("div", { className: "px-4 py-3 bg-white dark:bg-gray-900", children: [
|
|
509
|
+
/* @__PURE__ */ jsx9("h2", { className: "!text-lg font-semibold !text-gray-900 dark:!text-white", children: headerTitle }),
|
|
510
|
+
/* @__PURE__ */ jsxs7("p", { className: "!text-xs !text-gray-500 dark:!text-gray-400", children: [
|
|
452
511
|
"Agent: ",
|
|
453
512
|
agentId
|
|
454
513
|
] })
|
|
455
514
|
] }),
|
|
456
515
|
/* @__PURE__ */ jsx9(MessageList, { messages, onAction }),
|
|
457
|
-
isLoading && /* @__PURE__ */ jsx9("div", { className: "px-4 py-2 text-sm text-gray-500 italic", children: "AI is thinking..." }),
|
|
458
|
-
/* @__PURE__ */ jsx9(Composer, { onSendMessage: handleSendMessage, placeholder, disabled: isLoading })
|
|
516
|
+
isLoading && /* @__PURE__ */ jsx9("div", { className: "px-4 py-2 !text-sm !text-gray-500 dark:!text-gray-400 italic", children: "AI is thinking..." }),
|
|
517
|
+
/* @__PURE__ */ jsx9(Composer, { onSendMessage: handleSendMessage, placeholder, disabled: isLoading, onFileUpload })
|
|
459
518
|
] });
|
|
460
519
|
}
|
|
461
520
|
|
|
462
521
|
// src/components/Command/Command.tsx
|
|
463
|
-
import { useState as useState3, useEffect as useEffect4 } from "react";
|
|
464
|
-
import { Fragment, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
522
|
+
import React, { useState as useState3, useEffect as useEffect4 } from "react";
|
|
523
|
+
import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
465
524
|
function Command({
|
|
466
525
|
agentId,
|
|
467
526
|
command: initialCommand,
|
|
@@ -476,6 +535,7 @@ function Command({
|
|
|
476
535
|
onChunk,
|
|
477
536
|
onComplete,
|
|
478
537
|
onError,
|
|
538
|
+
onFileUpload,
|
|
479
539
|
loadingText = "Processing...",
|
|
480
540
|
showProgress = true,
|
|
481
541
|
enableStreaming = false,
|
|
@@ -488,6 +548,7 @@ function Command({
|
|
|
488
548
|
const [progress, setProgress] = useState3(0);
|
|
489
549
|
const [command, setCommand] = useState3(initialCommand || "");
|
|
490
550
|
const [streamedContent, setStreamedContent] = useState3("");
|
|
551
|
+
const fileInputRef = React.useRef(null);
|
|
491
552
|
useEffect4(() => {
|
|
492
553
|
if (autoExecute && state === "idle" && command) {
|
|
493
554
|
executeCommand();
|
|
@@ -499,10 +560,12 @@ function Command({
|
|
|
499
560
|
setState("error");
|
|
500
561
|
return;
|
|
501
562
|
}
|
|
563
|
+
const currentCommand = command;
|
|
502
564
|
setState("loading");
|
|
503
565
|
setError(null);
|
|
504
566
|
setProgress(0);
|
|
505
567
|
setStreamedContent("");
|
|
568
|
+
setCommand("");
|
|
506
569
|
onStart?.();
|
|
507
570
|
try {
|
|
508
571
|
if (enableStreaming) {
|
|
@@ -526,7 +589,7 @@ function Command({
|
|
|
526
589
|
const mockResult = {
|
|
527
590
|
success: true,
|
|
528
591
|
data: {
|
|
529
|
-
summary: `Successfully processed: "${
|
|
592
|
+
summary: `Successfully processed: "${currentCommand}"`,
|
|
530
593
|
agentId,
|
|
531
594
|
context,
|
|
532
595
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -550,7 +613,7 @@ function Command({
|
|
|
550
613
|
const mockResult = {
|
|
551
614
|
success: true,
|
|
552
615
|
data: {
|
|
553
|
-
summary: `Command "${
|
|
616
|
+
summary: `Command "${currentCommand}" executed successfully`,
|
|
554
617
|
agentId,
|
|
555
618
|
context,
|
|
556
619
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -576,6 +639,11 @@ function Command({
|
|
|
576
639
|
setProgress(0);
|
|
577
640
|
setCommand("");
|
|
578
641
|
};
|
|
642
|
+
const handleFileSelect = (e) => {
|
|
643
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
644
|
+
onFileUpload?.(e.target.files);
|
|
645
|
+
}
|
|
646
|
+
};
|
|
579
647
|
const isCompact = variant === "compact";
|
|
580
648
|
return /* @__PURE__ */ jsxs8(
|
|
581
649
|
"div",
|
|
@@ -608,7 +676,16 @@ function Command({
|
|
|
608
676
|
rows: 6
|
|
609
677
|
}
|
|
610
678
|
),
|
|
611
|
-
state === "idle" && allowInput && isCompact && /* @__PURE__ */ jsxs8(
|
|
679
|
+
state === "idle" && allowInput && isCompact && /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
680
|
+
/* @__PURE__ */ jsx10(
|
|
681
|
+
"button",
|
|
682
|
+
{
|
|
683
|
+
onClick: () => fileInputRef.current?.click(),
|
|
684
|
+
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-gray-500 dark:!text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
685
|
+
title: "Attach file",
|
|
686
|
+
children: /* @__PURE__ */ jsx10("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx10("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)" }) })
|
|
687
|
+
}
|
|
688
|
+
),
|
|
612
689
|
/* @__PURE__ */ jsx10(
|
|
613
690
|
"input",
|
|
614
691
|
{
|
|
@@ -641,7 +718,7 @@ function Command({
|
|
|
641
718
|
!command.trim() && "border-gray-200 dark:border-gray-700 !text-gray-400 dark:!text-gray-600"
|
|
642
719
|
),
|
|
643
720
|
title: "Execute",
|
|
644
|
-
children: "
|
|
721
|
+
children: /* @__PURE__ */ jsx10("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx10("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
645
722
|
}
|
|
646
723
|
)
|
|
647
724
|
] }),
|
|
@@ -662,7 +739,7 @@ function Command({
|
|
|
662
739
|
] })
|
|
663
740
|
] })
|
|
664
741
|
] }),
|
|
665
|
-
state === "loading" && isCompact && /* @__PURE__ */ jsxs8(
|
|
742
|
+
state === "loading" && isCompact && /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
666
743
|
/* @__PURE__ */ jsxs8("div", { className: "flex-1 flex items-center gap-3 py-1", children: [
|
|
667
744
|
/* @__PURE__ */ jsx10("div", { className: "w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin" }),
|
|
668
745
|
/* @__PURE__ */ jsx10("div", { className: "text-gray-600 dark:text-gray-400 text-sm truncate", children: enableStreaming && streamedContent ? streamedContent : loadingText })
|
|
@@ -679,7 +756,7 @@ function Command({
|
|
|
679
756
|
"!text-lg",
|
|
680
757
|
"opacity-30 cursor-not-allowed"
|
|
681
758
|
),
|
|
682
|
-
children: "
|
|
759
|
+
children: /* @__PURE__ */ jsx10("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx10("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
683
760
|
}
|
|
684
761
|
)
|
|
685
762
|
] }),
|
|
@@ -718,57 +795,94 @@ function Command({
|
|
|
718
795
|
] }),
|
|
719
796
|
result.data?.summary && /* @__PURE__ */ jsx10("div", { className: "text-gray-700 dark:text-gray-300 text-sm leading-relaxed", children: result.data.summary })
|
|
720
797
|
] }) }),
|
|
721
|
-
state === "success" && result && isCompact && /* @__PURE__ */ jsxs8(
|
|
722
|
-
/* @__PURE__ */ jsxs8(
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
798
|
+
state === "success" && result && isCompact && /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
799
|
+
/* @__PURE__ */ jsxs8(
|
|
800
|
+
"div",
|
|
801
|
+
{
|
|
802
|
+
className: "flex-1 flex items-center gap-2 py-1 cursor-text",
|
|
803
|
+
onClick: () => {
|
|
804
|
+
setState("idle");
|
|
805
|
+
setResult(null);
|
|
806
|
+
},
|
|
807
|
+
children: [
|
|
808
|
+
/* @__PURE__ */ jsx10("svg", { className: "w-4 h-4 text-green-600 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx10("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
809
|
+
/* @__PURE__ */ jsx10("div", { className: "text-green-700 dark:text-green-300 text-sm truncate", children: resultRenderer ? resultRenderer(result.data) : result.message || "Command executed successfully" })
|
|
810
|
+
]
|
|
811
|
+
}
|
|
812
|
+
),
|
|
726
813
|
/* @__PURE__ */ jsx10(
|
|
727
814
|
"button",
|
|
728
815
|
{
|
|
729
|
-
|
|
816
|
+
onClick: () => {
|
|
817
|
+
setState("idle");
|
|
818
|
+
setResult(null);
|
|
819
|
+
},
|
|
730
820
|
className: cn(
|
|
731
821
|
"w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all flex-shrink-0",
|
|
732
|
-
"border border-gray-
|
|
822
|
+
"border border-gray-300 dark:border-gray-600",
|
|
733
823
|
"bg-white dark:bg-gray-800",
|
|
734
|
-
"!text-gray-
|
|
735
|
-
"
|
|
736
|
-
"
|
|
824
|
+
"!text-gray-700 dark:!text-gray-300",
|
|
825
|
+
"hover:bg-gray-50 dark:hover:bg-gray-700",
|
|
826
|
+
"!text-lg"
|
|
737
827
|
),
|
|
738
|
-
|
|
828
|
+
title: "New command",
|
|
829
|
+
children: /* @__PURE__ */ jsx10("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx10("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
739
830
|
}
|
|
740
831
|
)
|
|
741
832
|
] })
|
|
742
833
|
] }),
|
|
743
|
-
!isCompact && /* @__PURE__ */ jsxs8("div", { className: "p-3 flex items-center justify-
|
|
744
|
-
|
|
834
|
+
!isCompact && /* @__PURE__ */ jsxs8("div", { className: "p-3 flex items-center justify-between gap-2", children: [
|
|
835
|
+
state === "idle" && allowInput && /* @__PURE__ */ jsx10(
|
|
745
836
|
"button",
|
|
746
837
|
{
|
|
747
|
-
onClick:
|
|
748
|
-
className: "
|
|
749
|
-
|
|
838
|
+
onClick: () => fileInputRef.current?.click(),
|
|
839
|
+
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-gray-500 dark:!text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
840
|
+
title: "Attach file",
|
|
841
|
+
children: /* @__PURE__ */ jsx10("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx10("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)" }) })
|
|
750
842
|
}
|
|
751
843
|
),
|
|
752
|
-
(state === "idle"
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
"
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
844
|
+
!(state === "idle" && allowInput) && /* @__PURE__ */ jsx10("div", {}),
|
|
845
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", children: [
|
|
846
|
+
(state === "success" || state === "error") && allowInput && /* @__PURE__ */ jsx10(
|
|
847
|
+
"button",
|
|
848
|
+
{
|
|
849
|
+
onClick: resetCommand,
|
|
850
|
+
className: "px-3 py-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",
|
|
851
|
+
children: "Reset"
|
|
852
|
+
}
|
|
853
|
+
),
|
|
854
|
+
(state === "idle" || state === "error") && /* @__PURE__ */ jsx10(
|
|
855
|
+
"button",
|
|
856
|
+
{
|
|
857
|
+
onClick: executeCommand,
|
|
858
|
+
disabled: !command.trim(),
|
|
859
|
+
className: cn(
|
|
860
|
+
"w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all",
|
|
861
|
+
"border border-gray-300 dark:border-gray-600",
|
|
862
|
+
"bg-white dark:bg-gray-800",
|
|
863
|
+
"!text-gray-700 dark:!text-gray-300",
|
|
864
|
+
"hover:bg-gray-50 dark:hover:bg-gray-700",
|
|
865
|
+
"disabled:opacity-30 disabled:cursor-not-allowed",
|
|
866
|
+
"!text-lg",
|
|
867
|
+
!command.trim() && "border-gray-200 dark:border-gray-700 !text-gray-400 dark:!text-gray-600"
|
|
868
|
+
),
|
|
869
|
+
title: state === "error" ? "Retry" : "Execute",
|
|
870
|
+
children: state === "error" ? /* @__PURE__ */ jsx10("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx10("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__ */ jsx10("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx10("path", { d: "M8 3L8 13M8 3L4 7M8 3L12 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
871
|
+
}
|
|
872
|
+
)
|
|
873
|
+
] })
|
|
771
874
|
] }),
|
|
875
|
+
/* @__PURE__ */ jsx10(
|
|
876
|
+
"input",
|
|
877
|
+
{
|
|
878
|
+
ref: fileInputRef,
|
|
879
|
+
type: "file",
|
|
880
|
+
multiple: true,
|
|
881
|
+
onChange: handleFileSelect,
|
|
882
|
+
className: "hidden",
|
|
883
|
+
accept: "image/*,application/pdf,.doc,.docx,.txt"
|
|
884
|
+
}
|
|
885
|
+
),
|
|
772
886
|
/* @__PURE__ */ jsx10("style", { dangerouslySetInnerHTML: {
|
|
773
887
|
__html: `
|
|
774
888
|
@keyframes pulse-border {
|