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