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