@webless/agent 0.7.5 → 0.8.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/README.md +19 -0
- package/dist/{chunk-CD6TKXGT.js → chunk-JZPXXG76.js} +47 -39
- package/dist/chunk-JZPXXG76.js.map +1 -0
- package/dist/embed.cjs +43 -38
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.css +56 -0
- package/dist/embed.css.map +1 -1
- package/dist/embed.js +1 -1
- package/dist/react.cjs +103 -38
- package/dist/react.cjs.map +1 -1
- package/dist/react.css +56 -0
- package/dist/react.css.map +1 -1
- package/dist/react.d.cts +13 -1
- package/dist/react.d.ts +13 -1
- package/dist/react.js +64 -2
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-CD6TKXGT.js.map +0 -1
package/dist/react.d.cts
CHANGED
|
@@ -135,4 +135,16 @@ declare function buildAgentAnswerFeedbackEvent(input: {
|
|
|
135
135
|
*/
|
|
136
136
|
declare function sendAgentAnswerFeedback(eventUrl: string, event: Record<string, unknown>): void;
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
type AgentTranscriptProps = {
|
|
139
|
+
messages: readonly ConversationMessage[];
|
|
140
|
+
theme?: Partial<AgentRailTheme>;
|
|
141
|
+
colorScheme?: AgentColorScheme;
|
|
142
|
+
agentLabel?: string;
|
|
143
|
+
visitorLabel?: string;
|
|
144
|
+
label?: string;
|
|
145
|
+
formatTimestamp?: (createdAt: number) => string;
|
|
146
|
+
};
|
|
147
|
+
/** Renders a stored snapshot; never creates a session or exposes chat actions. */
|
|
148
|
+
declare function AgentTranscript({ messages, theme, colorScheme, agentLabel, visitorLabel, label, formatTimestamp, }: AgentTranscriptProps): react.JSX.Element;
|
|
149
|
+
|
|
150
|
+
export { AGENT_ANSWER_FEEDBACK_EVENT_TYPE, AgentColorScheme, AgentInputResponse, AgentMessageFeedback, AgentPlacementConfig, AgentRail, AgentRailPhase, type AgentRailProps, AgentRailState, AgentRailTheme, AgentToolUiSurface, AgentTranscript, type AgentTranscriptProps, AgentWidget, type AgentWidgetProps, ConversationMessage, FollowUpSuggestion, MessageActions, ToolStep, type UseAgentChatOptions, VisitorToolResultRegistry, buildAgentAnswerFeedbackEvent, createIdleSuggestions, findPrecedingVisitorText, hasVisitorMessages, isAgentBusy, sendAgentAnswerFeedback, useAgentChat };
|
package/dist/react.d.ts
CHANGED
|
@@ -135,4 +135,16 @@ declare function buildAgentAnswerFeedbackEvent(input: {
|
|
|
135
135
|
*/
|
|
136
136
|
declare function sendAgentAnswerFeedback(eventUrl: string, event: Record<string, unknown>): void;
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
type AgentTranscriptProps = {
|
|
139
|
+
messages: readonly ConversationMessage[];
|
|
140
|
+
theme?: Partial<AgentRailTheme>;
|
|
141
|
+
colorScheme?: AgentColorScheme;
|
|
142
|
+
agentLabel?: string;
|
|
143
|
+
visitorLabel?: string;
|
|
144
|
+
label?: string;
|
|
145
|
+
formatTimestamp?: (createdAt: number) => string;
|
|
146
|
+
};
|
|
147
|
+
/** Renders a stored snapshot; never creates a session or exposes chat actions. */
|
|
148
|
+
declare function AgentTranscript({ messages, theme, colorScheme, agentLabel, visitorLabel, label, formatTimestamp, }: AgentTranscriptProps): react.JSX.Element;
|
|
149
|
+
|
|
150
|
+
export { AGENT_ANSWER_FEEDBACK_EVENT_TYPE, AgentColorScheme, AgentInputResponse, AgentMessageFeedback, AgentPlacementConfig, AgentRail, AgentRailPhase, type AgentRailProps, AgentRailState, AgentRailTheme, AgentToolUiSurface, AgentTranscript, type AgentTranscriptProps, AgentWidget, type AgentWidgetProps, ConversationMessage, FollowUpSuggestion, MessageActions, ToolStep, type UseAgentChatOptions, VisitorToolResultRegistry, buildAgentAnswerFeedbackEvent, createIdleSuggestions, findPrecedingVisitorText, hasVisitorMessages, isAgentBusy, sendAgentAnswerFeedback, useAgentChat };
|
package/dist/react.js
CHANGED
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
AssistEdgeTab,
|
|
9
9
|
DEFAULT_AGENT_PLACEMENT,
|
|
10
10
|
MessageActions,
|
|
11
|
+
MessageBubble,
|
|
12
|
+
agentThemeStyle,
|
|
11
13
|
buildAgentAnswerFeedbackEvent,
|
|
12
14
|
builtInVisitorToolResultRegistry,
|
|
13
15
|
createIdleSuggestions,
|
|
@@ -20,13 +22,73 @@ import {
|
|
|
20
22
|
normalizeAgentPlacement,
|
|
21
23
|
presentVisitorToolResult,
|
|
22
24
|
sendAgentAnswerFeedback,
|
|
23
|
-
useAgentChat
|
|
24
|
-
|
|
25
|
+
useAgentChat,
|
|
26
|
+
useAgentColorScheme
|
|
27
|
+
} from "./chunk-JZPXXG76.js";
|
|
28
|
+
|
|
29
|
+
// src/react/components/AgentTranscript/AgentTranscript.tsx
|
|
30
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
31
|
+
var timestampFormat = new Intl.DateTimeFormat("en-US", {
|
|
32
|
+
month: "short",
|
|
33
|
+
day: "numeric",
|
|
34
|
+
hour: "numeric",
|
|
35
|
+
minute: "2-digit",
|
|
36
|
+
timeZone: "UTC"
|
|
37
|
+
});
|
|
38
|
+
function defaultTimestamp(createdAt) {
|
|
39
|
+
return `${timestampFormat.format(createdAt)} UTC`;
|
|
40
|
+
}
|
|
41
|
+
function AgentTranscript({
|
|
42
|
+
messages,
|
|
43
|
+
theme,
|
|
44
|
+
colorScheme,
|
|
45
|
+
agentLabel = "Agent",
|
|
46
|
+
visitorLabel = "Visitor",
|
|
47
|
+
label = "Conversation transcript",
|
|
48
|
+
formatTimestamp = defaultTimestamp
|
|
49
|
+
}) {
|
|
50
|
+
const scheme = useAgentColorScheme(colorScheme);
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
"ol",
|
|
53
|
+
{
|
|
54
|
+
className: "webless-agent-root agent-transcript not-typeset",
|
|
55
|
+
"data-not-typeset": "",
|
|
56
|
+
"data-color-scheme": scheme,
|
|
57
|
+
"aria-label": label,
|
|
58
|
+
style: agentThemeStyle(theme, scheme),
|
|
59
|
+
children: messages.map((message) => {
|
|
60
|
+
const date = new Date(message.createdAt);
|
|
61
|
+
const validTimestamp = Number.isFinite(date.getTime());
|
|
62
|
+
return /* @__PURE__ */ jsxs(
|
|
63
|
+
"li",
|
|
64
|
+
{
|
|
65
|
+
className: `agent-transcript__message agent-transcript__message--${message.role}`,
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsxs("div", { className: "agent-transcript__meta", children: [
|
|
68
|
+
/* @__PURE__ */ jsx("span", { children: message.role === "visitor" ? visitorLabel : agentLabel }),
|
|
69
|
+
validTimestamp ? /* @__PURE__ */ jsx("time", { dateTime: date.toISOString(), children: formatTimestamp(message.createdAt) }) : null
|
|
70
|
+
] }),
|
|
71
|
+
/* @__PURE__ */ jsx(
|
|
72
|
+
MessageBubble,
|
|
73
|
+
{
|
|
74
|
+
message: message.role === "agent" ? { ...message, streaming: false } : message,
|
|
75
|
+
bookingDisabled: true
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
message.id
|
|
81
|
+
);
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
25
86
|
export {
|
|
26
87
|
AGENT_ANSWER_FEEDBACK_EVENT_TYPE,
|
|
27
88
|
AGENT_STRUCTURED_TOOL_INPUT_HEADER,
|
|
28
89
|
AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION,
|
|
29
90
|
AgentRail,
|
|
91
|
+
AgentTranscript,
|
|
30
92
|
AgentWidget,
|
|
31
93
|
AssistEdgeTab,
|
|
32
94
|
DEFAULT_AGENT_PLACEMENT,
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/react/components/AgentTranscript/AgentTranscript.tsx"],"sourcesContent":["import type {\n ConversationMessage,\n AgentColorScheme,\n AgentRailTheme,\n} from \"../../types/conversation\";\nimport { useAgentColorScheme } from \"../../hooks/useAgentColorScheme\";\nimport { agentThemeStyle } from \"../../lib/agent-theme\";\nimport { MessageBubble } from \"../MessageBubble/MessageBubble\";\nimport \"./AgentTranscript.css\";\n\nexport type AgentTranscriptProps = {\n messages: readonly ConversationMessage[];\n theme?: Partial<AgentRailTheme>;\n colorScheme?: AgentColorScheme;\n agentLabel?: string;\n visitorLabel?: string;\n label?: string;\n formatTimestamp?: (createdAt: number) => string;\n};\n\nconst timestampFormat = new Intl.DateTimeFormat(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n timeZone: \"UTC\",\n});\nfunction defaultTimestamp(createdAt: number) {\n return `${timestampFormat.format(createdAt)} UTC`;\n}\n\n/** Renders a stored snapshot; never creates a session or exposes chat actions. */\nexport function AgentTranscript({\n messages,\n theme,\n colorScheme,\n agentLabel = \"Agent\",\n visitorLabel = \"Visitor\",\n label = \"Conversation transcript\",\n formatTimestamp = defaultTimestamp,\n}: AgentTranscriptProps) {\n const scheme = useAgentColorScheme(colorScheme);\n return (\n <ol\n className=\"webless-agent-root agent-transcript not-typeset\"\n data-not-typeset=\"\"\n data-color-scheme={scheme}\n aria-label={label}\n style={agentThemeStyle(theme, scheme)}\n >\n {messages.map((message) => {\n const date = new Date(message.createdAt);\n const validTimestamp = Number.isFinite(date.getTime());\n return (\n <li\n key={message.id}\n className={`agent-transcript__message agent-transcript__message--${message.role}`}\n >\n <div className=\"agent-transcript__meta\">\n <span>\n {message.role === \"visitor\" ? visitorLabel : agentLabel}\n </span>\n {validTimestamp ? (\n <time dateTime={date.toISOString()}>\n {formatTimestamp(message.createdAt)}\n </time>\n ) : null}\n </div>\n <MessageBubble\n message={\n message.role === \"agent\"\n ? { ...message, streaming: false }\n : message\n }\n bookingDisabled\n />\n </li>\n );\n })}\n </ol>\n );\n}\n"],"mappings":";;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