@hef2024/llmasaservice-ui 0.20.1 → 0.20.3
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.css +66 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +177 -16
- package/dist/index.mjs +177 -16
- package/package.json +1 -1
- package/src/AIAgentPanel.tsx +146 -9
- package/src/AIChatPanel.css +82 -0
- package/src/AIChatPanel.tsx +82 -6
- package/src/components/ui/ToolInfoModal.tsx +3 -0
- package/src/hooks/useAgentRegistry.ts +0 -1
package/dist/index.css
CHANGED
|
@@ -3371,6 +3371,72 @@ button[data-pending=true]::after {
|
|
|
3371
3371
|
font-family: "SF Mono", monospace;
|
|
3372
3372
|
font-size: 10px;
|
|
3373
3373
|
}
|
|
3374
|
+
.ai-chat-context-popover__detail-section-title-row {
|
|
3375
|
+
display: flex;
|
|
3376
|
+
align-items: center;
|
|
3377
|
+
gap: 12px;
|
|
3378
|
+
flex: 1;
|
|
3379
|
+
min-width: 0;
|
|
3380
|
+
}
|
|
3381
|
+
.ai-chat-context-popover__detail-section--disabled {
|
|
3382
|
+
opacity: 0.6;
|
|
3383
|
+
}
|
|
3384
|
+
.ai-chat-context-popover__detail-section--disabled .ai-chat-context-popover__detail-section-title {
|
|
3385
|
+
text-decoration: line-through;
|
|
3386
|
+
opacity: 0.7;
|
|
3387
|
+
}
|
|
3388
|
+
.ai-chat-context-toggle {
|
|
3389
|
+
position: relative;
|
|
3390
|
+
display: inline-flex;
|
|
3391
|
+
width: 36px;
|
|
3392
|
+
height: 20px;
|
|
3393
|
+
cursor: pointer;
|
|
3394
|
+
user-select: none;
|
|
3395
|
+
flex-shrink: 0;
|
|
3396
|
+
}
|
|
3397
|
+
.ai-chat-context-toggle__input {
|
|
3398
|
+
opacity: 0;
|
|
3399
|
+
width: 0;
|
|
3400
|
+
height: 0;
|
|
3401
|
+
position: absolute;
|
|
3402
|
+
}
|
|
3403
|
+
.ai-chat-context-toggle__slider {
|
|
3404
|
+
position: absolute;
|
|
3405
|
+
top: 0;
|
|
3406
|
+
left: 0;
|
|
3407
|
+
right: 0;
|
|
3408
|
+
bottom: 0;
|
|
3409
|
+
background-color: #cbd5e1;
|
|
3410
|
+
transition: background-color 0.2s ease;
|
|
3411
|
+
border-radius: 20px;
|
|
3412
|
+
}
|
|
3413
|
+
.ai-chat-context-toggle__slider:before {
|
|
3414
|
+
position: absolute;
|
|
3415
|
+
content: "";
|
|
3416
|
+
height: 16px;
|
|
3417
|
+
width: 16px;
|
|
3418
|
+
left: 2px;
|
|
3419
|
+
bottom: 2px;
|
|
3420
|
+
background-color: white;
|
|
3421
|
+
transition: transform 0.2s ease;
|
|
3422
|
+
border-radius: 50%;
|
|
3423
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
|
3424
|
+
}
|
|
3425
|
+
.ai-chat-context-toggle__input:checked + .ai-chat-context-toggle__slider {
|
|
3426
|
+
background-color: #3b82f6;
|
|
3427
|
+
}
|
|
3428
|
+
.ai-chat-context-toggle__input:checked + .ai-chat-context-toggle__slider:before {
|
|
3429
|
+
transform: translateX(16px);
|
|
3430
|
+
}
|
|
3431
|
+
.ai-chat-context-toggle:hover .ai-chat-context-toggle__slider {
|
|
3432
|
+
opacity: 0.9;
|
|
3433
|
+
}
|
|
3434
|
+
.dark-theme .ai-chat-context-toggle__slider {
|
|
3435
|
+
background-color: #4b5563;
|
|
3436
|
+
}
|
|
3437
|
+
.dark-theme .ai-chat-context-toggle__input:checked + .ai-chat-context-toggle__slider {
|
|
3438
|
+
background-color: #60a5fa;
|
|
3439
|
+
}
|
|
3374
3440
|
.ai-chat-context-popover__detail-content {
|
|
3375
3441
|
margin: 0;
|
|
3376
3442
|
padding: 12px 14px;
|
package/dist/index.d.mts
CHANGED
|
@@ -182,6 +182,7 @@ interface AIAgentPanelHandle {
|
|
|
182
182
|
interface AIAgentPanelProps {
|
|
183
183
|
agents: (string | AgentConfig)[];
|
|
184
184
|
defaultAgent?: string;
|
|
185
|
+
selectedAgent?: string;
|
|
185
186
|
customerId: string;
|
|
186
187
|
apiKey?: string;
|
|
187
188
|
context?: AgentContext | null;
|
|
@@ -325,6 +326,8 @@ interface AIChatPanelProps {
|
|
|
325
326
|
totalContextTokens?: number;
|
|
326
327
|
maxContextTokens?: number;
|
|
327
328
|
enableContextDetailView?: boolean;
|
|
329
|
+
disabledSectionIds?: Set<string>;
|
|
330
|
+
onToggleSection?: (sectionId: string, enabled: boolean) => void;
|
|
328
331
|
onConversationCreated?: (conversationId: string) => void;
|
|
329
332
|
cssUrl?: string;
|
|
330
333
|
markdownClass?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -182,6 +182,7 @@ interface AIAgentPanelHandle {
|
|
|
182
182
|
interface AIAgentPanelProps {
|
|
183
183
|
agents: (string | AgentConfig)[];
|
|
184
184
|
defaultAgent?: string;
|
|
185
|
+
selectedAgent?: string;
|
|
185
186
|
customerId: string;
|
|
186
187
|
apiKey?: string;
|
|
187
188
|
context?: AgentContext | null;
|
|
@@ -325,6 +326,8 @@ interface AIChatPanelProps {
|
|
|
325
326
|
totalContextTokens?: number;
|
|
326
327
|
maxContextTokens?: number;
|
|
327
328
|
enableContextDetailView?: boolean;
|
|
329
|
+
disabledSectionIds?: Set<string>;
|
|
330
|
+
onToggleSection?: (sectionId: string, enabled: boolean) => void;
|
|
328
331
|
onConversationCreated?: (conversationId: string) => void;
|
|
329
332
|
cssUrl?: string;
|
|
330
333
|
markdownClass?: string;
|
package/dist/index.js
CHANGED
|
@@ -3500,12 +3500,15 @@ var ChatInput = import_react12.default.memo(({
|
|
|
3500
3500
|
contextSections = [],
|
|
3501
3501
|
totalContextTokens = 0,
|
|
3502
3502
|
maxContextTokens = 8e3,
|
|
3503
|
-
enableContextDetailView = false
|
|
3503
|
+
enableContextDetailView = false,
|
|
3504
|
+
disabledSectionIds = /* @__PURE__ */ new Set(),
|
|
3505
|
+
onToggleSection
|
|
3504
3506
|
}) => {
|
|
3505
3507
|
const [inputValue, setInputValue] = (0, import_react12.useState)("");
|
|
3506
3508
|
const [dropdownOpen, setDropdownOpen] = (0, import_react12.useState)(false);
|
|
3507
3509
|
const [contextViewerOpen, setContextViewerOpen] = (0, import_react12.useState)(false);
|
|
3508
3510
|
const [contextViewMode, setContextViewMode] = (0, import_react12.useState)("summary");
|
|
3511
|
+
const [expandedSectionId, setExpandedSectionId] = (0, import_react12.useState)(null);
|
|
3509
3512
|
const textareaRef = (0, import_react12.useRef)(null);
|
|
3510
3513
|
const containerRef = (0, import_react12.useRef)(null);
|
|
3511
3514
|
const contextPopoverRef = (0, import_react12.useRef)(null);
|
|
@@ -3542,6 +3545,7 @@ var ChatInput = import_react12.default.memo(({
|
|
|
3542
3545
|
if (contextPopoverRef.current && !contextPopoverRef.current.contains(event.target)) {
|
|
3543
3546
|
setContextViewerOpen(false);
|
|
3544
3547
|
setContextViewMode("summary");
|
|
3548
|
+
setExpandedSectionId(null);
|
|
3545
3549
|
}
|
|
3546
3550
|
};
|
|
3547
3551
|
if (contextViewerOpen) {
|
|
@@ -3623,6 +3627,9 @@ var ChatInput = import_react12.default.memo(({
|
|
|
3623
3627
|
setContextViewerOpen(!contextViewerOpen);
|
|
3624
3628
|
if (!contextViewerOpen) {
|
|
3625
3629
|
setContextViewMode("summary");
|
|
3630
|
+
setExpandedSectionId(null);
|
|
3631
|
+
} else {
|
|
3632
|
+
setExpandedSectionId(null);
|
|
3626
3633
|
}
|
|
3627
3634
|
},
|
|
3628
3635
|
type: "button",
|
|
@@ -3640,7 +3647,10 @@ var ChatInput = import_react12.default.memo(({
|
|
|
3640
3647
|
"button",
|
|
3641
3648
|
{
|
|
3642
3649
|
className: "ai-chat-context-popover__close",
|
|
3643
|
-
onClick: () =>
|
|
3650
|
+
onClick: () => {
|
|
3651
|
+
setContextViewerOpen(false);
|
|
3652
|
+
setExpandedSectionId(null);
|
|
3653
|
+
},
|
|
3644
3654
|
type: "button"
|
|
3645
3655
|
},
|
|
3646
3656
|
"\xD7"
|
|
@@ -3657,6 +3667,7 @@ var ChatInput = import_react12.default.memo(({
|
|
|
3657
3667
|
className: `ai-chat-context-popover__section-item ${enableContextDetailView ? "ai-chat-context-popover__section-item--clickable" : ""}`,
|
|
3658
3668
|
onClick: () => {
|
|
3659
3669
|
if (enableContextDetailView) {
|
|
3670
|
+
setExpandedSectionId(section.id);
|
|
3660
3671
|
setContextViewMode("detail");
|
|
3661
3672
|
}
|
|
3662
3673
|
}
|
|
@@ -3668,7 +3679,10 @@ var ChatInput = import_react12.default.memo(({
|
|
|
3668
3679
|
"button",
|
|
3669
3680
|
{
|
|
3670
3681
|
className: "ai-chat-context-popover__expand-btn",
|
|
3671
|
-
onClick: () =>
|
|
3682
|
+
onClick: () => {
|
|
3683
|
+
setExpandedSectionId(null);
|
|
3684
|
+
setContextViewMode("detail");
|
|
3685
|
+
},
|
|
3672
3686
|
type: "button"
|
|
3673
3687
|
},
|
|
3674
3688
|
"View details \u2192"
|
|
@@ -3677,7 +3691,10 @@ var ChatInput = import_react12.default.memo(({
|
|
|
3677
3691
|
"button",
|
|
3678
3692
|
{
|
|
3679
3693
|
className: "ai-chat-context-popover__back",
|
|
3680
|
-
onClick: () =>
|
|
3694
|
+
onClick: () => {
|
|
3695
|
+
setContextViewMode("summary");
|
|
3696
|
+
setExpandedSectionId(null);
|
|
3697
|
+
},
|
|
3681
3698
|
type: "button"
|
|
3682
3699
|
},
|
|
3683
3700
|
"\u2190 Back"
|
|
@@ -3685,7 +3702,10 @@ var ChatInput = import_react12.default.memo(({
|
|
|
3685
3702
|
"button",
|
|
3686
3703
|
{
|
|
3687
3704
|
className: "ai-chat-context-popover__close",
|
|
3688
|
-
onClick: () =>
|
|
3705
|
+
onClick: () => {
|
|
3706
|
+
setContextViewerOpen(false);
|
|
3707
|
+
setExpandedSectionId(null);
|
|
3708
|
+
},
|
|
3689
3709
|
type: "button"
|
|
3690
3710
|
},
|
|
3691
3711
|
"\xD7"
|
|
@@ -3697,7 +3717,39 @@ var ChatInput = import_react12.default.memo(({
|
|
|
3697
3717
|
}
|
|
3698
3718
|
))), /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__detail-sections" }, contextSections.map((section) => {
|
|
3699
3719
|
const format = detectFormat(section.data);
|
|
3700
|
-
|
|
3720
|
+
const isEnabled = !disabledSectionIds.has(section.id);
|
|
3721
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
3722
|
+
"details",
|
|
3723
|
+
{
|
|
3724
|
+
key: section.id,
|
|
3725
|
+
className: `ai-chat-context-popover__detail-section ${!isEnabled ? "ai-chat-context-popover__detail-section--disabled" : ""}`,
|
|
3726
|
+
open: expandedSectionId === section.id
|
|
3727
|
+
},
|
|
3728
|
+
/* @__PURE__ */ import_react12.default.createElement("summary", { className: "ai-chat-context-popover__detail-section-header" }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-context-popover__detail-section-title-row" }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__detail-section-title" }, section.title), /* @__PURE__ */ import_react12.default.createElement(
|
|
3729
|
+
"label",
|
|
3730
|
+
{
|
|
3731
|
+
className: "ai-chat-context-toggle",
|
|
3732
|
+
onClick: (e) => e.stopPropagation(),
|
|
3733
|
+
title: isEnabled ? "Disable this context section" : "Enable this context section"
|
|
3734
|
+
},
|
|
3735
|
+
/* @__PURE__ */ import_react12.default.createElement(
|
|
3736
|
+
"input",
|
|
3737
|
+
{
|
|
3738
|
+
type: "checkbox",
|
|
3739
|
+
checked: isEnabled,
|
|
3740
|
+
onChange: (e) => {
|
|
3741
|
+
e.stopPropagation();
|
|
3742
|
+
if (onToggleSection) {
|
|
3743
|
+
onToggleSection(section.id, !isEnabled);
|
|
3744
|
+
}
|
|
3745
|
+
},
|
|
3746
|
+
className: "ai-chat-context-toggle__input"
|
|
3747
|
+
}
|
|
3748
|
+
),
|
|
3749
|
+
/* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-toggle__slider" })
|
|
3750
|
+
)), /* @__PURE__ */ import_react12.default.createElement("span", { className: "ai-chat-context-popover__detail-section-meta" }, /* @__PURE__ */ import_react12.default.createElement("code", null, `{{${section.id}}}`), /* @__PURE__ */ import_react12.default.createElement("span", null, "~", section.tokens || Math.ceil(JSON.stringify(section.data).length / 4)))),
|
|
3751
|
+
/* @__PURE__ */ import_react12.default.createElement("pre", { className: "ai-chat-context-popover__detail-content" }, /* @__PURE__ */ import_react12.default.createElement("code", null, formatContent(section.data, format)))
|
|
3752
|
+
);
|
|
3701
3753
|
})))
|
|
3702
3754
|
)), /* @__PURE__ */ import_react12.default.createElement(
|
|
3703
3755
|
"button",
|
|
@@ -3773,6 +3825,8 @@ var AIChatPanel = ({
|
|
|
3773
3825
|
totalContextTokens = 0,
|
|
3774
3826
|
maxContextTokens = 8e3,
|
|
3775
3827
|
enableContextDetailView = false,
|
|
3828
|
+
disabledSectionIds: propDisabledSectionIds,
|
|
3829
|
+
onToggleSection: propOnToggleSection,
|
|
3776
3830
|
onConversationCreated,
|
|
3777
3831
|
// UI Customization Props
|
|
3778
3832
|
cssUrl,
|
|
@@ -3824,6 +3878,8 @@ var AIChatPanel = ({
|
|
|
3824
3878
|
const [pendingToolRequests, setPendingToolRequests] = (0, import_react12.useState)([]);
|
|
3825
3879
|
const [sessionApprovedTools, setSessionApprovedTools] = (0, import_react12.useState)([]);
|
|
3826
3880
|
const [alwaysApprovedTools, setAlwaysApprovedTools] = (0, import_react12.useState)([]);
|
|
3881
|
+
const [internalDisabledSectionIds, setInternalDisabledSectionIds] = (0, import_react12.useState)(/* @__PURE__ */ new Set());
|
|
3882
|
+
const disabledSectionIds = propDisabledSectionIds != null ? propDisabledSectionIds : internalDisabledSectionIds;
|
|
3827
3883
|
(0, import_react12.useEffect)(() => {
|
|
3828
3884
|
setShowEmailPanel(customerEmailCaptureMode !== "HIDE");
|
|
3829
3885
|
if (customerEmailCaptureMode === "REQUIRED") {
|
|
@@ -3901,6 +3957,21 @@ var AIChatPanel = ({
|
|
|
3901
3957
|
userLanguage: navigator.language
|
|
3902
3958
|
};
|
|
3903
3959
|
}, []);
|
|
3960
|
+
const handleToggleSection = (0, import_react12.useCallback)((sectionId, enabled) => {
|
|
3961
|
+
if (propOnToggleSection) {
|
|
3962
|
+
propOnToggleSection(sectionId, enabled);
|
|
3963
|
+
} else {
|
|
3964
|
+
setInternalDisabledSectionIds((prev) => {
|
|
3965
|
+
const next = new Set(prev);
|
|
3966
|
+
if (enabled) {
|
|
3967
|
+
next.delete(sectionId);
|
|
3968
|
+
} else {
|
|
3969
|
+
next.add(sectionId);
|
|
3970
|
+
}
|
|
3971
|
+
return next;
|
|
3972
|
+
});
|
|
3973
|
+
}
|
|
3974
|
+
}, [propOnToggleSection]);
|
|
3904
3975
|
const ensureConversation = (0, import_react12.useCallback)(() => {
|
|
3905
3976
|
var _a2, _b;
|
|
3906
3977
|
console.log("ensureConversation - called with:", {
|
|
@@ -5041,7 +5112,9 @@ var AIChatPanel = ({
|
|
|
5041
5112
|
contextSections,
|
|
5042
5113
|
totalContextTokens,
|
|
5043
5114
|
maxContextTokens,
|
|
5044
|
-
enableContextDetailView
|
|
5115
|
+
enableContextDetailView,
|
|
5116
|
+
disabledSectionIds,
|
|
5117
|
+
onToggleSection: handleToggleSection
|
|
5045
5118
|
}
|
|
5046
5119
|
),
|
|
5047
5120
|
showPoweredBy && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-panel__footer" }, mcpServers && mcpServers.length > 0 && /* @__PURE__ */ import_react12.default.createElement("div", { className: "ai-chat-tools-status" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
@@ -5392,6 +5465,8 @@ var ChatPanelWrapper = ({
|
|
|
5392
5465
|
totalContextTokens,
|
|
5393
5466
|
maxContextTokens,
|
|
5394
5467
|
enableContextDetailView,
|
|
5468
|
+
disabledSectionIds,
|
|
5469
|
+
onToggleSection,
|
|
5395
5470
|
onConversationCreated,
|
|
5396
5471
|
conversationInitialPrompt,
|
|
5397
5472
|
// New props from ChatPanel port
|
|
@@ -5493,6 +5568,8 @@ var ChatPanelWrapper = ({
|
|
|
5493
5568
|
totalContextTokens,
|
|
5494
5569
|
maxContextTokens,
|
|
5495
5570
|
enableContextDetailView,
|
|
5571
|
+
disabledSectionIds,
|
|
5572
|
+
onToggleSection,
|
|
5496
5573
|
onConversationCreated: conversationCreatedCallback,
|
|
5497
5574
|
cssUrl,
|
|
5498
5575
|
markdownClass,
|
|
@@ -5517,6 +5594,7 @@ ChatPanelWrapper.displayName = "ChatPanelWrapper";
|
|
|
5517
5594
|
var AIAgentPanel = import_react14.default.forwardRef(({
|
|
5518
5595
|
agents,
|
|
5519
5596
|
defaultAgent,
|
|
5597
|
+
selectedAgent,
|
|
5520
5598
|
customerId,
|
|
5521
5599
|
apiKey,
|
|
5522
5600
|
context,
|
|
@@ -5620,6 +5698,63 @@ var AIAgentPanel = import_react14.default.forwardRef(({
|
|
|
5620
5698
|
const [currentAgentId, setCurrentAgentId] = (0, import_react14.useState)(
|
|
5621
5699
|
defaultAgent || agentIds[0] || ""
|
|
5622
5700
|
);
|
|
5701
|
+
const [pendingFollowOnPrompt, setPendingFollowOnPrompt] = (0, import_react14.useState)(null);
|
|
5702
|
+
const [agentSwitchSettled, setAgentSwitchSettled] = (0, import_react14.useState)(true);
|
|
5703
|
+
const lastProcessedFollowOnRef = (0, import_react14.useRef)("");
|
|
5704
|
+
(0, import_react14.useEffect)(() => {
|
|
5705
|
+
if (selectedAgent && selectedAgent !== currentAgentId) {
|
|
5706
|
+
const oldAgentId = currentAgentId;
|
|
5707
|
+
setAgentSwitchSettled(false);
|
|
5708
|
+
setCurrentAgentId(selectedAgent);
|
|
5709
|
+
if (onAgentSwitch) {
|
|
5710
|
+
onAgentSwitch(oldAgentId, selectedAgent);
|
|
5711
|
+
}
|
|
5712
|
+
if (currentConversationIdRef.current) {
|
|
5713
|
+
setActiveConversations((prev) => {
|
|
5714
|
+
const existing = prev.get(currentConversationIdRef.current);
|
|
5715
|
+
if (existing) {
|
|
5716
|
+
const next = new Map(prev);
|
|
5717
|
+
next.set(currentConversationIdRef.current, __spreadProps(__spreadValues({}, existing), {
|
|
5718
|
+
agentId: selectedAgent
|
|
5719
|
+
}));
|
|
5720
|
+
return next;
|
|
5721
|
+
}
|
|
5722
|
+
return prev;
|
|
5723
|
+
});
|
|
5724
|
+
}
|
|
5725
|
+
}
|
|
5726
|
+
}, [selectedAgent]);
|
|
5727
|
+
(0, import_react14.useEffect)(() => {
|
|
5728
|
+
if (!agentSwitchSettled && followOnPrompt && followOnPrompt !== "" && followOnPrompt !== lastProcessedFollowOnRef.current) {
|
|
5729
|
+
setPendingFollowOnPrompt(followOnPrompt);
|
|
5730
|
+
lastProcessedFollowOnRef.current = followOnPrompt;
|
|
5731
|
+
}
|
|
5732
|
+
}, [followOnPrompt, agentSwitchSettled]);
|
|
5733
|
+
(0, import_react14.useEffect)(() => {
|
|
5734
|
+
if (!agentSwitchSettled) {
|
|
5735
|
+
const timer = setTimeout(() => {
|
|
5736
|
+
setAgentSwitchSettled(true);
|
|
5737
|
+
}, 100);
|
|
5738
|
+
return () => clearTimeout(timer);
|
|
5739
|
+
}
|
|
5740
|
+
}, [agentSwitchSettled]);
|
|
5741
|
+
const effectiveFollowOnPrompt = (0, import_react14.useMemo)(() => {
|
|
5742
|
+
if (!agentSwitchSettled) {
|
|
5743
|
+
return "";
|
|
5744
|
+
}
|
|
5745
|
+
if (pendingFollowOnPrompt) {
|
|
5746
|
+
return pendingFollowOnPrompt;
|
|
5747
|
+
}
|
|
5748
|
+
return followOnPrompt;
|
|
5749
|
+
}, [followOnPrompt, pendingFollowOnPrompt, agentSwitchSettled]);
|
|
5750
|
+
(0, import_react14.useEffect)(() => {
|
|
5751
|
+
if (agentSwitchSettled && pendingFollowOnPrompt) {
|
|
5752
|
+
const timer = setTimeout(() => {
|
|
5753
|
+
setPendingFollowOnPrompt(null);
|
|
5754
|
+
}, 100);
|
|
5755
|
+
return () => clearTimeout(timer);
|
|
5756
|
+
}
|
|
5757
|
+
}, [agentSwitchSettled, pendingFollowOnPrompt]);
|
|
5623
5758
|
const [apiConversations, setApiConversations] = (0, import_react14.useState)([]);
|
|
5624
5759
|
const [conversationsLoading, setConversationsLoading] = (0, import_react14.useState)(false);
|
|
5625
5760
|
const [conversationsError, setConversationsError] = (0, import_react14.useState)(null);
|
|
@@ -5636,6 +5771,7 @@ var AIAgentPanel = import_react14.default.forwardRef(({
|
|
|
5636
5771
|
"This Month": false,
|
|
5637
5772
|
"Older": false
|
|
5638
5773
|
});
|
|
5774
|
+
const [disabledContextSections, setDisabledContextSections] = (0, import_react14.useState)(/* @__PURE__ */ new Map());
|
|
5639
5775
|
const {
|
|
5640
5776
|
agents: agentProfiles,
|
|
5641
5777
|
isLoading: agentsLoading,
|
|
@@ -5779,13 +5915,8 @@ var AIAgentPanel = import_react14.default.forwardRef(({
|
|
|
5779
5915
|
fetchInProgressRef.current = true;
|
|
5780
5916
|
setConversationsLoading(true);
|
|
5781
5917
|
setConversationsError(null);
|
|
5782
|
-
console.log("projectId", projectId);
|
|
5783
|
-
console.log("customerId", customerId);
|
|
5784
|
-
console.log("apiKey", apiKey);
|
|
5785
5918
|
try {
|
|
5786
|
-
console.log("fetchConversations - customerId:", customerId);
|
|
5787
5919
|
const url2 = `https://api.llmasaservice.io/conversations?customer_id=${customerId}`;
|
|
5788
|
-
console.log("fetchConversations - URL:", url2);
|
|
5789
5920
|
const response = yield fetch(url2, {
|
|
5790
5921
|
signal,
|
|
5791
5922
|
headers: {
|
|
@@ -6169,8 +6300,21 @@ var AIAgentPanel = import_react14.default.forwardRef(({
|
|
|
6169
6300
|
});
|
|
6170
6301
|
}
|
|
6171
6302
|
}, [pageContextSections, currentAgentId, agentIds, getAgent, localOverrides]);
|
|
6303
|
+
const currentDisabledSections = (0, import_react14.useMemo)(() => {
|
|
6304
|
+
return currentConversationId ? disabledContextSections.get(currentConversationId) || /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set();
|
|
6305
|
+
}, [currentConversationId, disabledContextSections]);
|
|
6306
|
+
const filteredContext = (0, import_react14.useMemo)(() => {
|
|
6307
|
+
const enabledSections = mergedContext.sections.filter(
|
|
6308
|
+
(section) => !currentDisabledSections.has(section.id)
|
|
6309
|
+
);
|
|
6310
|
+
const totalTokens = enabledSections.reduce((sum, s) => sum + (s.tokens || 0), 0);
|
|
6311
|
+
return {
|
|
6312
|
+
sections: enabledSections,
|
|
6313
|
+
totalTokens
|
|
6314
|
+
};
|
|
6315
|
+
}, [mergedContext.sections, currentDisabledSections]);
|
|
6172
6316
|
const chatPanelData = (0, import_react14.useMemo)(() => {
|
|
6173
|
-
const contextData =
|
|
6317
|
+
const contextData = filteredContext.sections.map((section) => ({
|
|
6174
6318
|
key: section.id,
|
|
6175
6319
|
data: JSON.stringify(section.data)
|
|
6176
6320
|
}));
|
|
@@ -6184,7 +6328,7 @@ var AIAgentPanel = import_react14.default.forwardRef(({
|
|
|
6184
6328
|
}
|
|
6185
6329
|
}
|
|
6186
6330
|
return [...data, ...contextData];
|
|
6187
|
-
}, [data,
|
|
6331
|
+
}, [data, filteredContext.sections, buildAgentAwarenessInstructions, currentAgentId, enableAgentSuggestions]);
|
|
6188
6332
|
const handleAgentSwitch = (0, import_react14.useCallback)(
|
|
6189
6333
|
(newAgentId) => {
|
|
6190
6334
|
const oldAgentId = currentAgentId;
|
|
@@ -6315,6 +6459,21 @@ var AIAgentPanel = import_react14.default.forwardRef(({
|
|
|
6315
6459
|
setSuggestedAgent(null);
|
|
6316
6460
|
setHandoffSource("agent");
|
|
6317
6461
|
}, []);
|
|
6462
|
+
const handleContextSectionToggle = (0, import_react14.useCallback)((sectionId, enabled) => {
|
|
6463
|
+
if (!currentConversationId) return;
|
|
6464
|
+
setDisabledContextSections((prev) => {
|
|
6465
|
+
const next = new Map(prev);
|
|
6466
|
+
const conversationDisabled = next.get(currentConversationId) || /* @__PURE__ */ new Set();
|
|
6467
|
+
const nextDisabled = new Set(conversationDisabled);
|
|
6468
|
+
if (enabled) {
|
|
6469
|
+
nextDisabled.delete(sectionId);
|
|
6470
|
+
} else {
|
|
6471
|
+
nextDisabled.add(sectionId);
|
|
6472
|
+
}
|
|
6473
|
+
next.set(currentConversationId, nextDisabled);
|
|
6474
|
+
return next;
|
|
6475
|
+
});
|
|
6476
|
+
}, [currentConversationId]);
|
|
6318
6477
|
const handleConversationCreated = (0, import_react14.useCallback)((tempId, realId) => {
|
|
6319
6478
|
console.log("Conversation created:", tempId, "->", realId);
|
|
6320
6479
|
setActiveConversations((prev) => {
|
|
@@ -6642,15 +6801,17 @@ var AIAgentPanel = import_react14.default.forwardRef(({
|
|
|
6642
6801
|
initialMessage,
|
|
6643
6802
|
hideInitialPrompt,
|
|
6644
6803
|
followOnQuestions,
|
|
6645
|
-
followOnPrompt,
|
|
6804
|
+
followOnPrompt: effectiveFollowOnPrompt,
|
|
6646
6805
|
agentOptions,
|
|
6647
6806
|
currentAgentId,
|
|
6648
6807
|
handleAgentSwitch,
|
|
6649
6808
|
agentsLoading,
|
|
6650
6809
|
contextSections: mergedContext.sections,
|
|
6651
|
-
totalContextTokens:
|
|
6810
|
+
totalContextTokens: filteredContext.totalTokens,
|
|
6652
6811
|
maxContextTokens,
|
|
6653
6812
|
enableContextDetailView,
|
|
6813
|
+
disabledSectionIds: currentDisabledSections,
|
|
6814
|
+
onToggleSection: handleContextSectionToggle,
|
|
6654
6815
|
onConversationCreated: handleConversationCreated,
|
|
6655
6816
|
conversationInitialPrompt: activeConv.conversationInitialPrompt,
|
|
6656
6817
|
cssUrl,
|