@apteva/apteva-kit 0.1.87 → 0.1.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -761,6 +761,10 @@ var WIDGET_DEFINITIONS = {
761
761
  chart: {
762
762
  schema: "chartType: line|bar|pie, data: {labels, datasets}",
763
763
  example: '@ui:chart[{"chartType": "bar", "data": {"labels": ["A"], "datasets": [{"label": "X", "data": [10]}]}}]'
764
+ },
765
+ flow: {
766
+ schema: "title, subtitle?, icon?: research|schedule|analyze|deploy, steps: [{id, label, type?: time|agent|email|slack|build|test|deploy, status?: pending|active|completed|error}], actions?: [{type, label}] - Horizontal pipeline with action button. Use @label for agents.",
767
+ example: '@ui:flow[{"title": "Deploy to Production", "icon": "deploy", "steps": [{"id": "1", "label": "Test"}, {"id": "2", "label": "Build"}, {"id": "3", "label": "Deploy"}], "actions": [{"type": "run", "label": "Run"}]}]'
764
768
  }
765
769
  };
766
770
  var ALL_WIDGET_TYPES = Object.keys(WIDGET_DEFINITIONS);
@@ -1222,6 +1226,153 @@ function Image({ widget }) {
1222
1226
  ] });
1223
1227
  }
1224
1228
 
1229
+ // src/components/Widgets/widget-library/Flow.tsx
1230
+
1231
+ function StepIcon({ type, status }) {
1232
+ if (status === "completed") {
1233
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5 text-emerald-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2.5, d: "M5 13l4 4L19 7" }) });
1234
+ }
1235
+ if (status === "error") {
1236
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5 text-red-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2.5, d: "M6 18L18 6M6 6l12 12" }) });
1237
+ }
1238
+ if (status === "active") {
1239
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-3 h-3 rounded-full bg-blue-400 animate-pulse" });
1240
+ }
1241
+ if (type === "time" || type === "schedule") {
1242
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" }) });
1243
+ }
1244
+ if (type === "agent" || _optionalChain([type, 'optionalAccess', _28 => _28.startsWith, 'call', _29 => _29("@")])) {
1245
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z" }) });
1246
+ }
1247
+ if (type === "email" || type === "mail") {
1248
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" }) });
1249
+ }
1250
+ if (type === "slack" || type === "message") {
1251
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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" }) });
1252
+ }
1253
+ if (type === "build" || type === "compile") {
1254
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" }) });
1255
+ }
1256
+ if (type === "test") {
1257
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 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-6 9l2 2 4-4" }) });
1258
+ }
1259
+ if (type === "deploy" || type === "rocket") {
1260
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) });
1261
+ }
1262
+ if (type === "push" || type === "upload") {
1263
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" }) });
1264
+ }
1265
+ if (type === "generate" || type === "create" || type === "document") {
1266
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) });
1267
+ }
1268
+ if (type === "review" || type === "check") {
1269
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
1270
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" }),
1271
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" })
1272
+ ] });
1273
+ }
1274
+ if (type === "analyze" || type === "research") {
1275
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3.5 h-3.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" }) });
1276
+ }
1277
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-2.5 h-2.5 rounded-full bg-current opacity-60" });
1278
+ }
1279
+ function HeaderIcon({ icon }) {
1280
+ const baseClass = "w-5 h-5";
1281
+ if (icon === "research" || icon === "multi-agent") {
1282
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-8 h-8 rounded-lg bg-purple-500/20 flex items-center justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: `${baseClass} text-purple-400`, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) });
1283
+ }
1284
+ if (icon === "schedule" || icon === "report") {
1285
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-8 h-8 rounded-lg bg-amber-500/20 flex items-center justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: `${baseClass} text-amber-400`, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) });
1286
+ }
1287
+ if (icon === "analyze" || icon === "analysis") {
1288
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-8 h-8 rounded-lg bg-cyan-500/20 flex items-center justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: `${baseClass} text-cyan-400`, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" }) }) });
1289
+ }
1290
+ if (icon === "deploy" || icon === "rocket") {
1291
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-8 h-8 rounded-lg bg-blue-500/20 flex items-center justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: `${baseClass} text-blue-400`, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) });
1292
+ }
1293
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-8 h-8 rounded-lg bg-blue-500/20 flex items-center justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: `${baseClass} text-blue-400`, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 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 2" }) }) });
1294
+ }
1295
+ function Chevron() {
1296
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3 h-3 text-neutral-500 flex-shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) });
1297
+ }
1298
+ function Flow({ widget, onAction }) {
1299
+ const { title, subtitle, icon, steps, actions } = widget.props;
1300
+ const handleAction = (actionType) => {
1301
+ _optionalChain([onAction, 'optionalCall', _30 => _30({
1302
+ type: actionType,
1303
+ payload: { steps, title },
1304
+ widgetId: widget.id,
1305
+ timestamp: /* @__PURE__ */ new Date()
1306
+ })]);
1307
+ };
1308
+ const handleDismiss = () => {
1309
+ _optionalChain([onAction, 'optionalCall', _31 => _31({
1310
+ type: "dismiss",
1311
+ payload: { title },
1312
+ widgetId: widget.id,
1313
+ timestamp: /* @__PURE__ */ new Date()
1314
+ })]);
1315
+ };
1316
+ const primaryAction = _optionalChain([widget, 'access', _32 => _32.actions, 'optionalAccess', _33 => _33[0]]) || _optionalChain([actions, 'optionalAccess', _34 => _34[0]]);
1317
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rounded-xl bg-neutral-900 border border-neutral-800 overflow-hidden", children: [
1318
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "px-4 py-3 flex items-center gap-3", children: [
1319
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, HeaderIcon, { icon }),
1320
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex-1 min-w-0", children: [
1321
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "font-semibold text-sm text-white truncate", children: title }),
1322
+ subtitle && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-neutral-400 truncate", children: subtitle })
1323
+ ] }),
1324
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
1325
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1326
+ "button",
1327
+ {
1328
+ onClick: handleDismiss,
1329
+ className: "p-1.5 text-neutral-500 hover:text-neutral-300 transition-colors",
1330
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
1331
+ }
1332
+ ),
1333
+ primaryAction && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1334
+ "button",
1335
+ {
1336
+ onClick: () => handleAction(primaryAction.type),
1337
+ className: "px-3 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-xs font-medium rounded-lg flex items-center gap-1.5 transition-colors",
1338
+ children: [
1339
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M8 5v14l11-7z" }) }),
1340
+ primaryAction.label
1341
+ ]
1342
+ }
1343
+ )
1344
+ ] })
1345
+ ] }),
1346
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "px-4 pb-4", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex flex-wrap items-center gap-2", children: steps.map((step, index) => {
1347
+ const isLast = index === steps.length - 1;
1348
+ const isActive = step.status === "active";
1349
+ const isCompleted = step.status === "completed";
1350
+ const isError = step.status === "error";
1351
+ const isSkipped = step.status === "skipped";
1352
+ const label = step.label;
1353
+ let stepType = step.type;
1354
+ if (!stepType) {
1355
+ if (label.startsWith("@")) stepType = "agent";
1356
+ else if (label.toLowerCase().includes("am") || label.toLowerCase().includes("pm") || /^\d/.test(label)) stepType = "time";
1357
+ else if (["test", "build", "push", "deploy", "email", "slack", "generate", "review", "analyze"].includes(label.toLowerCase())) {
1358
+ stepType = label.toLowerCase();
1359
+ }
1360
+ }
1361
+ const pillClasses = `
1362
+ inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-full text-xs font-medium transition-colors
1363
+ ${isActive ? "bg-blue-500/20 text-blue-300 ring-1 ring-blue-500/50" : isCompleted ? "bg-emerald-500/15 text-emerald-300" : isError ? "bg-red-500/15 text-red-300" : isSkipped ? "bg-neutral-700/50 text-neutral-500 line-through" : "bg-neutral-800 text-neutral-300"}
1364
+ `;
1365
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
1366
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: pillClasses, children: [
1367
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StepIcon, { type: stepType, status: step.status }),
1368
+ label
1369
+ ] }),
1370
+ !isLast && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Chevron, {})
1371
+ ] }, step.id);
1372
+ }) }) })
1373
+ ] });
1374
+ }
1375
+
1225
1376
  // src/components/Widgets/WidgetRenderer.tsx
1226
1377
 
1227
1378
  function WidgetRenderer({ widget, onAction }) {
@@ -1241,6 +1392,8 @@ function WidgetRenderer({ widget, onAction }) {
1241
1392
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Form, { widget, onAction });
1242
1393
  case "image":
1243
1394
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Image, { widget });
1395
+ case "flow":
1396
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Flow, { widget });
1244
1397
  default:
1245
1398
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border border-yellow-300 bg-yellow-50 rounded-lg", children: [
1246
1399
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-yellow-800", children: [
@@ -1267,7 +1420,7 @@ function Widgets({
1267
1420
  }) {
1268
1421
  _react.useEffect.call(void 0, () => {
1269
1422
  widgets.forEach((widget) => {
1270
- _optionalChain([onWidgetMount, 'optionalCall', _28 => _28(widget.id)]);
1423
+ _optionalChain([onWidgetMount, 'optionalCall', _35 => _35(widget.id)]);
1271
1424
  });
1272
1425
  }, [widgets, onWidgetMount]);
1273
1426
  const layoutClasses = {
@@ -1593,8 +1746,8 @@ function ToolCall({ name, status, isReceiving = false, inputLength = 0, streamOu
1593
1746
 
1594
1747
  function Message({ message, onAction, enableWidgets, onWidgetRender }) {
1595
1748
  const isUser = message.role === "user";
1596
- const contentSegments = _optionalChain([message, 'access', _29 => _29.metadata, 'optionalAccess', _30 => _30.content_segments]);
1597
- const isStreaming = _optionalChain([message, 'access', _31 => _31.metadata, 'optionalAccess', _32 => _32.isStreaming]) === true;
1749
+ const contentSegments = _optionalChain([message, 'access', _36 => _36.metadata, 'optionalAccess', _37 => _37.content_segments]);
1750
+ const isStreaming = _optionalChain([message, 'access', _38 => _38.metadata, 'optionalAccess', _39 => _39.isStreaming]) === true;
1598
1751
  const hasContent = message.content || contentSegments && contentSegments.length > 0;
1599
1752
  const reportedWidgetsRef = _react.useRef.call(void 0, /* @__PURE__ */ new Set());
1600
1753
  const parsedWidgets = _react.useMemo.call(void 0, () => {
@@ -1674,7 +1827,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
1674
1827
  }
1675
1828
  return elements.length > 0 ? elements : null;
1676
1829
  };
1677
- const attachments = _optionalChain([message, 'access', _33 => _33.metadata, 'optionalAccess', _34 => _34.attachments]) || [];
1830
+ const attachments = _optionalChain([message, 'access', _40 => _40.metadata, 'optionalAccess', _41 => _41.attachments]) || [];
1678
1831
  const hasAttachments = attachments.length > 0;
1679
1832
  const renderAttachments = () => {
1680
1833
  if (!hasAttachments) return null;
@@ -2081,7 +2234,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
2081
2234
  setFileError(errors.join(", "));
2082
2235
  setTimeout(() => setFileError(null), 5e3);
2083
2236
  }
2084
- _optionalChain([onFileUpload, 'optionalCall', _35 => _35(e.target.files)]);
2237
+ _optionalChain([onFileUpload, 'optionalCall', _42 => _42(e.target.files)]);
2085
2238
  setShowMenu(false);
2086
2239
  e.target.value = "";
2087
2240
  }
@@ -2151,15 +2304,15 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
2151
2304
  {
2152
2305
  className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
2153
2306
  style: {
2154
- left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.getBoundingClientRect, 'call', _38 => _38(), 'access', _39 => _39.left]), () => ( 0)),
2155
- top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _40 => _40.current, 'optionalAccess', _41 => _41.getBoundingClientRect, 'call', _42 => _42(), 'access', _43 => _43.bottom]), () => ( 0))) + 8
2307
+ left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.getBoundingClientRect, 'call', _45 => _45(), 'access', _46 => _46.left]), () => ( 0)),
2308
+ top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _47 => _47.current, 'optionalAccess', _48 => _48.getBoundingClientRect, 'call', _49 => _49(), 'access', _50 => _50.bottom]), () => ( 0))) + 8
2156
2309
  },
2157
2310
  children: [
2158
2311
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2159
2312
  "button",
2160
2313
  {
2161
2314
  onClick: () => {
2162
- _optionalChain([fileInputRef, 'access', _44 => _44.current, 'optionalAccess', _45 => _45.click, 'call', _46 => _46()]);
2315
+ _optionalChain([fileInputRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.click, 'call', _53 => _53()]);
2163
2316
  setShowMenu(false);
2164
2317
  },
2165
2318
  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",
@@ -2277,8 +2430,8 @@ function CommandComposer({
2277
2430
  }
2278
2431
  };
2279
2432
  const handleNewCommand = () => {
2280
- _optionalChain([onReset, 'optionalCall', _47 => _47()]);
2281
- _optionalChain([inputRef, 'access', _48 => _48.current, 'optionalAccess', _49 => _49.focus, 'call', _50 => _50()]);
2433
+ _optionalChain([onReset, 'optionalCall', _54 => _54()]);
2434
+ _optionalChain([inputRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.focus, 'call', _57 => _57()]);
2282
2435
  };
2283
2436
  const handleInputChange = (value) => {
2284
2437
  setInput(value);
@@ -2392,15 +2545,15 @@ function CommandComposer({
2392
2545
  {
2393
2546
  className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
2394
2547
  style: {
2395
- left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.getBoundingClientRect, 'call', _53 => _53(), 'access', _54 => _54.left]), () => ( 0)),
2396
- top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.getBoundingClientRect, 'call', _57 => _57(), 'access', _58 => _58.bottom]), () => ( 0))) + 8
2548
+ left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _58 => _58.current, 'optionalAccess', _59 => _59.getBoundingClientRect, 'call', _60 => _60(), 'access', _61 => _61.left]), () => ( 0)),
2549
+ top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _62 => _62.current, 'optionalAccess', _63 => _63.getBoundingClientRect, 'call', _64 => _64(), 'access', _65 => _65.bottom]), () => ( 0))) + 8
2397
2550
  },
2398
2551
  children: [
2399
2552
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2400
2553
  "button",
2401
2554
  {
2402
2555
  onClick: () => {
2403
- _optionalChain([fileInputRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.click, 'call', _61 => _61()]);
2556
+ _optionalChain([fileInputRef, 'access', _66 => _66.current, 'optionalAccess', _67 => _67.click, 'call', _68 => _68()]);
2404
2557
  setShowMenu(false);
2405
2558
  },
2406
2559
  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",
@@ -2641,7 +2794,7 @@ var AptevaClient = class {
2641
2794
  const error = await response.json().catch(() => ({ error: "Request failed" }));
2642
2795
  throw new Error(error.error || `Request failed with status ${response.status}`);
2643
2796
  }
2644
- const reader = _optionalChain([response, 'access', _62 => _62.body, 'optionalAccess', _63 => _63.getReader, 'call', _64 => _64()]);
2797
+ const reader = _optionalChain([response, 'access', _69 => _69.body, 'optionalAccess', _70 => _70.getReader, 'call', _71 => _71()]);
2645
2798
  if (!reader) {
2646
2799
  throw new Error("Response body is not readable");
2647
2800
  }
@@ -2659,7 +2812,7 @@ var AptevaClient = class {
2659
2812
  if (line.startsWith("data: ")) {
2660
2813
  const data = line.slice(6);
2661
2814
  if (data === "[DONE]") {
2662
- _optionalChain([onComplete, 'optionalCall', _65 => _65(threadId)]);
2815
+ _optionalChain([onComplete, 'optionalCall', _72 => _72(threadId)]);
2663
2816
  return;
2664
2817
  }
2665
2818
  try {
@@ -2674,10 +2827,10 @@ var AptevaClient = class {
2674
2827
  }
2675
2828
  }
2676
2829
  }
2677
- _optionalChain([onComplete, 'optionalCall', _66 => _66(threadId)]);
2830
+ _optionalChain([onComplete, 'optionalCall', _73 => _73(threadId)]);
2678
2831
  } catch (error) {
2679
2832
  const err = error instanceof Error ? error : new Error("Unknown error");
2680
- _optionalChain([onError, 'optionalCall', _67 => _67(err)]);
2833
+ _optionalChain([onError, 'optionalCall', _74 => _74(err)]);
2681
2834
  throw err;
2682
2835
  }
2683
2836
  }
@@ -2837,7 +2990,7 @@ ${widgetContext}` : widgetContext;
2837
2990
  }, [apiUrl, apiKey]);
2838
2991
  _react.useEffect.call(void 0, () => {
2839
2992
  if (threadId) {
2840
- _optionalChain([onThreadChange, 'optionalCall', _68 => _68(threadId)]);
2993
+ _optionalChain([onThreadChange, 'optionalCall', _75 => _75(threadId)]);
2841
2994
  }
2842
2995
  }, [threadId, onThreadChange]);
2843
2996
  _react.useEffect.call(void 0, () => {
@@ -2855,7 +3008,7 @@ ${widgetContext}` : widgetContext;
2855
3008
  }, [showSettingsMenu]);
2856
3009
  const handleModeChange = (newMode) => {
2857
3010
  setMode(newMode);
2858
- _optionalChain([onModeChange, 'optionalCall', _69 => _69(newMode)]);
3011
+ _optionalChain([onModeChange, 'optionalCall', _76 => _76(newMode)]);
2859
3012
  if (newMode === "command") {
2860
3013
  setCommandState("idle");
2861
3014
  setCommandResult(null);
@@ -2880,7 +3033,7 @@ ${widgetContext}` : widgetContext;
2880
3033
  metadata: hasFiles ? { attachments } : void 0
2881
3034
  };
2882
3035
  setMessages((prev) => [...prev, userMessage]);
2883
- _optionalChain([onMessageSent, 'optionalCall', _70 => _70(userMessage)]);
3036
+ _optionalChain([onMessageSent, 'optionalCall', _77 => _77(userMessage)]);
2884
3037
  }
2885
3038
  setIsLoading(true);
2886
3039
  try {
@@ -2948,7 +3101,7 @@ ${widgetContext}` : widgetContext;
2948
3101
  responseThreadId = chunk.thread_id;
2949
3102
  if (!currentThreadId) {
2950
3103
  setCurrentThreadId(chunk.thread_id);
2951
- _optionalChain([onThreadChange, 'optionalCall', _71 => _71(chunk.thread_id)]);
3104
+ _optionalChain([onThreadChange, 'optionalCall', _78 => _78(chunk.thread_id)]);
2952
3105
  }
2953
3106
  }
2954
3107
  break;
@@ -2974,7 +3127,7 @@ ${widgetContext}` : widgetContext;
2974
3127
  contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
2975
3128
  toolInputBuffers[chunk.tool_id] = "";
2976
3129
  setChatToolName(displayName);
2977
- _optionalChain([onToolCall, 'optionalCall', _72 => _72(chunk.tool_name, chunk.tool_id)]);
3130
+ _optionalChain([onToolCall, 'optionalCall', _79 => _79(chunk.tool_name, chunk.tool_id)]);
2978
3131
  updateMessage();
2979
3132
  }
2980
3133
  break;
@@ -3034,7 +3187,7 @@ ${widgetContext}` : widgetContext;
3034
3187
  toolSegment.result = chunk.content;
3035
3188
  toolSegment.status = "completed";
3036
3189
  toolSegment.isReceiving = false;
3037
- _optionalChain([onToolResult, 'optionalCall', _73 => _73(toolSegment.name, chunk.content)]);
3190
+ _optionalChain([onToolResult, 'optionalCall', _80 => _80(toolSegment.name, chunk.content)]);
3038
3191
  }
3039
3192
  setChatToolName(null);
3040
3193
  updateMessage();
@@ -3077,7 +3230,7 @@ ${widgetContext}` : widgetContext;
3077
3230
  });
3078
3231
  if (threadId2 && threadId2 !== currentThreadId) {
3079
3232
  setCurrentThreadId(threadId2);
3080
- _optionalChain([onThreadChange, 'optionalCall', _74 => _74(threadId2)]);
3233
+ _optionalChain([onThreadChange, 'optionalCall', _81 => _81(threadId2)]);
3081
3234
  }
3082
3235
  setIsLoading(false);
3083
3236
  setCurrentRequestId(null);
@@ -3101,7 +3254,7 @@ ${widgetContext}` : widgetContext;
3101
3254
  setIsLoading(false);
3102
3255
  setCurrentRequestId(null);
3103
3256
  setChatToolName(null);
3104
- _optionalChain([onError, 'optionalCall', _75 => _75(error)]);
3257
+ _optionalChain([onError, 'optionalCall', _82 => _82(error)]);
3105
3258
  }
3106
3259
  );
3107
3260
  }
@@ -3114,7 +3267,7 @@ ${widgetContext}` : widgetContext;
3114
3267
  metadata: { error: true }
3115
3268
  };
3116
3269
  setMessages((prev) => [...prev, errorMessage]);
3117
- _optionalChain([onError, 'optionalCall', _76 => _76(error instanceof Error ? error : new Error("Unknown error"))]);
3270
+ _optionalChain([onError, 'optionalCall', _83 => _83(error instanceof Error ? error : new Error("Unknown error"))]);
3118
3271
  } finally {
3119
3272
  setIsLoading(false);
3120
3273
  }
@@ -3160,7 +3313,7 @@ ${planningInstruction}` : planningInstruction;
3160
3313
  const error = err instanceof Error ? err : new Error("Failed to generate plan");
3161
3314
  setCommandError(error);
3162
3315
  setCommandState("error");
3163
- _optionalChain([onError, 'optionalCall', _77 => _77(error)]);
3316
+ _optionalChain([onError, 'optionalCall', _84 => _84(error)]);
3164
3317
  }
3165
3318
  }
3166
3319
  return;
@@ -3193,12 +3346,12 @@ ${planningInstruction}` : planningInstruction;
3193
3346
  setCommandResult(result);
3194
3347
  setCommandState("success");
3195
3348
  setProgress(100);
3196
- _optionalChain([onComplete, 'optionalCall', _78 => _78(result)]);
3349
+ _optionalChain([onComplete, 'optionalCall', _85 => _85(result)]);
3197
3350
  },
3198
3351
  (error) => {
3199
3352
  setCommandError(error);
3200
3353
  setCommandState("error");
3201
- _optionalChain([onError, 'optionalCall', _79 => _79(error)]);
3354
+ _optionalChain([onError, 'optionalCall', _86 => _86(error)]);
3202
3355
  }
3203
3356
  );
3204
3357
  } else {
@@ -3211,7 +3364,7 @@ ${planningInstruction}` : planningInstruction;
3211
3364
  setCommandResult(result);
3212
3365
  setCommandState("success");
3213
3366
  setProgress(100);
3214
- _optionalChain([onComplete, 'optionalCall', _80 => _80(result)]);
3367
+ _optionalChain([onComplete, 'optionalCall', _87 => _87(result)]);
3215
3368
  }
3216
3369
  } else {
3217
3370
  const commandInstruction = `CRITICAL COMMAND MODE: Maximum 10 words per response. Execute the command immediately. Make reasonable assumptions based on context. Use sensible defaults for missing details. DO NOT ask questions unless something is truly impossible without user input (e.g., missing required password). State what you're doing or the result. Examples: "Analyzing customer data from last quarter..." or "Created 5 new database entries successfully" or "Search complete: found 12 matching results". NO greetings, NO filler words, NO clarification requests. Action/result only.`;
@@ -3241,16 +3394,16 @@ ${commandInstruction}` : commandInstruction;
3241
3394
  const displayName = chunk.tool_display_name || chunk.tool_name;
3242
3395
  lastToolName = chunk.tool_name;
3243
3396
  setCurrentToolName(displayName);
3244
- _optionalChain([onToolCall, 'optionalCall', _81 => _81(chunk.tool_name, chunk.tool_id || "")]);
3397
+ _optionalChain([onToolCall, 'optionalCall', _88 => _88(chunk.tool_name, chunk.tool_id || "")]);
3245
3398
  accumulatedContent = "";
3246
3399
  setStreamedContent("");
3247
3400
  } else if (chunk.type === "tool_result") {
3248
- _optionalChain([onToolResult, 'optionalCall', _82 => _82(lastToolName, chunk.content)]);
3401
+ _optionalChain([onToolResult, 'optionalCall', _89 => _89(lastToolName, chunk.content)]);
3249
3402
  setCurrentToolName(null);
3250
3403
  } else if (chunk.type === "thread_id" && chunk.thread_id) {
3251
3404
  if (!currentThreadId) {
3252
3405
  setCurrentThreadId(chunk.thread_id);
3253
- _optionalChain([onThreadChange, 'optionalCall', _83 => _83(chunk.thread_id)]);
3406
+ _optionalChain([onThreadChange, 'optionalCall', _90 => _90(chunk.thread_id)]);
3254
3407
  }
3255
3408
  } else if (chunk.type === "request_id" && chunk.request_id) {
3256
3409
  setCurrentRequestId(chunk.request_id);
@@ -3266,13 +3419,13 @@ ${commandInstruction}` : commandInstruction;
3266
3419
  setCommandState("success");
3267
3420
  setProgress(100);
3268
3421
  setCurrentRequestId(null);
3269
- _optionalChain([onComplete, 'optionalCall', _84 => _84(result)]);
3422
+ _optionalChain([onComplete, 'optionalCall', _91 => _91(result)]);
3270
3423
  },
3271
3424
  (error) => {
3272
3425
  setCommandError(error);
3273
3426
  setCommandState("error");
3274
3427
  setCurrentRequestId(null);
3275
- _optionalChain([onError, 'optionalCall', _85 => _85(error)]);
3428
+ _optionalChain([onError, 'optionalCall', _92 => _92(error)]);
3276
3429
  }
3277
3430
  );
3278
3431
  } else {
@@ -3292,14 +3445,14 @@ ${commandInstruction}` : commandInstruction;
3292
3445
  setCommandResult(result);
3293
3446
  setCommandState("success");
3294
3447
  setProgress(100);
3295
- _optionalChain([onComplete, 'optionalCall', _86 => _86(result)]);
3448
+ _optionalChain([onComplete, 'optionalCall', _93 => _93(result)]);
3296
3449
  }
3297
3450
  }
3298
3451
  } catch (err) {
3299
3452
  const error = err instanceof Error ? err : new Error("Unknown error");
3300
3453
  setCommandError(error);
3301
3454
  setCommandState("error");
3302
- _optionalChain([onError, 'optionalCall', _87 => _87(error)]);
3455
+ _optionalChain([onError, 'optionalCall', _94 => _94(error)]);
3303
3456
  }
3304
3457
  };
3305
3458
  const resetCommand = () => {
@@ -3391,8 +3544,8 @@ ${planToExecute}`;
3391
3544
  executeCommand(text, files);
3392
3545
  },
3393
3546
  state: commandState,
3394
- response: _optionalChain([commandResult, 'optionalAccess', _88 => _88.data, 'optionalAccess', _89 => _89.summary]) || _optionalChain([commandResult, 'optionalAccess', _90 => _90.message]),
3395
- error: _optionalChain([commandError, 'optionalAccess', _91 => _91.message]),
3547
+ response: _optionalChain([commandResult, 'optionalAccess', _95 => _95.data, 'optionalAccess', _96 => _96.summary]) || _optionalChain([commandResult, 'optionalAccess', _97 => _97.message]),
3548
+ error: _optionalChain([commandError, 'optionalAccess', _98 => _98.message]),
3396
3549
  plan,
3397
3550
  streamedContent,
3398
3551
  toolName: currentToolName,
@@ -3560,13 +3713,13 @@ ${planningInstruction}` : planningInstruction;
3560
3713
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
3561
3714
  setError(error2);
3562
3715
  setState("error");
3563
- _optionalChain([onError, 'optionalCall', _92 => _92(error2)]);
3716
+ _optionalChain([onError, 'optionalCall', _99 => _99(error2)]);
3564
3717
  });
3565
3718
  } catch (err) {
3566
3719
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
3567
3720
  setError(error2);
3568
3721
  setState("error");
3569
- _optionalChain([onError, 'optionalCall', _93 => _93(error2)]);
3722
+ _optionalChain([onError, 'optionalCall', _100 => _100(error2)]);
3570
3723
  }
3571
3724
  }
3572
3725
  return;
@@ -3577,7 +3730,7 @@ ${planningInstruction}` : planningInstruction;
3577
3730
  setStreamedContent("");
3578
3731
  setCommand("");
3579
3732
  setUploadedFiles([]);
3580
- _optionalChain([onStart, 'optionalCall', _94 => _94()]);
3733
+ _optionalChain([onStart, 'optionalCall', _101 => _101()]);
3581
3734
  try {
3582
3735
  if (useMock) {
3583
3736
  if (enableStreaming) {
@@ -3588,16 +3741,16 @@ ${planningInstruction}` : planningInstruction;
3588
3741
  if (chunk.type === "token" && chunk.content) {
3589
3742
  accumulatedContent += chunk.content;
3590
3743
  setStreamedContent(accumulatedContent);
3591
- _optionalChain([onChunk, 'optionalCall', _95 => _95(chunk.content)]);
3744
+ _optionalChain([onChunk, 'optionalCall', _102 => _102(chunk.content)]);
3592
3745
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
3593
3746
  setProgress(estimatedProgress);
3594
- _optionalChain([onProgress, 'optionalCall', _96 => _96(estimatedProgress)]);
3747
+ _optionalChain([onProgress, 'optionalCall', _103 => _103(estimatedProgress)]);
3595
3748
  } else if (chunk.type === "widget" && chunk.widget) {
3596
3749
  const widget = chunk.widget;
3597
3750
  setResult((prev) => ({
3598
3751
  success: true,
3599
- data: _optionalChain([prev, 'optionalAccess', _97 => _97.data]) || {},
3600
- widgets: [..._optionalChain([prev, 'optionalAccess', _98 => _98.widgets]) || [], widget],
3752
+ data: _optionalChain([prev, 'optionalAccess', _104 => _104.data]) || {},
3753
+ widgets: [..._optionalChain([prev, 'optionalAccess', _105 => _105.widgets]) || [], widget],
3601
3754
  message: accumulatedContent || "Command executed successfully"
3602
3755
  }));
3603
3756
  }
@@ -3617,19 +3770,19 @@ ${planningInstruction}` : planningInstruction;
3617
3770
  setResult(result2);
3618
3771
  setState("success");
3619
3772
  setProgress(100);
3620
- _optionalChain([onComplete, 'optionalCall', _99 => _99(result2)]);
3773
+ _optionalChain([onComplete, 'optionalCall', _106 => _106(result2)]);
3621
3774
  },
3622
3775
  (error2) => {
3623
3776
  setError(error2);
3624
3777
  setState("error");
3625
- _optionalChain([onError, 'optionalCall', _100 => _100(error2)]);
3778
+ _optionalChain([onError, 'optionalCall', _107 => _107(error2)]);
3626
3779
  }
3627
3780
  );
3628
3781
  } else {
3629
3782
  const progressInterval = setInterval(() => {
3630
3783
  setProgress((prev) => {
3631
3784
  const next = Math.min(prev + 10, 90);
3632
- _optionalChain([onProgress, 'optionalCall', _101 => _101(next)]);
3785
+ _optionalChain([onProgress, 'optionalCall', _108 => _108(next)]);
3633
3786
  return next;
3634
3787
  });
3635
3788
  }, 200);
@@ -3653,7 +3806,7 @@ ${planningInstruction}` : planningInstruction;
3653
3806
  setResult(result2);
3654
3807
  setState("success");
3655
3808
  setProgress(100);
3656
- _optionalChain([onComplete, 'optionalCall', _102 => _102(result2)]);
3809
+ _optionalChain([onComplete, 'optionalCall', _109 => _109(result2)]);
3657
3810
  }
3658
3811
  } else {
3659
3812
  if (enableStreaming) {
@@ -3699,16 +3852,16 @@ ${commandInstruction}` : commandInstruction;
3699
3852
  if (chunk.type === "token" && chunk.content) {
3700
3853
  accumulatedContent += chunk.content;
3701
3854
  setStreamedContent(accumulatedContent);
3702
- _optionalChain([onChunk, 'optionalCall', _103 => _103(chunk.content)]);
3855
+ _optionalChain([onChunk, 'optionalCall', _110 => _110(chunk.content)]);
3703
3856
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
3704
3857
  setProgress(estimatedProgress);
3705
- _optionalChain([onProgress, 'optionalCall', _104 => _104(estimatedProgress)]);
3858
+ _optionalChain([onProgress, 'optionalCall', _111 => _111(estimatedProgress)]);
3706
3859
  } else if (chunk.type === "widget" && chunk.widget) {
3707
3860
  const widget = chunk.widget;
3708
3861
  setResult((prev) => ({
3709
3862
  success: true,
3710
- data: _optionalChain([prev, 'optionalAccess', _105 => _105.data]) || {},
3711
- widgets: [..._optionalChain([prev, 'optionalAccess', _106 => _106.widgets]) || [], widget],
3863
+ data: _optionalChain([prev, 'optionalAccess', _112 => _112.data]) || {},
3864
+ widgets: [..._optionalChain([prev, 'optionalAccess', _113 => _113.widgets]) || [], widget],
3712
3865
  message: accumulatedContent || "Command executed successfully"
3713
3866
  }));
3714
3867
  }
@@ -3728,20 +3881,20 @@ ${commandInstruction}` : commandInstruction;
3728
3881
  setResult(result2);
3729
3882
  setState("success");
3730
3883
  setProgress(100);
3731
- _optionalChain([onComplete, 'optionalCall', _107 => _107(result2)]);
3884
+ _optionalChain([onComplete, 'optionalCall', _114 => _114(result2)]);
3732
3885
  },
3733
3886
  (error2) => {
3734
3887
  const err = error2 instanceof Error ? error2 : new Error("Unknown error");
3735
3888
  setError(err);
3736
3889
  setState("error");
3737
- _optionalChain([onError, 'optionalCall', _108 => _108(err)]);
3890
+ _optionalChain([onError, 'optionalCall', _115 => _115(err)]);
3738
3891
  }
3739
3892
  );
3740
3893
  } else {
3741
3894
  const progressInterval = setInterval(() => {
3742
3895
  setProgress((prev) => {
3743
3896
  const next = Math.min(prev + 10, 90);
3744
- _optionalChain([onProgress, 'optionalCall', _109 => _109(next)]);
3897
+ _optionalChain([onProgress, 'optionalCall', _116 => _116(next)]);
3745
3898
  return next;
3746
3899
  });
3747
3900
  }, 200);
@@ -3797,14 +3950,14 @@ ${commandInstruction}` : commandInstruction;
3797
3950
  setResult(result2);
3798
3951
  setState("success");
3799
3952
  setProgress(100);
3800
- _optionalChain([onComplete, 'optionalCall', _110 => _110(result2)]);
3953
+ _optionalChain([onComplete, 'optionalCall', _117 => _117(result2)]);
3801
3954
  }
3802
3955
  }
3803
3956
  } catch (err) {
3804
3957
  const error2 = err instanceof Error ? err : new Error("Unknown error");
3805
3958
  setError(error2);
3806
3959
  setState("error");
3807
- _optionalChain([onError, 'optionalCall', _111 => _111(error2)]);
3960
+ _optionalChain([onError, 'optionalCall', _118 => _118(error2)]);
3808
3961
  }
3809
3962
  };
3810
3963
  const resetCommand = () => {
@@ -3837,14 +3990,14 @@ ${planToExecute}`;
3837
3990
  };
3838
3991
  const handleFileSelect = async (e) => {
3839
3992
  if (e.target.files && e.target.files.length > 0) {
3840
- _optionalChain([onFileUpload, 'optionalCall', _112 => _112(e.target.files)]);
3993
+ _optionalChain([onFileUpload, 'optionalCall', _119 => _119(e.target.files)]);
3841
3994
  const files = [];
3842
3995
  for (let i = 0; i < e.target.files.length; i++) {
3843
3996
  const file = e.target.files[i];
3844
3997
  const reader = new FileReader();
3845
3998
  await new Promise((resolve) => {
3846
3999
  reader.onload = (event) => {
3847
- if (_optionalChain([event, 'access', _113 => _113.target, 'optionalAccess', _114 => _114.result])) {
4000
+ if (_optionalChain([event, 'access', _120 => _120.target, 'optionalAccess', _121 => _121.result])) {
3848
4001
  const fullDataUrl = event.target.result;
3849
4002
  const base64Data = fullDataUrl.split(",")[1];
3850
4003
  if (file.type.startsWith("image/")) {
@@ -3938,7 +4091,7 @@ ${planToExecute}`;
3938
4091
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3939
4092
  "button",
3940
4093
  {
3941
- onClick: () => _optionalChain([fileInputRef, 'access', _115 => _115.current, 'optionalAccess', _116 => _116.click, 'call', _117 => _117()]),
4094
+ onClick: () => _optionalChain([fileInputRef, 'access', _122 => _122.current, 'optionalAccess', _123 => _123.click, 'call', _124 => _124()]),
3942
4095
  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",
3943
4096
  title: "Attach file",
3944
4097
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M8.4 2.8L4.4 6.8C3.736 7.464 3.736 8.536 4.4 9.2C5.064 9.864 6.136 9.864 6.8 9.2L11.6 4.4C12.704 3.296 12.704 1.504 11.6 0.4C10.496 -0.704 8.704 -0.704 7.6 0.4L2.8 5.2C1.256 6.744 1.256 9.256 2.8 10.8C4.344 12.344 6.856 12.344 8.4 10.8L12.4 6.8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(1.6, 2.4)" }) })
@@ -4157,7 +4310,7 @@ ${planToExecute}`;
4157
4310
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-5 h-5 text-red-600 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
4158
4311
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
4159
4312
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
4160
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _118 => _118.message]) })
4313
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _125 => _125.message]) })
4161
4314
  ] })
4162
4315
  ] }) }),
4163
4316
  allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -4185,7 +4338,7 @@ ${planToExecute}`;
4185
4338
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
4186
4339
  ] })
4187
4340
  ] }),
4188
- _optionalChain([result, 'access', _119 => _119.data, 'optionalAccess', _120 => _120.summary]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
4341
+ _optionalChain([result, 'access', _126 => _126.data, 'optionalAccess', _127 => _127.summary]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
4189
4342
  result.widgets && result.widgets.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-3", children: result.widgets.map((widget) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4190
4343
  WidgetRenderer,
4191
4344
  {
@@ -4236,7 +4389,7 @@ ${planToExecute}`;
4236
4389
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4237
4390
  "button",
4238
4391
  {
4239
- onClick: () => _optionalChain([fileInputRef, 'access', _121 => _121.current, 'optionalAccess', _122 => _122.click, 'call', _123 => _123()]),
4392
+ onClick: () => _optionalChain([fileInputRef, 'access', _128 => _128.current, 'optionalAccess', _129 => _129.click, 'call', _130 => _130()]),
4240
4393
  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",
4241
4394
  title: "Attach file",
4242
4395
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M8.4 2.8L4.4 6.8C3.736 7.464 3.736 8.536 4.4 9.2C5.064 9.864 6.136 9.864 6.8 9.2L11.6 4.4C12.704 3.296 12.704 1.504 11.6 0.4C10.496 -0.704 8.704 -0.704 7.6 0.4L2.8 5.2C1.256 6.744 1.256 9.256 2.8 10.8C4.344 12.344 6.856 12.344 8.4 10.8L12.4 6.8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(1.6, 2.4)" }) })
@@ -4422,25 +4575,25 @@ function Prompt({
4422
4575
  const newValue = e.target.value;
4423
4576
  if (!maxLength || newValue.length <= maxLength) {
4424
4577
  setValue(newValue);
4425
- _optionalChain([onChange, 'optionalCall', _124 => _124(newValue)]);
4578
+ _optionalChain([onChange, 'optionalCall', _131 => _131(newValue)]);
4426
4579
  }
4427
4580
  };
4428
4581
  const handleSubmit = async () => {
4429
4582
  if (value.length < minLength) return;
4430
- _optionalChain([onSubmit, 'optionalCall', _125 => _125(value)]);
4583
+ _optionalChain([onSubmit, 'optionalCall', _132 => _132(value)]);
4431
4584
  setIsLoading(true);
4432
4585
  try {
4433
4586
  if (useMock) {
4434
4587
  await new Promise((resolve) => setTimeout(resolve, 1500));
4435
4588
  const mockResult = `Enhanced version: ${value} [AI-generated content]`;
4436
- _optionalChain([onResult, 'optionalCall', _126 => _126(mockResult)]);
4589
+ _optionalChain([onResult, 'optionalCall', _133 => _133(mockResult)]);
4437
4590
  setValue("");
4438
4591
  } else {
4439
4592
  const response = await aptevaClient.chat({
4440
4593
  agent_id: agentId,
4441
4594
  message: value
4442
4595
  });
4443
- _optionalChain([onResult, 'optionalCall', _127 => _127(response.message)]);
4596
+ _optionalChain([onResult, 'optionalCall', _134 => _134(response.message)]);
4444
4597
  setValue("");
4445
4598
  }
4446
4599
  } catch (error) {
@@ -4535,7 +4688,7 @@ function Stream({
4535
4688
  }, [autoStart]);
4536
4689
  const startStreaming = async () => {
4537
4690
  setIsStreaming(true);
4538
- _optionalChain([onStart, 'optionalCall', _128 => _128()]);
4691
+ _optionalChain([onStart, 'optionalCall', _135 => _135()]);
4539
4692
  try {
4540
4693
  if (useMock) {
4541
4694
  const mockText = "This is a simulated streaming response from the AI agent. In a real implementation, this would stream data from your backend API. The text appears word by word to simulate the streaming effect. You can customize the typing speed and styling based on your needs.";
@@ -4543,13 +4696,13 @@ function Stream({
4543
4696
  mockText,
4544
4697
  (chunk) => {
4545
4698
  setText((prev) => prev + chunk);
4546
- _optionalChain([onChunk, 'optionalCall', _129 => _129(chunk)]);
4699
+ _optionalChain([onChunk, 'optionalCall', _136 => _136(chunk)]);
4547
4700
  },
4548
4701
  typingSpeed
4549
4702
  );
4550
4703
  setIsComplete(true);
4551
4704
  setIsStreaming(false);
4552
- _optionalChain([onComplete, 'optionalCall', _130 => _130(text + mockText)]);
4705
+ _optionalChain([onComplete, 'optionalCall', _137 => _137(text + mockText)]);
4553
4706
  } else {
4554
4707
  let accumulatedText = "";
4555
4708
  await aptevaClient.chatStream(
@@ -4562,24 +4715,24 @@ function Stream({
4562
4715
  if (chunk.type === "token" && chunk.content) {
4563
4716
  accumulatedText += chunk.content;
4564
4717
  setText(accumulatedText);
4565
- _optionalChain([onChunk, 'optionalCall', _131 => _131(chunk.content)]);
4718
+ _optionalChain([onChunk, 'optionalCall', _138 => _138(chunk.content)]);
4566
4719
  }
4567
4720
  },
4568
4721
  () => {
4569
4722
  setIsComplete(true);
4570
4723
  setIsStreaming(false);
4571
- _optionalChain([onComplete, 'optionalCall', _132 => _132(accumulatedText)]);
4724
+ _optionalChain([onComplete, 'optionalCall', _139 => _139(accumulatedText)]);
4572
4725
  },
4573
4726
  (error) => {
4574
4727
  const err = error instanceof Error ? error : new Error("Streaming error");
4575
- _optionalChain([onError, 'optionalCall', _133 => _133(err)]);
4728
+ _optionalChain([onError, 'optionalCall', _140 => _140(err)]);
4576
4729
  setIsStreaming(false);
4577
4730
  }
4578
4731
  );
4579
4732
  }
4580
4733
  } catch (error) {
4581
4734
  const err = error instanceof Error ? error : new Error("Streaming error");
4582
- _optionalChain([onError, 'optionalCall', _134 => _134(err)]);
4735
+ _optionalChain([onError, 'optionalCall', _141 => _141(err)]);
4583
4736
  setIsStreaming(false);
4584
4737
  }
4585
4738
  };
@@ -4671,7 +4824,7 @@ function ThreadList({
4671
4824
  }) {
4672
4825
  const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
4673
4826
  const filteredThreads = threads.filter(
4674
- (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _135 => _135.preview, 'optionalAccess', _136 => _136.toLowerCase, 'call', _137 => _137(), 'access', _138 => _138.includes, 'call', _139 => _139(searchQuery.toLowerCase())])
4827
+ (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _142 => _142.preview, 'optionalAccess', _143 => _143.toLowerCase, 'call', _144 => _144(), 'access', _145 => _145.includes, 'call', _146 => _146(searchQuery.toLowerCase())])
4675
4828
  );
4676
4829
  const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
4677
4830
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
@@ -4693,8 +4846,8 @@ function ThreadList({
4693
4846
  {
4694
4847
  thread,
4695
4848
  isActive: thread.id === currentThreadId,
4696
- onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _140 => _140(thread.id)]),
4697
- onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _141 => _141(thread.id)])
4849
+ onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _147 => _147(thread.id)]),
4850
+ onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _148 => _148(thread.id)])
4698
4851
  },
4699
4852
  thread.id
4700
4853
  ))
@@ -4756,7 +4909,7 @@ function Threads({
4756
4909
  threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4757
4910
  "button",
4758
4911
  {
4759
- onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _142 => _142(thread.id)]),
4912
+ onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _149 => _149(thread.id)]),
4760
4913
  className: cn(
4761
4914
  "px-4 py-2 whitespace-nowrap font-medium transition-colors",
4762
4915
  thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"