@webless/agent 0.2.15 → 0.3.0
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/{chunk-7IR64MFS.js → chunk-MRSLWREA.js} +556 -250
- package/dist/chunk-MRSLWREA.js.map +1 -0
- package/dist/embed.cjs +600 -267
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.css +190 -22
- package/dist/embed.css.map +1 -1
- package/dist/embed.d.cts +3 -33
- package/dist/embed.d.ts +3 -33
- package/dist/embed.js +31 -3
- package/dist/embed.js.map +1 -1
- package/dist/index.cjs +123 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +123 -12
- package/dist/index.js.map +1 -1
- package/dist/manifest-oc_3zCSC.d.cts +79 -0
- package/dist/manifest-oc_3zCSC.d.ts +79 -0
- package/dist/react.cjs +566 -279
- package/dist/react.cjs.map +1 -1
- package/dist/react.css +190 -22
- package/dist/react.css.map +1 -1
- package/dist/react.d.cts +11 -5
- package/dist/react.d.ts +11 -5
- package/dist/react.js +2 -19
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-7IR64MFS.js.map +0 -1
- package/dist/placement-CXW_83AF.d.cts +0 -25
- package/dist/placement-CXW_83AF.d.ts +0 -25
package/dist/embed.cjs
CHANGED
|
@@ -351,9 +351,8 @@ function clearPersistedAgentSession(visitorSessionId, options) {
|
|
|
351
351
|
function isTurnBoundary(event) {
|
|
352
352
|
return event.type === "session.waiting" || event.type === "session.completed" || event.type === "session.failed";
|
|
353
353
|
}
|
|
354
|
-
function applyMessageEvent(event, rendered, handlers) {
|
|
355
|
-
|
|
356
|
-
if (step) handlers.onStep?.(step.label, step.detail);
|
|
354
|
+
function applyMessageEvent(event, rendered, handlers, workItems) {
|
|
355
|
+
applyWorkEvent(event, handlers, workItems);
|
|
357
356
|
if (event.type === "session.failed") {
|
|
358
357
|
throw new Error(event.data.message || event.data.code);
|
|
359
358
|
}
|
|
@@ -396,13 +395,120 @@ function renderTurn(events) {
|
|
|
396
395
|
}
|
|
397
396
|
return rendered;
|
|
398
397
|
}
|
|
399
|
-
function
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
398
|
+
function emitWorkItem(item, handlers, workItems) {
|
|
399
|
+
workItems.set(item.id, item);
|
|
400
|
+
handlers.onWork?.(item);
|
|
401
|
+
handlers.onStep?.(item.label, item.detail);
|
|
402
|
+
}
|
|
403
|
+
function completePlanning(handlers, workItems) {
|
|
404
|
+
const planning = workItems.get("planning");
|
|
405
|
+
if (!planning || planning.state !== "active") return;
|
|
406
|
+
emitWorkItem(
|
|
407
|
+
{
|
|
408
|
+
...planning,
|
|
409
|
+
detail: "Picked the best way to help",
|
|
410
|
+
state: "completed"
|
|
411
|
+
},
|
|
412
|
+
handlers,
|
|
413
|
+
workItems
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
function specialistNameFromInput(input) {
|
|
417
|
+
const message = input.message;
|
|
418
|
+
if (typeof message !== "string") return void 0;
|
|
419
|
+
const match = /^Webless-Agent-Name:\s*(.+)$/imu.exec(message);
|
|
420
|
+
return match?.[1]?.trim() || void 0;
|
|
421
|
+
}
|
|
422
|
+
function requestedWorkItem(action) {
|
|
423
|
+
if (action.kind === "tool-call" && action.toolName === "search_discovery") {
|
|
424
|
+
return {
|
|
425
|
+
id: action.callId,
|
|
426
|
+
kind: "search",
|
|
427
|
+
label: "Search & Discovery",
|
|
428
|
+
detail: "Searching this site",
|
|
429
|
+
state: "active"
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
if (action.kind === "subagent-call" || action.kind === "remote-agent-call" || action.kind === "tool-call" && action.toolName === "agent") {
|
|
433
|
+
const name = specialistNameFromInput(action.input) ?? "Specialist";
|
|
434
|
+
return {
|
|
435
|
+
id: action.callId,
|
|
436
|
+
kind: "specialist",
|
|
437
|
+
label: name,
|
|
438
|
+
detail: "Reviewing your question",
|
|
439
|
+
state: "active"
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
function applyWorkEvent(event, handlers, workItems) {
|
|
445
|
+
if (event.type === "step.started" && workItems.size === 0) {
|
|
446
|
+
emitWorkItem(
|
|
447
|
+
{
|
|
448
|
+
id: "planning",
|
|
449
|
+
kind: "planning",
|
|
450
|
+
label: "Understanding your question",
|
|
451
|
+
state: "active"
|
|
452
|
+
},
|
|
453
|
+
handlers,
|
|
454
|
+
workItems
|
|
455
|
+
);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
if (event.type === "actions.requested") {
|
|
459
|
+
completePlanning(handlers, workItems);
|
|
460
|
+
for (const action of event.data.actions) {
|
|
461
|
+
const item = requestedWorkItem(action);
|
|
462
|
+
if (item) emitWorkItem(item, handlers, workItems);
|
|
463
|
+
}
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
if (event.type === "subagent.called") {
|
|
467
|
+
completePlanning(handlers, workItems);
|
|
468
|
+
const current2 = workItems.get(event.data.callId);
|
|
469
|
+
if (!current2) {
|
|
470
|
+
emitWorkItem(
|
|
471
|
+
{
|
|
472
|
+
id: event.data.callId,
|
|
473
|
+
kind: "specialist",
|
|
474
|
+
label: event.data.name || "Specialist",
|
|
475
|
+
detail: "Reviewing your question",
|
|
476
|
+
state: "active"
|
|
477
|
+
},
|
|
478
|
+
handlers,
|
|
479
|
+
workItems
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (event.type === "subagent.completed") {
|
|
485
|
+
const current2 = workItems.get(event.data.callId);
|
|
486
|
+
if (!current2) return;
|
|
487
|
+
emitWorkItem(
|
|
488
|
+
{
|
|
489
|
+
...current2,
|
|
490
|
+
detail: "Guidance received",
|
|
491
|
+
state: "completed"
|
|
492
|
+
},
|
|
493
|
+
handlers,
|
|
494
|
+
workItems
|
|
495
|
+
);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
if (event.type !== "action.result") return;
|
|
499
|
+
const { result, status } = event.data;
|
|
500
|
+
const current = workItems.get(result.callId);
|
|
501
|
+
if (!current) return;
|
|
502
|
+
const failed = status !== "completed" || result.isError === true;
|
|
503
|
+
emitWorkItem(
|
|
504
|
+
{
|
|
505
|
+
...current,
|
|
506
|
+
detail: failed ? "Couldn\u2019t complete; continuing with available information" : current.kind === "search" ? "Found relevant site content" : "Guidance received",
|
|
507
|
+
state: failed ? "error" : "completed"
|
|
508
|
+
},
|
|
509
|
+
handlers,
|
|
510
|
+
workItems
|
|
511
|
+
);
|
|
406
512
|
}
|
|
407
513
|
var AgentSession = class {
|
|
408
514
|
constructor(indexId, version, runtimeOrigin, visitorSessionId, storeOptions, getUnpublishedPreviewGrant) {
|
|
@@ -520,10 +626,11 @@ var AgentSession = class {
|
|
|
520
626
|
this.activeResponse = response;
|
|
521
627
|
let streamIndex = session?.state.streamIndex ?? 0;
|
|
522
628
|
let rendered = "";
|
|
629
|
+
const workItems = /* @__PURE__ */ new Map();
|
|
523
630
|
try {
|
|
524
631
|
for await (const event of response) {
|
|
525
632
|
if (signal.aborted) break;
|
|
526
|
-
rendered = applyMessageEvent(event, rendered, handlers);
|
|
633
|
+
rendered = applyMessageEvent(event, rendered, handlers, workItems);
|
|
527
634
|
streamIndex += 1;
|
|
528
635
|
if (session) {
|
|
529
636
|
savePersistedAgentSession(
|
|
@@ -565,6 +672,10 @@ var AgentSession = class {
|
|
|
565
672
|
return null;
|
|
566
673
|
}
|
|
567
674
|
let rendered = renderTurn(turnEvents);
|
|
675
|
+
const workItems = /* @__PURE__ */ new Map();
|
|
676
|
+
for (const event of turnEvents) {
|
|
677
|
+
applyWorkEvent(event, handlers, workItems);
|
|
678
|
+
}
|
|
568
679
|
if (rendered.startsWith(initialText)) {
|
|
569
680
|
const missedText = rendered.slice(initialText.length);
|
|
570
681
|
if (missedText) handlers.onDelta(missedText);
|
|
@@ -599,7 +710,7 @@ var AgentSession = class {
|
|
|
599
710
|
let streamIndex = snapshot.session.streamIndex;
|
|
600
711
|
for await (const event of session.stream({ signal })) {
|
|
601
712
|
if (signal.aborted) break;
|
|
602
|
-
rendered = applyMessageEvent(event, rendered, handlers);
|
|
713
|
+
rendered = applyMessageEvent(event, rendered, handlers, workItems);
|
|
603
714
|
streamIndex += 1;
|
|
604
715
|
savePersistedAgentSession(
|
|
605
716
|
this.visitorSessionId,
|
|
@@ -752,57 +863,54 @@ function clearPersistedAgentConversation(storageKeyPrefix, visitorSessionId) {
|
|
|
752
863
|
}
|
|
753
864
|
|
|
754
865
|
// src/react/hooks/useAgentChat.ts
|
|
755
|
-
var
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
866
|
+
var DEFAULT_GREETING = "Hi! I can search this site or bring in a specialist when it helps. What would you like to know?";
|
|
867
|
+
function createInitialState(greeting = DEFAULT_GREETING) {
|
|
868
|
+
return {
|
|
869
|
+
phase: "idle",
|
|
870
|
+
messages: [
|
|
871
|
+
{
|
|
872
|
+
id: "greeting",
|
|
873
|
+
role: "agent",
|
|
874
|
+
text: greeting,
|
|
875
|
+
createdAt: 0
|
|
876
|
+
}
|
|
877
|
+
],
|
|
878
|
+
toolSteps: [],
|
|
879
|
+
journey: null,
|
|
880
|
+
followUps: [],
|
|
881
|
+
streamingText: "",
|
|
882
|
+
error: null
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function stateFromConversation(conversation, initialState) {
|
|
886
|
+
if (!conversation || conversation.messages.length === 0) return initialState;
|
|
772
887
|
return {
|
|
773
|
-
...
|
|
888
|
+
...initialState,
|
|
774
889
|
messages: conversation.messages,
|
|
775
890
|
phase: conversation.pending ? conversation.streamingText ? "streaming" : "thinking" : "complete",
|
|
776
891
|
streamingText: conversation.streamingText
|
|
777
892
|
};
|
|
778
893
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
)
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
id: item.id,
|
|
800
|
-
label: item.label,
|
|
801
|
-
detail: item.detail,
|
|
802
|
-
state: "active"
|
|
803
|
-
});
|
|
804
|
-
await delay(item.ms, signal);
|
|
805
|
-
}
|
|
894
|
+
function upsertToolStep(steps, item) {
|
|
895
|
+
const next = {
|
|
896
|
+
id: item.id,
|
|
897
|
+
kind: item.kind,
|
|
898
|
+
label: item.label,
|
|
899
|
+
state: item.state,
|
|
900
|
+
...item.detail ? { detail: item.detail } : {}
|
|
901
|
+
};
|
|
902
|
+
const index = steps.findIndex((step) => step.id === item.id);
|
|
903
|
+
if (index < 0) return [...steps, next];
|
|
904
|
+
return steps.map((step, stepIndex) => stepIndex === index ? next : step);
|
|
905
|
+
}
|
|
906
|
+
function completeActivePlanning(steps) {
|
|
907
|
+
return steps.map(
|
|
908
|
+
(step) => step.kind === "planning" && step.state === "active" ? {
|
|
909
|
+
...step,
|
|
910
|
+
detail: "Prepared a response",
|
|
911
|
+
state: "completed"
|
|
912
|
+
} : step
|
|
913
|
+
);
|
|
806
914
|
}
|
|
807
915
|
function useAgentChat({
|
|
808
916
|
customerId,
|
|
@@ -811,8 +919,13 @@ function useAgentChat({
|
|
|
811
919
|
version,
|
|
812
920
|
runtimeOrigin,
|
|
813
921
|
visitorSessionId,
|
|
814
|
-
storageKeyPrefix
|
|
922
|
+
storageKeyPrefix,
|
|
923
|
+
greeting
|
|
815
924
|
}) {
|
|
925
|
+
const initialState = (0, import_react2.useMemo)(
|
|
926
|
+
() => createInitialState(greeting?.trim() || DEFAULT_GREETING),
|
|
927
|
+
[greeting]
|
|
928
|
+
);
|
|
816
929
|
const previewGrantProviderRef = (0, import_react2.useRef)(getUnpublishedPreviewGrant);
|
|
817
930
|
previewGrantProviderRef.current = getUnpublishedPreviewGrant;
|
|
818
931
|
const resolveUnpublishedPreviewGrant = () => {
|
|
@@ -843,7 +956,8 @@ function useAgentChat({
|
|
|
843
956
|
);
|
|
844
957
|
const [state, setState] = (0, import_react2.useState)(
|
|
845
958
|
() => stateFromConversation(
|
|
846
|
-
loadPersistedAgentConversation(resolvedStorageKeyPrefix, visitorId)
|
|
959
|
+
loadPersistedAgentConversation(resolvedStorageKeyPrefix, visitorId),
|
|
960
|
+
initialState
|
|
847
961
|
)
|
|
848
962
|
);
|
|
849
963
|
const runRef = (0, import_react2.useRef)(null);
|
|
@@ -858,7 +972,7 @@ function useAgentChat({
|
|
|
858
972
|
storageKeyPrefix: resolvedStorageKeyPrefix
|
|
859
973
|
})
|
|
860
974
|
);
|
|
861
|
-
const identityKey = `${customerId ?? ""}|${indexId}|${version ?? "published"}|${runtimeOrigin ?? ""}|${resolvedStorageKeyPrefix}|${visitorId}`;
|
|
975
|
+
const identityKey = `${customerId ?? ""}|${indexId}|${version ?? "published"}|${runtimeOrigin ?? ""}|${resolvedStorageKeyPrefix}|${visitorId}|${greeting ?? ""}`;
|
|
862
976
|
const identityRef = (0, import_react2.useRef)(identityKey);
|
|
863
977
|
(0, import_react2.useEffect)(() => {
|
|
864
978
|
if (identityRef.current === identityKey) {
|
|
@@ -878,13 +992,15 @@ function useAgentChat({
|
|
|
878
992
|
});
|
|
879
993
|
setState(
|
|
880
994
|
stateFromConversation(
|
|
881
|
-
loadPersistedAgentConversation(resolvedStorageKeyPrefix, visitorId)
|
|
995
|
+
loadPersistedAgentConversation(resolvedStorageKeyPrefix, visitorId),
|
|
996
|
+
initialState
|
|
882
997
|
)
|
|
883
998
|
);
|
|
884
999
|
}, [
|
|
885
1000
|
customerId,
|
|
886
1001
|
identityKey,
|
|
887
1002
|
indexId,
|
|
1003
|
+
initialState,
|
|
888
1004
|
runtimeOrigin,
|
|
889
1005
|
resolvedStorageKeyPrefix,
|
|
890
1006
|
version,
|
|
@@ -909,8 +1025,8 @@ function useAgentChat({
|
|
|
909
1025
|
runRef.current = null;
|
|
910
1026
|
clientRef.current.reset();
|
|
911
1027
|
clearPersistedAgentConversation(resolvedStorageKeyPrefix, visitorId);
|
|
912
|
-
setState(
|
|
913
|
-
}, [resolvedStorageKeyPrefix, visitorId]);
|
|
1028
|
+
setState(initialState);
|
|
1029
|
+
}, [initialState, resolvedStorageKeyPrefix, visitorId]);
|
|
914
1030
|
const runTurn = (0, import_react2.useCallback)(
|
|
915
1031
|
async (input) => {
|
|
916
1032
|
const { controller, initialText = "", resume, visitorText } = input;
|
|
@@ -919,35 +1035,23 @@ function useAgentChat({
|
|
|
919
1035
|
try {
|
|
920
1036
|
let streamStarted = Boolean(initialText);
|
|
921
1037
|
let streamed = initialText;
|
|
922
|
-
const planningPromise = resume ? Promise.resolve() : runStatusSequence(signal, (step) => {
|
|
923
|
-
if (streamStarted || !isActiveRun()) return;
|
|
924
|
-
setState((prev) => ({
|
|
925
|
-
...prev,
|
|
926
|
-
phase: "running-tools",
|
|
927
|
-
toolSteps: [step]
|
|
928
|
-
}));
|
|
929
|
-
});
|
|
930
1038
|
const handlers = {
|
|
931
|
-
|
|
932
|
-
if (
|
|
1039
|
+
onWork: (item) => {
|
|
1040
|
+
if (!isActiveRun()) return;
|
|
933
1041
|
setState((prev) => ({
|
|
934
1042
|
...prev,
|
|
935
|
-
phase: "running-tools",
|
|
936
|
-
toolSteps:
|
|
937
|
-
{ id: `step-${label}`, label, detail, state: "active" }
|
|
938
|
-
]
|
|
1043
|
+
phase: item.state === "active" ? "running-tools" : prev.phase,
|
|
1044
|
+
toolSteps: upsertToolStep(prev.toolSteps, item)
|
|
939
1045
|
}));
|
|
940
1046
|
},
|
|
941
1047
|
onDelta: (delta) => {
|
|
942
1048
|
if (!isActiveRun()) return;
|
|
943
|
-
void planningPromise.catch(() => {
|
|
944
|
-
});
|
|
945
1049
|
if (!streamStarted) {
|
|
946
1050
|
streamStarted = true;
|
|
947
1051
|
setState((prev) => ({
|
|
948
1052
|
...prev,
|
|
949
1053
|
phase: "streaming",
|
|
950
|
-
toolSteps:
|
|
1054
|
+
toolSteps: completeActivePlanning(prev.toolSteps),
|
|
951
1055
|
streamingText: ""
|
|
952
1056
|
}));
|
|
953
1057
|
}
|
|
@@ -975,8 +1079,6 @@ function useAgentChat({
|
|
|
975
1079
|
signal
|
|
976
1080
|
});
|
|
977
1081
|
}
|
|
978
|
-
await planningPromise.catch(() => {
|
|
979
|
-
});
|
|
980
1082
|
if (!isActiveRun() || finalText === null) return;
|
|
981
1083
|
const agentMessage = {
|
|
982
1084
|
id: `agent-${Date.now()}`,
|
|
@@ -988,7 +1090,7 @@ function useAgentChat({
|
|
|
988
1090
|
...prev,
|
|
989
1091
|
phase: "complete",
|
|
990
1092
|
messages: [...prev.messages, agentMessage],
|
|
991
|
-
toolSteps:
|
|
1093
|
+
toolSteps: completeActivePlanning(prev.toolSteps),
|
|
992
1094
|
streamingText: "",
|
|
993
1095
|
followUps: [],
|
|
994
1096
|
journey: null
|
|
@@ -1003,7 +1105,13 @@ function useAgentChat({
|
|
|
1003
1105
|
setState((prev) => ({
|
|
1004
1106
|
...prev,
|
|
1005
1107
|
phase: "complete",
|
|
1006
|
-
toolSteps:
|
|
1108
|
+
toolSteps: prev.toolSteps.map(
|
|
1109
|
+
(step) => step.state === "active" ? {
|
|
1110
|
+
...step,
|
|
1111
|
+
detail: "Couldn\u2019t complete this step",
|
|
1112
|
+
state: "error"
|
|
1113
|
+
} : step
|
|
1114
|
+
),
|
|
1007
1115
|
streamingText: "",
|
|
1008
1116
|
error: message
|
|
1009
1117
|
}));
|
|
@@ -1031,7 +1139,12 @@ function useAgentChat({
|
|
|
1031
1139
|
phase: "thinking",
|
|
1032
1140
|
messages: [...prev.messages, visitorMessage],
|
|
1033
1141
|
toolSteps: [
|
|
1034
|
-
{
|
|
1142
|
+
{
|
|
1143
|
+
id: "planning",
|
|
1144
|
+
kind: "planning",
|
|
1145
|
+
label: "Understanding your question",
|
|
1146
|
+
state: "active"
|
|
1147
|
+
}
|
|
1035
1148
|
],
|
|
1036
1149
|
journey: null,
|
|
1037
1150
|
followUps: [],
|
|
@@ -1129,79 +1242,93 @@ function normalizeAgentPlacement(placement) {
|
|
|
1129
1242
|
// src/react/components/AgentRail/AgentRail.tsx
|
|
1130
1243
|
var import_react5 = require("react");
|
|
1131
1244
|
|
|
1132
|
-
// src/react/
|
|
1133
|
-
var
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
streamingText,
|
|
1152
|
-
showStreaming = false,
|
|
1153
|
-
inline = false
|
|
1154
|
-
}) {
|
|
1155
|
-
if (steps.length === 0 && !(showStreaming && streamingText)) return null;
|
|
1156
|
-
const currentStep = getCurrentStep(steps);
|
|
1157
|
-
const showStatus = currentStep && currentStep.state !== "completed" && !(showStreaming && streamingText);
|
|
1158
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1159
|
-
"div",
|
|
1160
|
-
{
|
|
1161
|
-
className: `tool-timeline${inline ? " tool-timeline--inline" : ""}`,
|
|
1162
|
-
role: "status",
|
|
1163
|
-
"aria-live": "polite",
|
|
1164
|
-
"aria-label": "Agent progress",
|
|
1165
|
-
children: [
|
|
1166
|
-
showStatus ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "agent-status", children: [
|
|
1167
|
-
currentStep.state === "error" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "agent-status__icon agent-status__icon--error", "aria-hidden": "true", children: "!" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "agent-status__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpinnerIcon, {}) }),
|
|
1168
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "agent-status__copy", children: [
|
|
1169
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "agent-status__label", children: currentStep.label }),
|
|
1170
|
-
currentStep.detail ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "agent-status__detail", children: currentStep.detail }) : null
|
|
1171
|
-
] })
|
|
1172
|
-
] }, currentStep.id) : null,
|
|
1173
|
-
showStreaming && streamingText ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "tool-timeline__streaming-text", children: [
|
|
1174
|
-
streamingText,
|
|
1175
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "tool-timeline__cursor", "aria-hidden": "true" })
|
|
1176
|
-
] }) : null
|
|
1177
|
-
]
|
|
1178
|
-
}
|
|
1179
|
-
);
|
|
1180
|
-
}
|
|
1245
|
+
// src/react/types/conversation.ts
|
|
1246
|
+
var defaultAgentRailTheme = {
|
|
1247
|
+
railMaxWidth: "450px",
|
|
1248
|
+
brand: "#6f16ff",
|
|
1249
|
+
brandSoft: "#f3edff",
|
|
1250
|
+
brandDeep: "#12043e",
|
|
1251
|
+
surface: "#ffffff",
|
|
1252
|
+
surfaceMuted: "#f4f6fb",
|
|
1253
|
+
text: "#171b2a",
|
|
1254
|
+
textMuted: "#5a6378",
|
|
1255
|
+
textSubtle: "#8a94a8",
|
|
1256
|
+
border: "rgb(42 51 70 / 0.1)",
|
|
1257
|
+
visitorBubble: "#6f16ff",
|
|
1258
|
+
visitorText: "#ffffff",
|
|
1259
|
+
success: "#18794e",
|
|
1260
|
+
danger: "#c94b63",
|
|
1261
|
+
fontBody: '"Mulish", "Avenir Next", "Segoe UI", sans-serif',
|
|
1262
|
+
fontDisplay: '"Space Grotesk", sans-serif'
|
|
1263
|
+
};
|
|
1181
1264
|
|
|
1182
1265
|
// src/react/components/AgentActivityBubble/AgentActivityBubble.tsx
|
|
1183
|
-
var
|
|
1184
|
-
function
|
|
1185
|
-
steps
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1266
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1267
|
+
function workSummary(steps) {
|
|
1268
|
+
const active = [...steps].reverse().find((step) => step.state === "active");
|
|
1269
|
+
if (active?.kind === "specialist") return `Working with ${active.label}`;
|
|
1270
|
+
if (active?.kind === "search") return "Searching this site";
|
|
1271
|
+
if (active) return active.label;
|
|
1272
|
+
const hasError = steps.some((step) => step.state === "error");
|
|
1273
|
+
const specialists = steps.filter(
|
|
1274
|
+
(step) => step.kind === "specialist" && step.state === "completed"
|
|
1275
|
+
);
|
|
1276
|
+
const searched = steps.some(
|
|
1277
|
+
(step) => step.kind === "search" && step.state === "completed"
|
|
1278
|
+
);
|
|
1279
|
+
if (hasError) return "Answered with available information";
|
|
1280
|
+
if (specialists.length > 1)
|
|
1281
|
+
return `Consulted ${specialists.length} specialists`;
|
|
1282
|
+
if (specialists.length === 1) return `Consulted ${specialists[0]?.label}`;
|
|
1283
|
+
if (searched) return "Searched this site";
|
|
1284
|
+
return "Prepared a response";
|
|
1285
|
+
}
|
|
1286
|
+
function AgentActivityBubble({ steps }) {
|
|
1287
|
+
const active = steps.some((step) => step.state === "active");
|
|
1288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: "agent-activity-bubble", children: [
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "agent-activity-bubble__status", "aria-live": "polite", children: [
|
|
1290
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1291
|
+
"span",
|
|
1292
|
+
{
|
|
1293
|
+
className: `agent-activity-bubble__pulse${active ? " is-active" : ""}`,
|
|
1294
|
+
"aria-hidden": "true"
|
|
1295
|
+
}
|
|
1296
|
+
),
|
|
1297
|
+
workSummary(steps)
|
|
1298
|
+
] }),
|
|
1299
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", { className: "agent-activity-bubble__details", open: active, children: [
|
|
1300
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { children: "Work details" }),
|
|
1301
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", { className: "agent-activity-bubble__steps", children: steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1302
|
+
"li",
|
|
1303
|
+
{
|
|
1304
|
+
className: "agent-activity-bubble__step",
|
|
1305
|
+
"data-state": step.state,
|
|
1306
|
+
children: [
|
|
1307
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1308
|
+
"span",
|
|
1309
|
+
{
|
|
1310
|
+
className: "agent-activity-bubble__step-icon",
|
|
1311
|
+
"aria-hidden": "true",
|
|
1312
|
+
children: step.state === "completed" ? "\u2713" : step.state === "error" ? "!" : ""
|
|
1313
|
+
}
|
|
1314
|
+
),
|
|
1315
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "agent-activity-bubble__step-copy", children: [
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: step.label }),
|
|
1317
|
+
step.detail ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: step.detail }) : null
|
|
1318
|
+
] })
|
|
1319
|
+
]
|
|
1320
|
+
},
|
|
1321
|
+
step.id
|
|
1322
|
+
)) })
|
|
1323
|
+
] })
|
|
1324
|
+
] });
|
|
1198
1325
|
}
|
|
1199
1326
|
|
|
1200
1327
|
// src/react/components/Composer/Composer.tsx
|
|
1201
1328
|
var import_react4 = require("react");
|
|
1202
|
-
var
|
|
1329
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1203
1330
|
function SendIcon() {
|
|
1204
|
-
return /* @__PURE__ */ (0,
|
|
1331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M8 12V4M8 4l-3 3M8 4l3 3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1205
1332
|
}
|
|
1206
1333
|
function Composer({
|
|
1207
1334
|
disabled = false,
|
|
@@ -1228,8 +1355,8 @@ function Composer({
|
|
|
1228
1355
|
submitCurrent();
|
|
1229
1356
|
}
|
|
1230
1357
|
}
|
|
1231
|
-
return /* @__PURE__ */ (0,
|
|
1232
|
-
/* @__PURE__ */ (0,
|
|
1358
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("form", { className: `composer${variant === "dock" ? " composer--dock" : ""}`, onSubmit: handleSubmit, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "composer__field", children: [
|
|
1359
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1233
1360
|
"textarea",
|
|
1234
1361
|
{
|
|
1235
1362
|
ref: inputRef,
|
|
@@ -1243,21 +1370,21 @@ function Composer({
|
|
|
1243
1370
|
onKeyDown: handleKeyDown
|
|
1244
1371
|
}
|
|
1245
1372
|
),
|
|
1246
|
-
/* @__PURE__ */ (0,
|
|
1373
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1247
1374
|
"button",
|
|
1248
1375
|
{
|
|
1249
1376
|
type: "submit",
|
|
1250
1377
|
className: "composer__send",
|
|
1251
1378
|
disabled: disabled || !value.trim(),
|
|
1252
1379
|
"aria-label": "Send message",
|
|
1253
|
-
children: /* @__PURE__ */ (0,
|
|
1380
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SendIcon, {})
|
|
1254
1381
|
}
|
|
1255
1382
|
)
|
|
1256
1383
|
] }) });
|
|
1257
1384
|
}
|
|
1258
1385
|
|
|
1259
1386
|
// src/react/components/FollowUpChips/FollowUpChips.tsx
|
|
1260
|
-
var
|
|
1387
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1261
1388
|
function FollowUpChips({
|
|
1262
1389
|
suggestions,
|
|
1263
1390
|
disabled = false,
|
|
@@ -1267,7 +1394,7 @@ function FollowUpChips({
|
|
|
1267
1394
|
}) {
|
|
1268
1395
|
if (suggestions.length === 0) return null;
|
|
1269
1396
|
if (variant === "dock") {
|
|
1270
|
-
return /* @__PURE__ */ (0,
|
|
1397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "followups followups--dock", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "followups__scroll", children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1271
1398
|
"button",
|
|
1272
1399
|
{
|
|
1273
1400
|
type: "button",
|
|
@@ -1279,9 +1406,9 @@ function FollowUpChips({
|
|
|
1279
1406
|
suggestion.id
|
|
1280
1407
|
)) }) });
|
|
1281
1408
|
}
|
|
1282
|
-
return /* @__PURE__ */ (0,
|
|
1283
|
-
/* @__PURE__ */ (0,
|
|
1284
|
-
/* @__PURE__ */ (0,
|
|
1409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "followups", children: [
|
|
1410
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "followups__label", children: label }),
|
|
1411
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "followups__list", children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1285
1412
|
"button",
|
|
1286
1413
|
{
|
|
1287
1414
|
type: "button",
|
|
@@ -1298,12 +1425,12 @@ function FollowUpChips({
|
|
|
1298
1425
|
// src/react/components/MessageBubble/MessageBubble.tsx
|
|
1299
1426
|
var import_streamdown = require("streamdown");
|
|
1300
1427
|
var import_styles = require("streamdown/styles.css");
|
|
1301
|
-
var
|
|
1428
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1302
1429
|
function MessageBubble({ message }) {
|
|
1303
1430
|
if (message.role === "visitor") {
|
|
1304
|
-
return /* @__PURE__ */ (0,
|
|
1431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("article", { className: "message-bubble message-bubble--visitor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "message-bubble__text", children: message.text }) });
|
|
1305
1432
|
}
|
|
1306
|
-
return /* @__PURE__ */ (0,
|
|
1433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("article", { className: "message-bubble message-bubble--agent", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "message-bubble__text", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1307
1434
|
import_streamdown.Streamdown,
|
|
1308
1435
|
{
|
|
1309
1436
|
animated: true,
|
|
@@ -1320,12 +1447,20 @@ function MessageBubble({ message }) {
|
|
|
1320
1447
|
}
|
|
1321
1448
|
|
|
1322
1449
|
// src/react/components/AgentRail/AgentRail.tsx
|
|
1323
|
-
var
|
|
1450
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1324
1451
|
function MinimizeIcon() {
|
|
1325
|
-
return /* @__PURE__ */ (0,
|
|
1452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1453
|
+
"path",
|
|
1454
|
+
{
|
|
1455
|
+
d: "M3.5 8h9",
|
|
1456
|
+
stroke: "currentColor",
|
|
1457
|
+
strokeWidth: "1.7",
|
|
1458
|
+
strokeLinecap: "round"
|
|
1459
|
+
}
|
|
1460
|
+
) });
|
|
1326
1461
|
}
|
|
1327
1462
|
function ExpandIcon() {
|
|
1328
|
-
return /* @__PURE__ */ (0,
|
|
1463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1329
1464
|
"path",
|
|
1330
1465
|
{
|
|
1331
1466
|
d: "M6 3.5H3.5V6M10 3.5h2.5V6M10 12.5h2.5V10M6 12.5H3.5V10",
|
|
@@ -1337,7 +1472,7 @@ function ExpandIcon() {
|
|
|
1337
1472
|
) });
|
|
1338
1473
|
}
|
|
1339
1474
|
function RestoreIcon() {
|
|
1340
|
-
return /* @__PURE__ */ (0,
|
|
1475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1341
1476
|
"path",
|
|
1342
1477
|
{
|
|
1343
1478
|
d: "M5.5 5.5H3.5V7.5M10.5 5.5h2V7.5M10.5 10.5h2V8.5M5.5 10.5H3.5V8.5",
|
|
@@ -1352,6 +1487,7 @@ function AgentRail({
|
|
|
1352
1487
|
state,
|
|
1353
1488
|
theme,
|
|
1354
1489
|
brandLabel = "Webless Assist",
|
|
1490
|
+
brandLogoUrl,
|
|
1355
1491
|
poweredByLabel = "Powered by Webless",
|
|
1356
1492
|
composerPlaceholder = "Ask anything\u2026",
|
|
1357
1493
|
mobileFullscreen = false,
|
|
@@ -1363,10 +1499,31 @@ function AgentRail({
|
|
|
1363
1499
|
onFollowUpSelect
|
|
1364
1500
|
}) {
|
|
1365
1501
|
const transcriptRef = (0, import_react5.useRef)(null);
|
|
1366
|
-
const
|
|
1502
|
+
const resolvedTheme = { ...defaultAgentRailTheme, ...theme };
|
|
1503
|
+
const railStyle = {
|
|
1504
|
+
"--rail-width": resolvedTheme.railMaxWidth,
|
|
1505
|
+
"--as-rail-max-width": resolvedTheme.railMaxWidth,
|
|
1506
|
+
"--as-brand": resolvedTheme.brand,
|
|
1507
|
+
"--as-brand-soft": resolvedTheme.brandSoft,
|
|
1508
|
+
"--as-brand-deep": resolvedTheme.brandDeep,
|
|
1509
|
+
"--as-surface": resolvedTheme.surface,
|
|
1510
|
+
"--as-surface-muted": resolvedTheme.surfaceMuted,
|
|
1511
|
+
"--as-text": resolvedTheme.text,
|
|
1512
|
+
"--as-text-muted": resolvedTheme.textMuted,
|
|
1513
|
+
"--as-text-subtle": resolvedTheme.textSubtle,
|
|
1514
|
+
"--as-border": resolvedTheme.border,
|
|
1515
|
+
"--as-visitor-bubble": resolvedTheme.visitorBubble,
|
|
1516
|
+
"--as-visitor-text": resolvedTheme.visitorText,
|
|
1517
|
+
"--as-success": resolvedTheme.success,
|
|
1518
|
+
"--as-danger": resolvedTheme.danger,
|
|
1519
|
+
"--as-font-body": resolvedTheme.fontBody,
|
|
1520
|
+
"--as-font-display": resolvedTheme.fontDisplay
|
|
1521
|
+
};
|
|
1367
1522
|
const isBusy = state.phase === "thinking" || state.phase === "running-tools" || state.phase === "streaming";
|
|
1368
|
-
const showActivity = state.toolSteps.length > 0
|
|
1369
|
-
const hasVisitorMessages2 = state.messages.some(
|
|
1523
|
+
const showActivity = state.toolSteps.length > 0;
|
|
1524
|
+
const hasVisitorMessages2 = state.messages.some(
|
|
1525
|
+
(message) => message.role === "visitor"
|
|
1526
|
+
);
|
|
1370
1527
|
const showIdleFollowUps = !hasVisitorMessages2 && state.followUps.length > 0;
|
|
1371
1528
|
const showDockFollowUps = expanded && showIdleFollowUps;
|
|
1372
1529
|
const streamingMessage = state.phase === "streaming" && state.streamingText ? {
|
|
@@ -1380,42 +1537,73 @@ function AgentRail({
|
|
|
1380
1537
|
const node = transcriptRef.current;
|
|
1381
1538
|
if (!node) return;
|
|
1382
1539
|
node.scrollTop = node.scrollHeight;
|
|
1383
|
-
}, [
|
|
1384
|
-
|
|
1540
|
+
}, [
|
|
1541
|
+
state.messages,
|
|
1542
|
+
state.toolSteps,
|
|
1543
|
+
state.streamingText,
|
|
1544
|
+
state.followUps,
|
|
1545
|
+
state.journey
|
|
1546
|
+
]);
|
|
1547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1385
1548
|
"aside",
|
|
1386
1549
|
{
|
|
1387
1550
|
className: `agent-rail${mobileFullscreen ? " agent-rail--mobile-fullscreen" : ""}${expanded ? " agent-rail--expanded" : ""}`,
|
|
1388
1551
|
style: railStyle,
|
|
1389
1552
|
"aria-label": "Agent conversation",
|
|
1390
1553
|
children: [
|
|
1391
|
-
/* @__PURE__ */ (0,
|
|
1392
|
-
onCollapse ? /* @__PURE__ */ (0,
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("header", { className: "agent-rail__header", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "agent-rail__brand-row", children: [
|
|
1555
|
+
onCollapse ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1393
1556
|
"button",
|
|
1394
1557
|
{
|
|
1395
1558
|
type: "button",
|
|
1396
1559
|
className: "agent-rail__collapse",
|
|
1397
1560
|
"aria-label": "Collapse assist",
|
|
1398
1561
|
onClick: onCollapse,
|
|
1399
|
-
children: /* @__PURE__ */ (0,
|
|
1562
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MinimizeIcon, {})
|
|
1400
1563
|
}
|
|
1401
|
-
) : onClose ? /* @__PURE__ */ (0,
|
|
1402
|
-
|
|
1403
|
-
|
|
1564
|
+
) : onClose ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1565
|
+
"button",
|
|
1566
|
+
{
|
|
1567
|
+
type: "button",
|
|
1568
|
+
className: "agent-rail__close",
|
|
1569
|
+
"aria-label": "Close agent",
|
|
1570
|
+
onClick: onClose,
|
|
1571
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MinimizeIcon, {})
|
|
1572
|
+
}
|
|
1573
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "agent-rail__brand-spacer", "aria-hidden": "true" }),
|
|
1574
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "agent-rail__identity", children: [
|
|
1575
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "agent-rail__brand-mark", "aria-hidden": "true", children: [
|
|
1576
|
+
brandLabel.slice(0, 1).toUpperCase(),
|
|
1577
|
+
brandLogoUrl ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1578
|
+
"img",
|
|
1579
|
+
{
|
|
1580
|
+
className: "agent-rail__brand-logo",
|
|
1581
|
+
src: brandLogoUrl,
|
|
1582
|
+
alt: "",
|
|
1583
|
+
onError: (event) => {
|
|
1584
|
+
event.currentTarget.hidden = true;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
) : null
|
|
1588
|
+
] }),
|
|
1589
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "agent-rail__brand-label", children: brandLabel })
|
|
1590
|
+
] }),
|
|
1591
|
+
onExpandToggle ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1404
1592
|
"button",
|
|
1405
1593
|
{
|
|
1406
1594
|
type: "button",
|
|
1407
1595
|
className: "agent-rail__expand",
|
|
1408
1596
|
"aria-label": expanded ? "Restore assist panel" : "Expand assist panel",
|
|
1409
1597
|
onClick: onExpandToggle,
|
|
1410
|
-
children: expanded ? /* @__PURE__ */ (0,
|
|
1598
|
+
children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RestoreIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ExpandIcon, {})
|
|
1411
1599
|
}
|
|
1412
|
-
) : /* @__PURE__ */ (0,
|
|
1600
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "agent-rail__brand-spacer", "aria-hidden": "true" })
|
|
1413
1601
|
] }) }),
|
|
1414
|
-
/* @__PURE__ */ (0,
|
|
1415
|
-
state.messages.map((message) => /* @__PURE__ */ (0,
|
|
1416
|
-
streamingMessage ? /* @__PURE__ */ (0,
|
|
1417
|
-
showActivity ? /* @__PURE__ */ (0,
|
|
1418
|
-
!expanded && showIdleFollowUps ? /* @__PURE__ */ (0,
|
|
1602
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { ref: transcriptRef, className: "agent-rail__transcript", children: [
|
|
1603
|
+
state.messages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MessageBubble, { message }, message.id)),
|
|
1604
|
+
streamingMessage ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MessageBubble, { message: streamingMessage }) : null,
|
|
1605
|
+
showActivity ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AgentActivityBubble, { steps: state.toolSteps }) : null,
|
|
1606
|
+
!expanded && showIdleFollowUps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "agent-rail__followups-slot", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1419
1607
|
FollowUpChips,
|
|
1420
1608
|
{
|
|
1421
1609
|
suggestions: state.followUps,
|
|
@@ -1424,10 +1612,17 @@ function AgentRail({
|
|
|
1424
1612
|
onSelect: (suggestion) => onFollowUpSelect?.(suggestion.label)
|
|
1425
1613
|
}
|
|
1426
1614
|
) }) : null,
|
|
1427
|
-
state.error ? /* @__PURE__ */ (0,
|
|
1615
|
+
state.error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1616
|
+
"p",
|
|
1617
|
+
{
|
|
1618
|
+
role: "alert",
|
|
1619
|
+
style: { fontSize: 13, color: "var(--as-danger)", margin: 0 },
|
|
1620
|
+
children: state.error
|
|
1621
|
+
}
|
|
1622
|
+
) : null
|
|
1428
1623
|
] }),
|
|
1429
|
-
expanded ? /* @__PURE__ */ (0,
|
|
1430
|
-
showDockFollowUps ? /* @__PURE__ */ (0,
|
|
1624
|
+
expanded ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "agent-rail__dock-wrap", children: [
|
|
1625
|
+
showDockFollowUps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "agent-rail__dock-followups", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1431
1626
|
FollowUpChips,
|
|
1432
1627
|
{
|
|
1433
1628
|
variant: "dock",
|
|
@@ -1436,7 +1631,7 @@ function AgentRail({
|
|
|
1436
1631
|
onSelect: (suggestion) => onFollowUpSelect?.(suggestion.label)
|
|
1437
1632
|
}
|
|
1438
1633
|
) }) : null,
|
|
1439
|
-
/* @__PURE__ */ (0,
|
|
1634
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "agent-rail__dock", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1440
1635
|
Composer,
|
|
1441
1636
|
{
|
|
1442
1637
|
variant: "dock",
|
|
@@ -1445,12 +1640,12 @@ function AgentRail({
|
|
|
1445
1640
|
onSubmit
|
|
1446
1641
|
}
|
|
1447
1642
|
) }),
|
|
1448
|
-
/* @__PURE__ */ (0,
|
|
1449
|
-
/* @__PURE__ */ (0,
|
|
1450
|
-
/* @__PURE__ */ (0,
|
|
1643
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "agent-rail__footer", children: [
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "agent-rail__footer-disclaimer", children: "AI can make mistakes. Check important info." }),
|
|
1645
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "agent-rail__footer-note", children: poweredByLabel })
|
|
1451
1646
|
] })
|
|
1452
|
-
] }) : /* @__PURE__ */ (0,
|
|
1453
|
-
/* @__PURE__ */ (0,
|
|
1647
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "agent-rail__composer-wrap", children: [
|
|
1648
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1454
1649
|
Composer,
|
|
1455
1650
|
{
|
|
1456
1651
|
disabled: isBusy,
|
|
@@ -1458,9 +1653,9 @@ function AgentRail({
|
|
|
1458
1653
|
onSubmit
|
|
1459
1654
|
}
|
|
1460
1655
|
),
|
|
1461
|
-
/* @__PURE__ */ (0,
|
|
1462
|
-
/* @__PURE__ */ (0,
|
|
1463
|
-
/* @__PURE__ */ (0,
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "agent-rail__footer", children: [
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "agent-rail__footer-disclaimer", children: "AI can make mistakes. Check important info." }),
|
|
1658
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "agent-rail__footer-note", children: poweredByLabel })
|
|
1464
1659
|
] })
|
|
1465
1660
|
] })
|
|
1466
1661
|
]
|
|
@@ -1469,22 +1664,67 @@ function AgentRail({
|
|
|
1469
1664
|
}
|
|
1470
1665
|
|
|
1471
1666
|
// src/react/components/AssistEdgeTab/AssistEdgeTab.tsx
|
|
1472
|
-
var
|
|
1667
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1473
1668
|
function SparklesIcon() {
|
|
1474
|
-
return /* @__PURE__ */ (0,
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1670
|
+
"svg",
|
|
1671
|
+
{
|
|
1672
|
+
className: "assist-edge-tab__sparkles",
|
|
1673
|
+
viewBox: "0 0 18 16",
|
|
1674
|
+
fill: "none",
|
|
1675
|
+
"aria-hidden": "true",
|
|
1676
|
+
children: [
|
|
1677
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1678
|
+
"path",
|
|
1679
|
+
{
|
|
1680
|
+
d: "M8 1.2l.95 2.7 2.85.05-2.25 1.75.8 2.75L8 6.7 5.65 8.45l.8-2.75L4.2 3.95l2.85-.05L8 1.2z",
|
|
1681
|
+
fill: "currentColor"
|
|
1682
|
+
}
|
|
1683
|
+
),
|
|
1684
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1685
|
+
"path",
|
|
1686
|
+
{
|
|
1687
|
+
d: "M14.2 6.4l.55 1.55 1.65.03-1.3 1 .46 1.58-1.36-1-1.36 1 .46-1.58-1.3-1 1.65-.03.55-1.55z",
|
|
1688
|
+
fill: "currentColor"
|
|
1689
|
+
}
|
|
1690
|
+
),
|
|
1691
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1692
|
+
"path",
|
|
1693
|
+
{
|
|
1694
|
+
d: "M3.1 9.1l.4 1.15 1.22.02-.96.74.34 1.17-1-.74-1 .74.34-1.17-.96-.74 1.22-.02.4-1.15z",
|
|
1695
|
+
fill: "currentColor"
|
|
1696
|
+
}
|
|
1697
|
+
)
|
|
1698
|
+
]
|
|
1699
|
+
}
|
|
1700
|
+
);
|
|
1479
1701
|
}
|
|
1480
1702
|
function ChevronLeftIcon() {
|
|
1481
|
-
return /* @__PURE__ */ (0,
|
|
1703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1704
|
+
"path",
|
|
1705
|
+
{
|
|
1706
|
+
d: "M10 4L6 8l4 4",
|
|
1707
|
+
stroke: "currentColor",
|
|
1708
|
+
strokeWidth: "1.6",
|
|
1709
|
+
strokeLinecap: "round",
|
|
1710
|
+
strokeLinejoin: "round"
|
|
1711
|
+
}
|
|
1712
|
+
) });
|
|
1482
1713
|
}
|
|
1483
1714
|
function ChevronDownIcon() {
|
|
1484
|
-
return /* @__PURE__ */ (0,
|
|
1715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1716
|
+
"path",
|
|
1717
|
+
{
|
|
1718
|
+
d: "M4 6l4 4 4-4",
|
|
1719
|
+
stroke: "currentColor",
|
|
1720
|
+
strokeWidth: "1.6",
|
|
1721
|
+
strokeLinecap: "round",
|
|
1722
|
+
strokeLinejoin: "round"
|
|
1723
|
+
}
|
|
1724
|
+
) });
|
|
1485
1725
|
}
|
|
1486
1726
|
function DragDots() {
|
|
1487
|
-
return /* @__PURE__ */ (0,
|
|
1727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "assist-edge-tab__dots", "aria-hidden": "true", children: Array.from({ length: 12 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", {}, index)) });
|
|
1488
1728
|
}
|
|
1489
1729
|
var VARIANT_COPY = {
|
|
1490
1730
|
outline: { label: "Assist", aria: "Open Assist" },
|
|
@@ -1497,38 +1737,71 @@ function AssistEdgeTab({
|
|
|
1497
1737
|
along,
|
|
1498
1738
|
inset,
|
|
1499
1739
|
visible,
|
|
1740
|
+
label,
|
|
1741
|
+
logoUrl,
|
|
1742
|
+
brandColor,
|
|
1743
|
+
fontFamily,
|
|
1500
1744
|
onOpen
|
|
1501
1745
|
}) {
|
|
1502
1746
|
const copy = VARIANT_COPY[variant];
|
|
1747
|
+
const visibleLabel = label?.trim() || copy.label;
|
|
1503
1748
|
const style = {
|
|
1504
1749
|
"--tab-along": `${along}%`,
|
|
1505
|
-
"--tab-inset": `${inset}px
|
|
1750
|
+
"--tab-inset": `${inset}px`,
|
|
1751
|
+
...brandColor ? { "--as-brand": brandColor } : {},
|
|
1752
|
+
...fontFamily ? { "--as-font-display": fontFamily } : {}
|
|
1506
1753
|
};
|
|
1507
|
-
return /* @__PURE__ */ (0,
|
|
1754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1508
1755
|
"button",
|
|
1509
1756
|
{
|
|
1510
1757
|
type: "button",
|
|
1511
1758
|
className: `assist-edge-tab assist-edge-tab--${variant} assist-edge-tab--${side}${visible ? " is-visible" : ""}`,
|
|
1512
1759
|
style,
|
|
1513
|
-
"aria-label":
|
|
1760
|
+
"aria-label": `Open ${visibleLabel}`,
|
|
1514
1761
|
"aria-hidden": !visible,
|
|
1515
1762
|
tabIndex: visible ? 0 : -1,
|
|
1516
1763
|
onClick: onOpen,
|
|
1517
1764
|
children: [
|
|
1518
|
-
variant === "outline" ? /* @__PURE__ */ (0,
|
|
1519
|
-
/* @__PURE__ */ (0,
|
|
1520
|
-
|
|
1521
|
-
|
|
1765
|
+
variant === "outline" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1766
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
|
|
1767
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SparklesIcon, {}),
|
|
1768
|
+
logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1769
|
+
"img",
|
|
1770
|
+
{
|
|
1771
|
+
className: "assist-edge-tab__logo",
|
|
1772
|
+
src: logoUrl,
|
|
1773
|
+
alt: "",
|
|
1774
|
+
onError: (event) => {
|
|
1775
|
+
event.currentTarget.hidden = true;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
) : null
|
|
1779
|
+
] }),
|
|
1780
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "assist-edge-tab__label", children: visibleLabel }),
|
|
1781
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronDownIcon, {})
|
|
1522
1782
|
] }) : null,
|
|
1523
|
-
variant === "ask" ? /* @__PURE__ */ (0,
|
|
1524
|
-
/* @__PURE__ */ (0,
|
|
1525
|
-
/* @__PURE__ */ (0,
|
|
1526
|
-
/* @__PURE__ */ (0,
|
|
1783
|
+
variant === "ask" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1784
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronLeftIcon, {}),
|
|
1785
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "assist-edge-tab__label", children: visibleLabel }),
|
|
1786
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DragDots, {})
|
|
1527
1787
|
] }) : null,
|
|
1528
|
-
variant === "fill" ? /* @__PURE__ */ (0,
|
|
1529
|
-
/* @__PURE__ */ (0,
|
|
1530
|
-
|
|
1531
|
-
|
|
1788
|
+
variant === "fill" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1789
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
|
|
1790
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SparklesIcon, {}),
|
|
1791
|
+
logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1792
|
+
"img",
|
|
1793
|
+
{
|
|
1794
|
+
className: "assist-edge-tab__logo",
|
|
1795
|
+
src: logoUrl,
|
|
1796
|
+
alt: "",
|
|
1797
|
+
onError: (event) => {
|
|
1798
|
+
event.currentTarget.hidden = true;
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
) : null
|
|
1802
|
+
] }),
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "assist-edge-tab__label", children: visibleLabel }),
|
|
1804
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronLeftIcon, {})
|
|
1532
1805
|
] }) : null
|
|
1533
1806
|
]
|
|
1534
1807
|
}
|
|
@@ -1536,7 +1809,7 @@ function AssistEdgeTab({
|
|
|
1536
1809
|
}
|
|
1537
1810
|
|
|
1538
1811
|
// src/react/components/AgentWidget/AgentWidget.tsx
|
|
1539
|
-
var
|
|
1812
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1540
1813
|
function AgentWidget({
|
|
1541
1814
|
indexId,
|
|
1542
1815
|
customerId,
|
|
@@ -1546,7 +1819,8 @@ function AgentWidget({
|
|
|
1546
1819
|
placement: placementInput,
|
|
1547
1820
|
defaultCollapsed = true,
|
|
1548
1821
|
pageShift = true,
|
|
1549
|
-
registerPanelController = false
|
|
1822
|
+
registerPanelController = false,
|
|
1823
|
+
branding
|
|
1550
1824
|
}) {
|
|
1551
1825
|
const isMobile = useIsMobile();
|
|
1552
1826
|
const placement = normalizeAgentPlacement(placementInput);
|
|
@@ -1568,8 +1842,27 @@ function AgentWidget({
|
|
|
1568
1842
|
getUnpublishedPreviewGrant,
|
|
1569
1843
|
indexId,
|
|
1570
1844
|
version,
|
|
1571
|
-
runtimeOrigin
|
|
1845
|
+
runtimeOrigin,
|
|
1846
|
+
greeting: branding?.greeting
|
|
1572
1847
|
});
|
|
1848
|
+
const agentName = branding?.agentName ?? "Webless Guide";
|
|
1849
|
+
const theme = {
|
|
1850
|
+
...branding?.fontFamily ? { fontBody: branding.fontFamily, fontDisplay: branding.fontFamily } : {},
|
|
1851
|
+
...branding?.colors?.primary ? {
|
|
1852
|
+
brand: branding.colors.primary,
|
|
1853
|
+
visitorBubble: branding.colors.primary
|
|
1854
|
+
} : {},
|
|
1855
|
+
...branding?.colors?.primarySoft ? { brandSoft: branding.colors.primarySoft } : {},
|
|
1856
|
+
...branding?.colors?.primaryForeground ? { visitorText: branding.colors.primaryForeground } : {},
|
|
1857
|
+
...branding?.colors?.surface ? { surface: branding.colors.surface } : {},
|
|
1858
|
+
...branding?.colors?.surfaceMuted ? { surfaceMuted: branding.colors.surfaceMuted } : {},
|
|
1859
|
+
...branding?.colors?.text ? { text: branding.colors.text } : {},
|
|
1860
|
+
...branding?.colors?.textMuted ? {
|
|
1861
|
+
textMuted: branding.colors.textMuted,
|
|
1862
|
+
textSubtle: branding.colors.textMuted
|
|
1863
|
+
} : {},
|
|
1864
|
+
...branding?.colors?.border ? { border: branding.colors.border } : {}
|
|
1865
|
+
};
|
|
1573
1866
|
const idle = state.phase === "idle" && !hasVisitorMessages(state.messages);
|
|
1574
1867
|
(0, import_react6.useEffect)(() => {
|
|
1575
1868
|
if (!registerPanelController) return;
|
|
@@ -1586,48 +1879,56 @@ function AgentWidget({
|
|
|
1586
1879
|
if (isMobile) setRailCollapsed(false);
|
|
1587
1880
|
await submit(message);
|
|
1588
1881
|
}
|
|
1589
|
-
return /* @__PURE__ */ (0,
|
|
1590
|
-
/* @__PURE__ */ (0,
|
|
1882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "webless-agent-root", children: [
|
|
1883
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1591
1884
|
"div",
|
|
1592
1885
|
{
|
|
1593
1886
|
className: `webless-agent-root__shell${railCollapsed ? " webless-agent-root__shell--collapsed" : ""}${railExpanded ? " webless-agent-root__shell--expanded" : ""}`,
|
|
1594
|
-
children:
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1887
|
+
children: [
|
|
1888
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1889
|
+
"div",
|
|
1890
|
+
{
|
|
1891
|
+
ref: railSlotRef,
|
|
1892
|
+
className: "webless-agent-root__rail-slot",
|
|
1893
|
+
inert: railCollapsed || void 0,
|
|
1894
|
+
"aria-hidden": railCollapsed,
|
|
1895
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1896
|
+
AgentRail,
|
|
1897
|
+
{
|
|
1898
|
+
theme,
|
|
1899
|
+
brandLabel: agentName,
|
|
1900
|
+
brandLogoUrl: branding?.logoUrl,
|
|
1901
|
+
composerPlaceholder: branding?.composerPlaceholder ?? `Ask ${agentName}\u2026`,
|
|
1902
|
+
poweredByLabel: branding?.poweredByLabel ?? "Powered by Webless",
|
|
1903
|
+
state: idle ? {
|
|
1904
|
+
...state,
|
|
1905
|
+
followUps: createIdleSuggestions()
|
|
1906
|
+
} : state,
|
|
1907
|
+
mobileFullscreen: isMobile && !railCollapsed,
|
|
1908
|
+
expanded: railExpanded,
|
|
1909
|
+
onCollapse: !isMobile ? () => setRailCollapsed(true) : void 0,
|
|
1910
|
+
onClose: isMobile ? () => setRailCollapsed(true) : void 0,
|
|
1911
|
+
onExpandToggle: !isMobile ? () => setRailExpanded((current) => !current) : void 0,
|
|
1912
|
+
onSubmit: handleSubmit,
|
|
1913
|
+
onFollowUpSelect: (label) => void handleSubmit(label)
|
|
1914
|
+
}
|
|
1915
|
+
)
|
|
1916
|
+
}
|
|
1917
|
+
),
|
|
1918
|
+
!isMobile && railExpanded && !railCollapsed ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1919
|
+
"button",
|
|
1920
|
+
{
|
|
1921
|
+
type: "button",
|
|
1922
|
+
className: "webless-agent-root__backdrop",
|
|
1923
|
+
tabIndex: -1,
|
|
1924
|
+
"aria-label": "Close expanded assist",
|
|
1925
|
+
onClick: () => setRailExpanded(false)
|
|
1926
|
+
}
|
|
1927
|
+
) : null
|
|
1928
|
+
]
|
|
1619
1929
|
}
|
|
1620
1930
|
),
|
|
1621
|
-
|
|
1622
|
-
"button",
|
|
1623
|
-
{
|
|
1624
|
-
type: "button",
|
|
1625
|
-
className: "webless-agent-root__backdrop",
|
|
1626
|
-
"aria-label": "Close expanded assist",
|
|
1627
|
-
onClick: () => setRailExpanded(false)
|
|
1628
|
-
}
|
|
1629
|
-
) : null,
|
|
1630
|
-
railCollapsed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1931
|
+
railCollapsed ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1631
1932
|
AssistEdgeTab,
|
|
1632
1933
|
{
|
|
1633
1934
|
variant: placement.variant,
|
|
@@ -1635,6 +1936,10 @@ function AgentWidget({
|
|
|
1635
1936
|
along: placement.along,
|
|
1636
1937
|
inset: placement.inset,
|
|
1637
1938
|
visible: true,
|
|
1939
|
+
label: agentName,
|
|
1940
|
+
logoUrl: branding?.logoUrl,
|
|
1941
|
+
brandColor: branding?.colors?.primary,
|
|
1942
|
+
fontFamily: branding?.fontFamily,
|
|
1638
1943
|
onOpen: () => setRailCollapsed(false)
|
|
1639
1944
|
}
|
|
1640
1945
|
) : null
|
|
@@ -1642,9 +1947,11 @@ function AgentWidget({
|
|
|
1642
1947
|
}
|
|
1643
1948
|
|
|
1644
1949
|
// src/embed/AgentWidget.tsx
|
|
1645
|
-
var
|
|
1646
|
-
function AgentWidget2({
|
|
1647
|
-
|
|
1950
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1951
|
+
function AgentWidget2({
|
|
1952
|
+
manifest
|
|
1953
|
+
}) {
|
|
1954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1648
1955
|
AgentWidget,
|
|
1649
1956
|
{
|
|
1650
1957
|
indexId: manifest.indexId,
|
|
@@ -1653,6 +1960,7 @@ function AgentWidget2({ manifest }) {
|
|
|
1653
1960
|
runtimeOrigin: manifest.runtimeOrigin,
|
|
1654
1961
|
placement: manifest.placement,
|
|
1655
1962
|
pageShift: manifest.pageShift,
|
|
1963
|
+
branding: manifest.branding,
|
|
1656
1964
|
defaultCollapsed: true,
|
|
1657
1965
|
registerPanelController: true
|
|
1658
1966
|
}
|
|
@@ -1678,6 +1986,7 @@ function normalizeAgentTagManifest(manifest) {
|
|
|
1678
1986
|
version,
|
|
1679
1987
|
runtimeOrigin: manifest.runtimeOrigin?.trim() || DEFAULT_RUNTIME_ORIGIN
|
|
1680
1988
|
});
|
|
1989
|
+
const branding = normalizeAgentBranding(manifest.branding);
|
|
1681
1990
|
return {
|
|
1682
1991
|
customerId,
|
|
1683
1992
|
indexId,
|
|
@@ -1688,12 +1997,36 @@ function normalizeAgentTagManifest(manifest) {
|
|
|
1688
1997
|
strategy: manifest.mount?.strategy ?? "body"
|
|
1689
1998
|
},
|
|
1690
1999
|
placement: normalizeAgentPlacement(manifest.placement),
|
|
1691
|
-
pageShift: manifest.pageShift ?? true
|
|
2000
|
+
pageShift: manifest.pageShift ?? true,
|
|
2001
|
+
...branding ? { branding } : {}
|
|
1692
2002
|
};
|
|
1693
2003
|
}
|
|
2004
|
+
function normalizeOptionalValue(value) {
|
|
2005
|
+
const normalized = value?.trim();
|
|
2006
|
+
return normalized || void 0;
|
|
2007
|
+
}
|
|
2008
|
+
function normalizeAgentBranding(branding) {
|
|
2009
|
+
if (!branding) return void 0;
|
|
2010
|
+
const colors = branding.colors ? Object.fromEntries(
|
|
2011
|
+
Object.entries(branding.colors).flatMap(([key, value]) => {
|
|
2012
|
+
const normalized2 = normalizeOptionalValue(value);
|
|
2013
|
+
return normalized2 ? [[key, normalized2]] : [];
|
|
2014
|
+
})
|
|
2015
|
+
) : void 0;
|
|
2016
|
+
const normalized = {
|
|
2017
|
+
agentName: normalizeOptionalValue(branding.agentName),
|
|
2018
|
+
logoUrl: normalizeOptionalValue(branding.logoUrl),
|
|
2019
|
+
greeting: normalizeOptionalValue(branding.greeting),
|
|
2020
|
+
composerPlaceholder: normalizeOptionalValue(branding.composerPlaceholder),
|
|
2021
|
+
poweredByLabel: normalizeOptionalValue(branding.poweredByLabel),
|
|
2022
|
+
fontFamily: normalizeOptionalValue(branding.fontFamily),
|
|
2023
|
+
colors: colors && Object.keys(colors).length > 0 ? colors : void 0
|
|
2024
|
+
};
|
|
2025
|
+
return Object.values(normalized).some((value) => value !== void 0) ? normalized : void 0;
|
|
2026
|
+
}
|
|
1694
2027
|
|
|
1695
2028
|
// src/embed/mount.tsx
|
|
1696
|
-
var
|
|
2029
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1697
2030
|
var mountedHandles = /* @__PURE__ */ new Map();
|
|
1698
2031
|
var latestCustomerId = null;
|
|
1699
2032
|
function resolveMountHost(manifest, script) {
|
|
@@ -1723,7 +2056,7 @@ function mountAgent(input) {
|
|
|
1723
2056
|
const host = createHost(manifest.customerId);
|
|
1724
2057
|
mountTarget.append(host);
|
|
1725
2058
|
const root = (0, import_client5.createRoot)(host);
|
|
1726
|
-
root.render(/* @__PURE__ */ (0,
|
|
2059
|
+
root.render(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AgentWidget2, { manifest }));
|
|
1727
2060
|
const handle = {
|
|
1728
2061
|
customerId: manifest.customerId,
|
|
1729
2062
|
manifest,
|