@apteva/apteva-kit 0.1.106 → 0.1.108

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 CHANGED
@@ -502,6 +502,7 @@ interface InterfaceUpdate {
502
502
  interface KpiWidget extends Widget {
503
503
  type: 'kpi';
504
504
  props: {
505
+ title?: string;
505
506
  label: string;
506
507
  value: string | number;
507
508
  change?: string;
package/dist/index.d.ts CHANGED
@@ -502,6 +502,7 @@ interface InterfaceUpdate {
502
502
  interface KpiWidget extends Widget {
503
503
  type: 'kpi';
504
504
  props: {
505
+ title?: string;
505
506
  label: string;
506
507
  value: string | number;
507
508
  change?: string;
package/dist/index.js CHANGED
@@ -1854,9 +1854,10 @@ var trendIcons = {
1854
1854
  flat: { symbol: "\u2192", color: "text-neutral-400" }
1855
1855
  };
1856
1856
  function Kpi({ widget, onAction }) {
1857
- const { label = "", value = "", change, trend } = widget.props || {};
1857
+ const { title, label = "", value = "", change, trend } = widget.props || {};
1858
1858
  const trendInfo = trend ? trendIcons[trend] : null;
1859
1859
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "border border-neutral-200 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 p-5", children: [
1860
+ title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "!text-base font-semibold !text-neutral-900 dark:!text-white mb-3", children: title }),
1860
1861
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "!text-sm font-medium !text-neutral-500 dark:!text-neutral-400 mb-1", children: label }),
1861
1862
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-end gap-2", children: [
1862
1863
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "!text-2xl font-bold !text-neutral-900 dark:!text-white", children: value }),
@@ -3971,6 +3972,30 @@ ${widgetContext}` : widgetContext;
3971
3972
  }
3972
3973
  };
3973
3974
  const defaultPlaceholder = mode === "chat" ? "Type a message..." : "Enter your command...";
3975
+ const handleWidgetAction = _react.useCallback.call(void 0, (action) => {
3976
+ _optionalChain([onAction, 'optionalCall', _88 => _88(action)]);
3977
+ if (action.type === "submit" && _optionalChain([action, 'access', _89 => _89.payload, 'optionalAccess', _90 => _90.formData])) {
3978
+ const formData = action.payload.formData;
3979
+ const lines = [];
3980
+ for (const [key, value] of Object.entries(formData)) {
3981
+ if (Array.isArray(value) && value.length > 0 && value[0] instanceof File) {
3982
+ const fileNames = value.map((f) => f.name).join(", ");
3983
+ lines.push(`${key}: ${fileNames}`);
3984
+ } else if (value !== "" && value !== false && value != null) {
3985
+ lines.push(`${key}: ${value}`);
3986
+ }
3987
+ }
3988
+ if (lines.length > 0 && handleSendMessageRef.current) {
3989
+ const files = [];
3990
+ for (const value of Object.values(formData)) {
3991
+ if (Array.isArray(value) && value.length > 0 && value[0] instanceof File) {
3992
+ files.push(...value);
3993
+ }
3994
+ }
3995
+ handleSendMessageRef.current(lines.join("\n"), files.length > 0 ? files : void 0);
3996
+ }
3997
+ }
3998
+ }, [onAction]);
3974
3999
  const handleSendMessage = async (text, files, isSystem) => {
3975
4000
  const hasFiles = files && files.length > 0;
3976
4001
  const attachments = hasFiles ? files.map((f) => ({
@@ -3988,7 +4013,7 @@ ${widgetContext}` : widgetContext;
3988
4013
  metadata: hasFiles ? { attachments } : void 0
3989
4014
  };
3990
4015
  setMessages((prev) => [...prev, userMessage]);
3991
- _optionalChain([onMessageSent, 'optionalCall', _88 => _88(userMessage)]);
4016
+ _optionalChain([onMessageSent, 'optionalCall', _91 => _91(userMessage)]);
3992
4017
  }
3993
4018
  setIsLoading(true);
3994
4019
  try {
@@ -4056,7 +4081,7 @@ ${widgetContext}` : widgetContext;
4056
4081
  responseThreadId = chunk.thread_id;
4057
4082
  if (!currentThreadId) {
4058
4083
  setCurrentThreadId(chunk.thread_id);
4059
- _optionalChain([onThreadChange, 'optionalCall', _89 => _89(chunk.thread_id)]);
4084
+ _optionalChain([onThreadChange, 'optionalCall', _92 => _92(chunk.thread_id)]);
4060
4085
  }
4061
4086
  }
4062
4087
  break;
@@ -4088,7 +4113,7 @@ ${widgetContext}` : widgetContext;
4088
4113
  contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
4089
4114
  toolInputBuffers[chunk.tool_id] = "";
4090
4115
  setChatToolName(displayName);
4091
- _optionalChain([onToolCall, 'optionalCall', _90 => _90(chunk.tool_name, chunk.tool_id)]);
4116
+ _optionalChain([onToolCall, 'optionalCall', _93 => _93(chunk.tool_name, chunk.tool_id)]);
4092
4117
  updateMessage();
4093
4118
  }
4094
4119
  break;
@@ -4148,7 +4173,7 @@ ${widgetContext}` : widgetContext;
4148
4173
  toolSegment.result = chunk.content;
4149
4174
  toolSegment.status = "completed";
4150
4175
  toolSegment.isReceiving = false;
4151
- _optionalChain([onToolResult, 'optionalCall', _91 => _91(toolSegment.name, chunk.content)]);
4176
+ _optionalChain([onToolResult, 'optionalCall', _94 => _94(toolSegment.name, chunk.content)]);
4152
4177
  }
4153
4178
  setChatToolName(null);
4154
4179
  updateMessage();
@@ -4192,7 +4217,7 @@ ${widgetContext}` : widgetContext;
4192
4217
  });
4193
4218
  if (threadId2 && threadId2 !== currentThreadId) {
4194
4219
  setCurrentThreadId(threadId2);
4195
- _optionalChain([onThreadChange, 'optionalCall', _92 => _92(threadId2)]);
4220
+ _optionalChain([onThreadChange, 'optionalCall', _95 => _95(threadId2)]);
4196
4221
  }
4197
4222
  setIsLoading(false);
4198
4223
  setCurrentRequestId(null);
@@ -4216,7 +4241,7 @@ ${widgetContext}` : widgetContext;
4216
4241
  setIsLoading(false);
4217
4242
  setCurrentRequestId(null);
4218
4243
  setChatToolName(null);
4219
- _optionalChain([onError, 'optionalCall', _93 => _93(error)]);
4244
+ _optionalChain([onError, 'optionalCall', _96 => _96(error)]);
4220
4245
  }
4221
4246
  );
4222
4247
  }
@@ -4229,7 +4254,7 @@ ${widgetContext}` : widgetContext;
4229
4254
  metadata: { error: true }
4230
4255
  };
4231
4256
  setMessages((prev) => [...prev, errorMessage]);
4232
- _optionalChain([onError, 'optionalCall', _94 => _94(error instanceof Error ? error : new Error("Unknown error"))]);
4257
+ _optionalChain([onError, 'optionalCall', _97 => _97(error instanceof Error ? error : new Error("Unknown error"))]);
4233
4258
  } finally {
4234
4259
  setIsLoading(false);
4235
4260
  }
@@ -4275,7 +4300,7 @@ ${planningInstruction}` : planningInstruction;
4275
4300
  const error = err instanceof Error ? err : new Error("Failed to generate plan");
4276
4301
  setCommandError(error);
4277
4302
  setCommandState("error");
4278
- _optionalChain([onError, 'optionalCall', _95 => _95(error)]);
4303
+ _optionalChain([onError, 'optionalCall', _98 => _98(error)]);
4279
4304
  }
4280
4305
  }
4281
4306
  return;
@@ -4308,12 +4333,12 @@ ${planningInstruction}` : planningInstruction;
4308
4333
  setCommandResult(result);
4309
4334
  setCommandState("success");
4310
4335
  setProgress(100);
4311
- _optionalChain([onComplete, 'optionalCall', _96 => _96(result)]);
4336
+ _optionalChain([onComplete, 'optionalCall', _99 => _99(result)]);
4312
4337
  },
4313
4338
  (error) => {
4314
4339
  setCommandError(error);
4315
4340
  setCommandState("error");
4316
- _optionalChain([onError, 'optionalCall', _97 => _97(error)]);
4341
+ _optionalChain([onError, 'optionalCall', _100 => _100(error)]);
4317
4342
  }
4318
4343
  );
4319
4344
  } else {
@@ -4326,7 +4351,7 @@ ${planningInstruction}` : planningInstruction;
4326
4351
  setCommandResult(result);
4327
4352
  setCommandState("success");
4328
4353
  setProgress(100);
4329
- _optionalChain([onComplete, 'optionalCall', _98 => _98(result)]);
4354
+ _optionalChain([onComplete, 'optionalCall', _101 => _101(result)]);
4330
4355
  }
4331
4356
  } else {
4332
4357
  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.`;
@@ -4356,16 +4381,16 @@ ${commandInstruction}` : commandInstruction;
4356
4381
  const displayName = chunk.tool_display_name || chunk.tool_name;
4357
4382
  lastToolName = chunk.tool_name;
4358
4383
  setCurrentToolName(displayName);
4359
- _optionalChain([onToolCall, 'optionalCall', _99 => _99(chunk.tool_name, chunk.tool_id || "")]);
4384
+ _optionalChain([onToolCall, 'optionalCall', _102 => _102(chunk.tool_name, chunk.tool_id || "")]);
4360
4385
  accumulatedContent = "";
4361
4386
  setStreamedContent("");
4362
4387
  } else if (chunk.type === "tool_result") {
4363
- _optionalChain([onToolResult, 'optionalCall', _100 => _100(lastToolName, chunk.content)]);
4388
+ _optionalChain([onToolResult, 'optionalCall', _103 => _103(lastToolName, chunk.content)]);
4364
4389
  setCurrentToolName(null);
4365
4390
  } else if (chunk.type === "thread_id" && chunk.thread_id) {
4366
4391
  if (!currentThreadId) {
4367
4392
  setCurrentThreadId(chunk.thread_id);
4368
- _optionalChain([onThreadChange, 'optionalCall', _101 => _101(chunk.thread_id)]);
4393
+ _optionalChain([onThreadChange, 'optionalCall', _104 => _104(chunk.thread_id)]);
4369
4394
  }
4370
4395
  } else if (chunk.type === "request_id" && chunk.request_id) {
4371
4396
  setCurrentRequestId(chunk.request_id);
@@ -4381,13 +4406,13 @@ ${commandInstruction}` : commandInstruction;
4381
4406
  setCommandState("success");
4382
4407
  setProgress(100);
4383
4408
  setCurrentRequestId(null);
4384
- _optionalChain([onComplete, 'optionalCall', _102 => _102(result)]);
4409
+ _optionalChain([onComplete, 'optionalCall', _105 => _105(result)]);
4385
4410
  },
4386
4411
  (error) => {
4387
4412
  setCommandError(error);
4388
4413
  setCommandState("error");
4389
4414
  setCurrentRequestId(null);
4390
- _optionalChain([onError, 'optionalCall', _103 => _103(error)]);
4415
+ _optionalChain([onError, 'optionalCall', _106 => _106(error)]);
4391
4416
  }
4392
4417
  );
4393
4418
  } else {
@@ -4407,14 +4432,14 @@ ${commandInstruction}` : commandInstruction;
4407
4432
  setCommandResult(result);
4408
4433
  setCommandState("success");
4409
4434
  setProgress(100);
4410
- _optionalChain([onComplete, 'optionalCall', _104 => _104(result)]);
4435
+ _optionalChain([onComplete, 'optionalCall', _107 => _107(result)]);
4411
4436
  }
4412
4437
  }
4413
4438
  } catch (err) {
4414
4439
  const error = err instanceof Error ? err : new Error("Unknown error");
4415
4440
  setCommandError(error);
4416
4441
  setCommandState("error");
4417
- _optionalChain([onError, 'optionalCall', _105 => _105(error)]);
4442
+ _optionalChain([onError, 'optionalCall', _108 => _108(error)]);
4418
4443
  }
4419
4444
  };
4420
4445
  const resetCommand = () => {
@@ -4473,12 +4498,12 @@ ${planToExecute}`;
4473
4498
  ] })
4474
4499
  ] }) }),
4475
4500
  mode === "chat" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
4476
- persistentWidgetList.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PersistentWidgetPanel, { widgets: persistentWidgetList, onAction }),
4501
+ persistentWidgetList.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PersistentWidgetPanel, { widgets: persistentWidgetList, onAction: handleWidgetAction }),
4477
4502
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4478
4503
  MessageList,
4479
4504
  {
4480
4505
  messages,
4481
- onAction,
4506
+ onAction: handleWidgetAction,
4482
4507
  welcomeTitle,
4483
4508
  welcomeSubtitle,
4484
4509
  welcomeIcon,
@@ -4513,8 +4538,8 @@ ${planToExecute}`;
4513
4538
  executeCommand(text, files);
4514
4539
  },
4515
4540
  state: commandState,
4516
- response: _optionalChain([commandResult, 'optionalAccess', _106 => _106.data, 'optionalAccess', _107 => _107.summary]) || _optionalChain([commandResult, 'optionalAccess', _108 => _108.message]),
4517
- error: _optionalChain([commandError, 'optionalAccess', _109 => _109.message]),
4541
+ response: _optionalChain([commandResult, 'optionalAccess', _109 => _109.data, 'optionalAccess', _110 => _110.summary]) || _optionalChain([commandResult, 'optionalAccess', _111 => _111.message]),
4542
+ error: _optionalChain([commandError, 'optionalAccess', _112 => _112.message]),
4518
4543
  plan,
4519
4544
  streamedContent,
4520
4545
  toolName: currentToolName,
@@ -4682,13 +4707,13 @@ ${planningInstruction}` : planningInstruction;
4682
4707
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
4683
4708
  setError(error2);
4684
4709
  setState("error");
4685
- _optionalChain([onError, 'optionalCall', _110 => _110(error2)]);
4710
+ _optionalChain([onError, 'optionalCall', _113 => _113(error2)]);
4686
4711
  });
4687
4712
  } catch (err) {
4688
4713
  const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
4689
4714
  setError(error2);
4690
4715
  setState("error");
4691
- _optionalChain([onError, 'optionalCall', _111 => _111(error2)]);
4716
+ _optionalChain([onError, 'optionalCall', _114 => _114(error2)]);
4692
4717
  }
4693
4718
  }
4694
4719
  return;
@@ -4699,7 +4724,7 @@ ${planningInstruction}` : planningInstruction;
4699
4724
  setStreamedContent("");
4700
4725
  setCommand("");
4701
4726
  setUploadedFiles([]);
4702
- _optionalChain([onStart, 'optionalCall', _112 => _112()]);
4727
+ _optionalChain([onStart, 'optionalCall', _115 => _115()]);
4703
4728
  try {
4704
4729
  if (useMock) {
4705
4730
  if (enableStreaming) {
@@ -4710,16 +4735,16 @@ ${planningInstruction}` : planningInstruction;
4710
4735
  if (chunk.type === "token" && chunk.content) {
4711
4736
  accumulatedContent += chunk.content;
4712
4737
  setStreamedContent(accumulatedContent);
4713
- _optionalChain([onChunk, 'optionalCall', _113 => _113(chunk.content)]);
4738
+ _optionalChain([onChunk, 'optionalCall', _116 => _116(chunk.content)]);
4714
4739
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
4715
4740
  setProgress(estimatedProgress);
4716
- _optionalChain([onProgress, 'optionalCall', _114 => _114(estimatedProgress)]);
4741
+ _optionalChain([onProgress, 'optionalCall', _117 => _117(estimatedProgress)]);
4717
4742
  } else if (chunk.type === "widget" && chunk.widget) {
4718
4743
  const widget = chunk.widget;
4719
4744
  setResult((prev) => ({
4720
4745
  success: true,
4721
- data: _optionalChain([prev, 'optionalAccess', _115 => _115.data]) || {},
4722
- widgets: [..._optionalChain([prev, 'optionalAccess', _116 => _116.widgets]) || [], widget],
4746
+ data: _optionalChain([prev, 'optionalAccess', _118 => _118.data]) || {},
4747
+ widgets: [..._optionalChain([prev, 'optionalAccess', _119 => _119.widgets]) || [], widget],
4723
4748
  message: accumulatedContent || "Command executed successfully"
4724
4749
  }));
4725
4750
  }
@@ -4739,19 +4764,19 @@ ${planningInstruction}` : planningInstruction;
4739
4764
  setResult(result2);
4740
4765
  setState("success");
4741
4766
  setProgress(100);
4742
- _optionalChain([onComplete, 'optionalCall', _117 => _117(result2)]);
4767
+ _optionalChain([onComplete, 'optionalCall', _120 => _120(result2)]);
4743
4768
  },
4744
4769
  (error2) => {
4745
4770
  setError(error2);
4746
4771
  setState("error");
4747
- _optionalChain([onError, 'optionalCall', _118 => _118(error2)]);
4772
+ _optionalChain([onError, 'optionalCall', _121 => _121(error2)]);
4748
4773
  }
4749
4774
  );
4750
4775
  } else {
4751
4776
  const progressInterval = setInterval(() => {
4752
4777
  setProgress((prev) => {
4753
4778
  const next = Math.min(prev + 10, 90);
4754
- _optionalChain([onProgress, 'optionalCall', _119 => _119(next)]);
4779
+ _optionalChain([onProgress, 'optionalCall', _122 => _122(next)]);
4755
4780
  return next;
4756
4781
  });
4757
4782
  }, 200);
@@ -4775,7 +4800,7 @@ ${planningInstruction}` : planningInstruction;
4775
4800
  setResult(result2);
4776
4801
  setState("success");
4777
4802
  setProgress(100);
4778
- _optionalChain([onComplete, 'optionalCall', _120 => _120(result2)]);
4803
+ _optionalChain([onComplete, 'optionalCall', _123 => _123(result2)]);
4779
4804
  }
4780
4805
  } else {
4781
4806
  if (enableStreaming) {
@@ -4821,16 +4846,16 @@ ${commandInstruction}` : commandInstruction;
4821
4846
  if (chunk.type === "token" && chunk.content) {
4822
4847
  accumulatedContent += chunk.content;
4823
4848
  setStreamedContent(accumulatedContent);
4824
- _optionalChain([onChunk, 'optionalCall', _121 => _121(chunk.content)]);
4849
+ _optionalChain([onChunk, 'optionalCall', _124 => _124(chunk.content)]);
4825
4850
  const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
4826
4851
  setProgress(estimatedProgress);
4827
- _optionalChain([onProgress, 'optionalCall', _122 => _122(estimatedProgress)]);
4852
+ _optionalChain([onProgress, 'optionalCall', _125 => _125(estimatedProgress)]);
4828
4853
  } else if (chunk.type === "widget" && chunk.widget) {
4829
4854
  const widget = chunk.widget;
4830
4855
  setResult((prev) => ({
4831
4856
  success: true,
4832
- data: _optionalChain([prev, 'optionalAccess', _123 => _123.data]) || {},
4833
- widgets: [..._optionalChain([prev, 'optionalAccess', _124 => _124.widgets]) || [], widget],
4857
+ data: _optionalChain([prev, 'optionalAccess', _126 => _126.data]) || {},
4858
+ widgets: [..._optionalChain([prev, 'optionalAccess', _127 => _127.widgets]) || [], widget],
4834
4859
  message: accumulatedContent || "Command executed successfully"
4835
4860
  }));
4836
4861
  }
@@ -4850,20 +4875,20 @@ ${commandInstruction}` : commandInstruction;
4850
4875
  setResult(result2);
4851
4876
  setState("success");
4852
4877
  setProgress(100);
4853
- _optionalChain([onComplete, 'optionalCall', _125 => _125(result2)]);
4878
+ _optionalChain([onComplete, 'optionalCall', _128 => _128(result2)]);
4854
4879
  },
4855
4880
  (error2) => {
4856
4881
  const err = error2 instanceof Error ? error2 : new Error("Unknown error");
4857
4882
  setError(err);
4858
4883
  setState("error");
4859
- _optionalChain([onError, 'optionalCall', _126 => _126(err)]);
4884
+ _optionalChain([onError, 'optionalCall', _129 => _129(err)]);
4860
4885
  }
4861
4886
  );
4862
4887
  } else {
4863
4888
  const progressInterval = setInterval(() => {
4864
4889
  setProgress((prev) => {
4865
4890
  const next = Math.min(prev + 10, 90);
4866
- _optionalChain([onProgress, 'optionalCall', _127 => _127(next)]);
4891
+ _optionalChain([onProgress, 'optionalCall', _130 => _130(next)]);
4867
4892
  return next;
4868
4893
  });
4869
4894
  }, 200);
@@ -4919,14 +4944,14 @@ ${commandInstruction}` : commandInstruction;
4919
4944
  setResult(result2);
4920
4945
  setState("success");
4921
4946
  setProgress(100);
4922
- _optionalChain([onComplete, 'optionalCall', _128 => _128(result2)]);
4947
+ _optionalChain([onComplete, 'optionalCall', _131 => _131(result2)]);
4923
4948
  }
4924
4949
  }
4925
4950
  } catch (err) {
4926
4951
  const error2 = err instanceof Error ? err : new Error("Unknown error");
4927
4952
  setError(error2);
4928
4953
  setState("error");
4929
- _optionalChain([onError, 'optionalCall', _129 => _129(error2)]);
4954
+ _optionalChain([onError, 'optionalCall', _132 => _132(error2)]);
4930
4955
  }
4931
4956
  };
4932
4957
  const resetCommand = () => {
@@ -4959,14 +4984,14 @@ ${planToExecute}`;
4959
4984
  };
4960
4985
  const handleFileSelect = async (e) => {
4961
4986
  if (e.target.files && e.target.files.length > 0) {
4962
- _optionalChain([onFileUpload, 'optionalCall', _130 => _130(e.target.files)]);
4987
+ _optionalChain([onFileUpload, 'optionalCall', _133 => _133(e.target.files)]);
4963
4988
  const files = [];
4964
4989
  for (let i = 0; i < e.target.files.length; i++) {
4965
4990
  const file = e.target.files[i];
4966
4991
  const reader = new FileReader();
4967
4992
  await new Promise((resolve) => {
4968
4993
  reader.onload = (event) => {
4969
- if (_optionalChain([event, 'access', _131 => _131.target, 'optionalAccess', _132 => _132.result])) {
4994
+ if (_optionalChain([event, 'access', _134 => _134.target, 'optionalAccess', _135 => _135.result])) {
4970
4995
  const fullDataUrl = event.target.result;
4971
4996
  const base64Data = fullDataUrl.split(",")[1];
4972
4997
  if (file.type.startsWith("image/")) {
@@ -5060,7 +5085,7 @@ ${planToExecute}`;
5060
5085
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5061
5086
  "button",
5062
5087
  {
5063
- onClick: () => _optionalChain([fileInputRef, 'access', _133 => _133.current, 'optionalAccess', _134 => _134.click, 'call', _135 => _135()]),
5088
+ onClick: () => _optionalChain([fileInputRef, 'access', _136 => _136.current, 'optionalAccess', _137 => _137.click, 'call', _138 => _138()]),
5064
5089
  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",
5065
5090
  title: "Attach file",
5066
5091
  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)" }) })
@@ -5279,7 +5304,7 @@ ${planToExecute}`;
5279
5304
  /* @__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" }) }),
5280
5305
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
5281
5306
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
5282
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _136 => _136.message]) })
5307
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _139 => _139.message]) })
5283
5308
  ] })
5284
5309
  ] }) }),
5285
5310
  allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -5307,7 +5332,7 @@ ${planToExecute}`;
5307
5332
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
5308
5333
  ] })
5309
5334
  ] }),
5310
- _optionalChain([result, 'access', _137 => _137.data, 'optionalAccess', _138 => _138.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 }),
5335
+ _optionalChain([result, 'access', _140 => _140.data, 'optionalAccess', _141 => _141.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 }),
5311
5336
  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,
5312
5337
  WidgetRenderer,
5313
5338
  {
@@ -5358,7 +5383,7 @@ ${planToExecute}`;
5358
5383
  enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5359
5384
  "button",
5360
5385
  {
5361
- onClick: () => _optionalChain([fileInputRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.click, 'call', _141 => _141()]),
5386
+ onClick: () => _optionalChain([fileInputRef, 'access', _142 => _142.current, 'optionalAccess', _143 => _143.click, 'call', _144 => _144()]),
5362
5387
  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",
5363
5388
  title: "Attach file",
5364
5389
  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)" }) })
@@ -5544,25 +5569,25 @@ function Prompt({
5544
5569
  const newValue = e.target.value;
5545
5570
  if (!maxLength || newValue.length <= maxLength) {
5546
5571
  setValue(newValue);
5547
- _optionalChain([onChange, 'optionalCall', _142 => _142(newValue)]);
5572
+ _optionalChain([onChange, 'optionalCall', _145 => _145(newValue)]);
5548
5573
  }
5549
5574
  };
5550
5575
  const handleSubmit = async () => {
5551
5576
  if (value.length < minLength) return;
5552
- _optionalChain([onSubmit, 'optionalCall', _143 => _143(value)]);
5577
+ _optionalChain([onSubmit, 'optionalCall', _146 => _146(value)]);
5553
5578
  setIsLoading(true);
5554
5579
  try {
5555
5580
  if (useMock) {
5556
5581
  await new Promise((resolve) => setTimeout(resolve, 1500));
5557
5582
  const mockResult = `Enhanced version: ${value} [AI-generated content]`;
5558
- _optionalChain([onResult, 'optionalCall', _144 => _144(mockResult)]);
5583
+ _optionalChain([onResult, 'optionalCall', _147 => _147(mockResult)]);
5559
5584
  setValue("");
5560
5585
  } else {
5561
5586
  const response = await aptevaClient.chat({
5562
5587
  agent_id: agentId,
5563
5588
  message: value
5564
5589
  });
5565
- _optionalChain([onResult, 'optionalCall', _145 => _145(response.message)]);
5590
+ _optionalChain([onResult, 'optionalCall', _148 => _148(response.message)]);
5566
5591
  setValue("");
5567
5592
  }
5568
5593
  } catch (error) {
@@ -5657,7 +5682,7 @@ function Stream({
5657
5682
  }, [autoStart]);
5658
5683
  const startStreaming = async () => {
5659
5684
  setIsStreaming(true);
5660
- _optionalChain([onStart, 'optionalCall', _146 => _146()]);
5685
+ _optionalChain([onStart, 'optionalCall', _149 => _149()]);
5661
5686
  try {
5662
5687
  if (useMock) {
5663
5688
  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.";
@@ -5665,13 +5690,13 @@ function Stream({
5665
5690
  mockText,
5666
5691
  (chunk) => {
5667
5692
  setText((prev) => prev + chunk);
5668
- _optionalChain([onChunk, 'optionalCall', _147 => _147(chunk)]);
5693
+ _optionalChain([onChunk, 'optionalCall', _150 => _150(chunk)]);
5669
5694
  },
5670
5695
  typingSpeed
5671
5696
  );
5672
5697
  setIsComplete(true);
5673
5698
  setIsStreaming(false);
5674
- _optionalChain([onComplete, 'optionalCall', _148 => _148(text + mockText)]);
5699
+ _optionalChain([onComplete, 'optionalCall', _151 => _151(text + mockText)]);
5675
5700
  } else {
5676
5701
  let accumulatedText = "";
5677
5702
  await aptevaClient.chatStream(
@@ -5684,24 +5709,24 @@ function Stream({
5684
5709
  if (chunk.type === "token" && chunk.content) {
5685
5710
  accumulatedText += chunk.content;
5686
5711
  setText(accumulatedText);
5687
- _optionalChain([onChunk, 'optionalCall', _149 => _149(chunk.content)]);
5712
+ _optionalChain([onChunk, 'optionalCall', _152 => _152(chunk.content)]);
5688
5713
  }
5689
5714
  },
5690
5715
  () => {
5691
5716
  setIsComplete(true);
5692
5717
  setIsStreaming(false);
5693
- _optionalChain([onComplete, 'optionalCall', _150 => _150(accumulatedText)]);
5718
+ _optionalChain([onComplete, 'optionalCall', _153 => _153(accumulatedText)]);
5694
5719
  },
5695
5720
  (error) => {
5696
5721
  const err = error instanceof Error ? error : new Error("Streaming error");
5697
- _optionalChain([onError, 'optionalCall', _151 => _151(err)]);
5722
+ _optionalChain([onError, 'optionalCall', _154 => _154(err)]);
5698
5723
  setIsStreaming(false);
5699
5724
  }
5700
5725
  );
5701
5726
  }
5702
5727
  } catch (error) {
5703
5728
  const err = error instanceof Error ? error : new Error("Streaming error");
5704
- _optionalChain([onError, 'optionalCall', _152 => _152(err)]);
5729
+ _optionalChain([onError, 'optionalCall', _155 => _155(err)]);
5705
5730
  setIsStreaming(false);
5706
5731
  }
5707
5732
  };
@@ -5793,7 +5818,7 @@ function ThreadList({
5793
5818
  }) {
5794
5819
  const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
5795
5820
  const filteredThreads = threads.filter(
5796
- (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _153 => _153.preview, 'optionalAccess', _154 => _154.toLowerCase, 'call', _155 => _155(), 'access', _156 => _156.includes, 'call', _157 => _157(searchQuery.toLowerCase())])
5821
+ (thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _156 => _156.preview, 'optionalAccess', _157 => _157.toLowerCase, 'call', _158 => _158(), 'access', _159 => _159.includes, 'call', _160 => _160(searchQuery.toLowerCase())])
5797
5822
  );
5798
5823
  const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
5799
5824
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
@@ -5815,8 +5840,8 @@ function ThreadList({
5815
5840
  {
5816
5841
  thread,
5817
5842
  isActive: thread.id === currentThreadId,
5818
- onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _158 => _158(thread.id)]),
5819
- onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _159 => _159(thread.id)])
5843
+ onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _161 => _161(thread.id)]),
5844
+ onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _162 => _162(thread.id)])
5820
5845
  },
5821
5846
  thread.id
5822
5847
  ))
@@ -5878,7 +5903,7 @@ function Threads({
5878
5903
  threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5879
5904
  "button",
5880
5905
  {
5881
- onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _160 => _160(thread.id)]),
5906
+ onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _163 => _163(thread.id)]),
5882
5907
  className: cn(
5883
5908
  "px-4 py-2 whitespace-nowrap font-medium transition-colors",
5884
5909
  thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"
@@ -6063,7 +6088,7 @@ function TabsLayout({ node, renderNode }) {
6063
6088
  var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
6064
6089
  function normalizeNode(n) {
6065
6090
  let node = { ...n };
6066
- if (node.type === "widget" && _optionalChain([node, 'access', _161 => _161.props, 'optionalAccess', _162 => _162.widget])) {
6091
+ if (node.type === "widget" && _optionalChain([node, 'access', _164 => _164.props, 'optionalAccess', _165 => _165.widget])) {
6067
6092
  node.type = node.props.widget;
6068
6093
  const { widget: _, ...rest } = node.props;
6069
6094
  node.props = rest;
@@ -6201,10 +6226,10 @@ function AutoInterface({
6201
6226
  ].filter(Boolean).join("\n\n");
6202
6227
  const updateInterface = _react.useCallback.call(void 0, (newSpec) => {
6203
6228
  setInterfaceSpec(newSpec);
6204
- _optionalChain([onInterfaceChange, 'optionalCall', _163 => _163(newSpec)]);
6229
+ _optionalChain([onInterfaceChange, 'optionalCall', _166 => _166(newSpec)]);
6205
6230
  }, [onInterfaceChange]);
6206
6231
  const handleAction = _react.useCallback.call(void 0, (action) => {
6207
- _optionalChain([onAction, 'optionalCall', _164 => _164(action)]);
6232
+ _optionalChain([onAction, 'optionalCall', _167 => _167(action)]);
6208
6233
  if (chatRef.current) {
6209
6234
  chatRef.current.sendMessage(
6210
6235
  `[Action: ${action.type} on widget ${action.widgetId || "unknown"}. Payload: ${JSON.stringify(action.payload)}]`
@@ -6212,7 +6237,7 @@ function AutoInterface({
6212
6237
  }
6213
6238
  }, [onAction]);
6214
6239
  const handleMessageComplete = _react.useCallback.call(void 0, (result) => {
6215
- if (!_optionalChain([result, 'optionalAccess', _165 => _165.data])) return;
6240
+ if (!_optionalChain([result, 'optionalAccess', _168 => _168.data])) return;
6216
6241
  const text = typeof result.data === "string" ? result.data : result.data.message || "";
6217
6242
  console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
6218
6243
  const parsed = parseInterfaceFromText(text);
@@ -6252,7 +6277,7 @@ function AutoInterface({
6252
6277
  }).catch((err) => {
6253
6278
  if (cancelled) return;
6254
6279
  console.error("[AutoInterface] Initial generation failed:", err);
6255
- _optionalChain([onError, 'optionalCall', _166 => _166(err instanceof Error ? err : new Error(String(err)))]);
6280
+ _optionalChain([onError, 'optionalCall', _169 => _169(err instanceof Error ? err : new Error(String(err)))]);
6256
6281
  setIsGenerating(false);
6257
6282
  });
6258
6283
  return () => {
@@ -6418,7 +6443,7 @@ function useInterfaceAI({
6418
6443
  }
6419
6444
  const sendMessage = _react.useCallback.call(void 0, async (message) => {
6420
6445
  accumulatedTextRef.current = "";
6421
- _optionalChain([onStreamStart, 'optionalCall', _167 => _167()]);
6446
+ _optionalChain([onStreamStart, 'optionalCall', _170 => _170()]);
6422
6447
  const systemPrompt = [
6423
6448
  generateInterfaceContext(),
6424
6449
  context || ""
@@ -6441,27 +6466,27 @@ function useInterfaceAI({
6441
6466
  accumulatedTextRef.current += chunk.content || "";
6442
6467
  const parsed = parseInterfaceFromText(accumulatedTextRef.current);
6443
6468
  if (parsed) {
6444
- _optionalChain([onInterface, 'optionalCall', _168 => _168(parsed)]);
6469
+ _optionalChain([onInterface, 'optionalCall', _171 => _171(parsed)]);
6445
6470
  }
6446
6471
  const updates = parseUpdatesFromText(accumulatedTextRef.current);
6447
6472
  if (updates.length > 0) {
6448
- _optionalChain([onUpdates, 'optionalCall', _169 => _169(updates)]);
6473
+ _optionalChain([onUpdates, 'optionalCall', _172 => _172(updates)]);
6449
6474
  }
6450
6475
  }
6451
6476
  },
6452
6477
  // onComplete
6453
6478
  () => {
6454
- _optionalChain([onStreamEnd, 'optionalCall', _170 => _170()]);
6479
+ _optionalChain([onStreamEnd, 'optionalCall', _173 => _173()]);
6455
6480
  },
6456
6481
  // onError
6457
6482
  (error) => {
6458
- _optionalChain([onError, 'optionalCall', _171 => _171(error)]);
6459
- _optionalChain([onStreamEnd, 'optionalCall', _172 => _172()]);
6483
+ _optionalChain([onError, 'optionalCall', _174 => _174(error)]);
6484
+ _optionalChain([onStreamEnd, 'optionalCall', _175 => _175()]);
6460
6485
  }
6461
6486
  );
6462
6487
  } catch (error) {
6463
- _optionalChain([onError, 'optionalCall', _173 => _173(error instanceof Error ? error : new Error("Unknown error"))]);
6464
- _optionalChain([onStreamEnd, 'optionalCall', _174 => _174()]);
6488
+ _optionalChain([onError, 'optionalCall', _176 => _176(error instanceof Error ? error : new Error("Unknown error"))]);
6489
+ _optionalChain([onStreamEnd, 'optionalCall', _177 => _177()]);
6465
6490
  }
6466
6491
  }, [agentId, context, onInterface, onUpdates, onError, onStreamStart, onStreamEnd]);
6467
6492
  return {