@webless/agent 0.9.2 → 0.10.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 +1 -1
- package/dist/{chunk-3E632FNE.js → chunk-6OCODDRO.js} +308 -168
- package/dist/chunk-6OCODDRO.js.map +1 -0
- package/dist/embed.cjs +309 -168
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.css +382 -151
- package/dist/embed.css.map +1 -1
- package/dist/embed.d.cts +2 -2
- package/dist/embed.d.ts +2 -2
- package/dist/embed.js +2 -1
- package/dist/embed.js.map +1 -1
- package/dist/{panel-controller-D_XIQa1U.d.cts → panel-controller-rxR75tRa.d.cts} +5 -1
- package/dist/{panel-controller-D_XIQa1U.d.ts → panel-controller-rxR75tRa.d.ts} +5 -1
- package/dist/presentation.cjs.map +1 -1
- package/dist/presentation.js.map +1 -1
- package/dist/react.cjs +310 -168
- package/dist/react.cjs.map +1 -1
- package/dist/react.css +382 -151
- package/dist/react.css.map +1 -1
- package/dist/react.d.cts +5 -3
- package/dist/react.d.ts +5 -3
- package/dist/react.js +3 -1
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3E632FNE.js.map +0 -1
package/dist/react.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { e as AgentIndexVersion, l as AgentPlacementConfig, d as AgentColorScheme, c as AgentBrandingConfig, b as AgentAnalyticsConfig, Y as VisitorToolResultRegistry, i as AgentMessageFeedback, T as ToolStep, n as AgentRailState, o as AgentRailTheme, I as ConversationMessage, k as AgentPanelSubmitOptions, h as AgentInputResponse, D as AgentToolUiSurface, w as AgentToolResultJsonValue, K as FollowUpSuggestion, m as AgentRailPhase, V as VisitorBooking, R as ResolvedVisitorToolResultPresentation } from './panel-controller-
|
|
3
|
-
export { A as AGENT_STRUCTURED_TOOL_INPUT_HEADER, a as AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION, f as AgentInputOption, g as AgentInputRequest, p as AgentSearchReferences, q as AgentSearchSource, r as AgentStructuredToolInput, v as AgentToolResult, x as AgentToolUiAction, y as AgentToolUiField, z as AgentToolUiFieldKind, B as AgentToolUiOption, C as AgentToolUiStep, E as AssistEdgeTab, F as AssistTabSide, G as AssistTabVariant, H as Citation, J as DEFAULT_AGENT_PLACEMENT, L as JourneyContext, M as ToolStepState, O as VisitorBookingResultPresentation, P as VisitorSearchResultPresentation, Q as VisitorToolInputResultPresentation, S as VisitorToolResultLink, U as VisitorToolResultPresentation, W as VisitorToolResultPresenter, X as VisitorToolResultPresenterOutput, Z as builtInVisitorToolResultRegistry, _ as defaultAgentRailTheme, $ as defaultDarkAgentRailTheme, a0 as formatAgentStructuredToolInput, a1 as normalizeAgentPlacement, a3 as presentVisitorToolResult } from './panel-controller-
|
|
2
|
+
import { e as AgentIndexVersion, l as AgentPlacementConfig, d as AgentColorScheme, c as AgentBrandingConfig, b as AgentAnalyticsConfig, Y as VisitorToolResultRegistry, i as AgentMessageFeedback, T as ToolStep, n as AgentRailState, o as AgentRailTheme, I as ConversationMessage, k as AgentPanelSubmitOptions, h as AgentInputResponse, D as AgentToolUiSurface, w as AgentToolResultJsonValue, K as FollowUpSuggestion, m as AgentRailPhase, V as VisitorBooking, R as ResolvedVisitorToolResultPresentation } from './panel-controller-rxR75tRa.cjs';
|
|
3
|
+
export { A as AGENT_STRUCTURED_TOOL_INPUT_HEADER, a as AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION, f as AgentInputOption, g as AgentInputRequest, p as AgentSearchReferences, q as AgentSearchSource, r as AgentStructuredToolInput, v as AgentToolResult, x as AgentToolUiAction, y as AgentToolUiField, z as AgentToolUiFieldKind, B as AgentToolUiOption, C as AgentToolUiStep, E as AssistEdgeTab, F as AssistTabSide, G as AssistTabVariant, H as Citation, J as DEFAULT_AGENT_PLACEMENT, L as JourneyContext, M as ToolStepState, O as VisitorBookingResultPresentation, P as VisitorSearchResultPresentation, Q as VisitorToolInputResultPresentation, S as VisitorToolResultLink, U as VisitorToolResultPresentation, W as VisitorToolResultPresenter, X as VisitorToolResultPresenterOutput, Z as builtInVisitorToolResultRegistry, _ as defaultAgentRailTheme, $ as defaultDarkAgentRailTheme, a0 as formatAgentStructuredToolInput, a1 as normalizeAgentPlacement, a3 as presentVisitorToolResult } from './panel-controller-rxR75tRa.cjs';
|
|
4
4
|
|
|
5
5
|
type AgentWidgetProps = {
|
|
6
6
|
indexId: string;
|
|
@@ -80,6 +80,7 @@ type UseAgentChatOptions = {
|
|
|
80
80
|
type AgentChatSubmitOptions = {
|
|
81
81
|
preservePendingOffer?: boolean;
|
|
82
82
|
runtimeText?: string;
|
|
83
|
+
declinedComposerFormId?: string;
|
|
83
84
|
};
|
|
84
85
|
declare function useAgentChat({ customerId, getUnpublishedPreviewGrant, indexId, previewBuildId, version, runtimeOrigin, visitorSessionId, storageKeyPrefix, greeting, toolResultRegistry, }: UseAgentChatOptions): {
|
|
85
86
|
state: AgentRailState;
|
|
@@ -150,6 +151,7 @@ type AgentTranscriptProps = {
|
|
|
150
151
|
activities?: readonly AgentTranscriptActivity[];
|
|
151
152
|
theme?: Partial<AgentRailTheme>;
|
|
152
153
|
colorScheme?: AgentColorScheme;
|
|
154
|
+
linkBaseUrl?: string;
|
|
153
155
|
agentLabel?: string;
|
|
154
156
|
visitorLabel?: string;
|
|
155
157
|
label?: string;
|
|
@@ -158,6 +160,6 @@ type AgentTranscriptProps = {
|
|
|
158
160
|
formatTimestamp?: (createdAt: number) => string;
|
|
159
161
|
};
|
|
160
162
|
/** Renders a stored snapshot; never creates a session or exposes chat actions. */
|
|
161
|
-
declare function AgentTranscript({ messages, activities, theme, colorScheme, agentLabel, visitorLabel, label, formatTimestamp, showInitialTimestamp, }: AgentTranscriptProps): react.JSX.Element;
|
|
163
|
+
declare function AgentTranscript({ messages, activities, theme, colorScheme, linkBaseUrl, agentLabel, visitorLabel, label, formatTimestamp, showInitialTimestamp, }: AgentTranscriptProps): react.JSX.Element;
|
|
162
164
|
|
|
163
165
|
export { AGENT_ANSWER_FEEDBACK_EVENT_TYPE, AgentColorScheme, AgentInputResponse, AgentMessageFeedback, AgentPlacementConfig, AgentRail, AgentRailPhase, type AgentRailProps, AgentRailState, AgentRailTheme, AgentToolUiSurface, AgentTranscript, type AgentTranscriptActivity, type AgentTranscriptProps, AgentWidget, type AgentWidgetProps, ConversationMessage, FollowUpSuggestion, MessageActions, ResolvedVisitorToolResultPresentation, ToolStep, type UseAgentChatOptions, VisitorToolResultRegistry, buildAgentAnswerFeedbackEvent, createIdleSuggestions, findPrecedingVisitorText, hasVisitorMessages, isAgentBusy, sendAgentAnswerFeedback, useAgentChat };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { e as AgentIndexVersion, l as AgentPlacementConfig, d as AgentColorScheme, c as AgentBrandingConfig, b as AgentAnalyticsConfig, Y as VisitorToolResultRegistry, i as AgentMessageFeedback, T as ToolStep, n as AgentRailState, o as AgentRailTheme, I as ConversationMessage, k as AgentPanelSubmitOptions, h as AgentInputResponse, D as AgentToolUiSurface, w as AgentToolResultJsonValue, K as FollowUpSuggestion, m as AgentRailPhase, V as VisitorBooking, R as ResolvedVisitorToolResultPresentation } from './panel-controller-
|
|
3
|
-
export { A as AGENT_STRUCTURED_TOOL_INPUT_HEADER, a as AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION, f as AgentInputOption, g as AgentInputRequest, p as AgentSearchReferences, q as AgentSearchSource, r as AgentStructuredToolInput, v as AgentToolResult, x as AgentToolUiAction, y as AgentToolUiField, z as AgentToolUiFieldKind, B as AgentToolUiOption, C as AgentToolUiStep, E as AssistEdgeTab, F as AssistTabSide, G as AssistTabVariant, H as Citation, J as DEFAULT_AGENT_PLACEMENT, L as JourneyContext, M as ToolStepState, O as VisitorBookingResultPresentation, P as VisitorSearchResultPresentation, Q as VisitorToolInputResultPresentation, S as VisitorToolResultLink, U as VisitorToolResultPresentation, W as VisitorToolResultPresenter, X as VisitorToolResultPresenterOutput, Z as builtInVisitorToolResultRegistry, _ as defaultAgentRailTheme, $ as defaultDarkAgentRailTheme, a0 as formatAgentStructuredToolInput, a1 as normalizeAgentPlacement, a3 as presentVisitorToolResult } from './panel-controller-
|
|
2
|
+
import { e as AgentIndexVersion, l as AgentPlacementConfig, d as AgentColorScheme, c as AgentBrandingConfig, b as AgentAnalyticsConfig, Y as VisitorToolResultRegistry, i as AgentMessageFeedback, T as ToolStep, n as AgentRailState, o as AgentRailTheme, I as ConversationMessage, k as AgentPanelSubmitOptions, h as AgentInputResponse, D as AgentToolUiSurface, w as AgentToolResultJsonValue, K as FollowUpSuggestion, m as AgentRailPhase, V as VisitorBooking, R as ResolvedVisitorToolResultPresentation } from './panel-controller-rxR75tRa.js';
|
|
3
|
+
export { A as AGENT_STRUCTURED_TOOL_INPUT_HEADER, a as AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION, f as AgentInputOption, g as AgentInputRequest, p as AgentSearchReferences, q as AgentSearchSource, r as AgentStructuredToolInput, v as AgentToolResult, x as AgentToolUiAction, y as AgentToolUiField, z as AgentToolUiFieldKind, B as AgentToolUiOption, C as AgentToolUiStep, E as AssistEdgeTab, F as AssistTabSide, G as AssistTabVariant, H as Citation, J as DEFAULT_AGENT_PLACEMENT, L as JourneyContext, M as ToolStepState, O as VisitorBookingResultPresentation, P as VisitorSearchResultPresentation, Q as VisitorToolInputResultPresentation, S as VisitorToolResultLink, U as VisitorToolResultPresentation, W as VisitorToolResultPresenter, X as VisitorToolResultPresenterOutput, Z as builtInVisitorToolResultRegistry, _ as defaultAgentRailTheme, $ as defaultDarkAgentRailTheme, a0 as formatAgentStructuredToolInput, a1 as normalizeAgentPlacement, a3 as presentVisitorToolResult } from './panel-controller-rxR75tRa.js';
|
|
4
4
|
|
|
5
5
|
type AgentWidgetProps = {
|
|
6
6
|
indexId: string;
|
|
@@ -80,6 +80,7 @@ type UseAgentChatOptions = {
|
|
|
80
80
|
type AgentChatSubmitOptions = {
|
|
81
81
|
preservePendingOffer?: boolean;
|
|
82
82
|
runtimeText?: string;
|
|
83
|
+
declinedComposerFormId?: string;
|
|
83
84
|
};
|
|
84
85
|
declare function useAgentChat({ customerId, getUnpublishedPreviewGrant, indexId, previewBuildId, version, runtimeOrigin, visitorSessionId, storageKeyPrefix, greeting, toolResultRegistry, }: UseAgentChatOptions): {
|
|
85
86
|
state: AgentRailState;
|
|
@@ -150,6 +151,7 @@ type AgentTranscriptProps = {
|
|
|
150
151
|
activities?: readonly AgentTranscriptActivity[];
|
|
151
152
|
theme?: Partial<AgentRailTheme>;
|
|
152
153
|
colorScheme?: AgentColorScheme;
|
|
154
|
+
linkBaseUrl?: string;
|
|
153
155
|
agentLabel?: string;
|
|
154
156
|
visitorLabel?: string;
|
|
155
157
|
label?: string;
|
|
@@ -158,6 +160,6 @@ type AgentTranscriptProps = {
|
|
|
158
160
|
formatTimestamp?: (createdAt: number) => string;
|
|
159
161
|
};
|
|
160
162
|
/** Renders a stored snapshot; never creates a session or exposes chat actions. */
|
|
161
|
-
declare function AgentTranscript({ messages, activities, theme, colorScheme, agentLabel, visitorLabel, label, formatTimestamp, showInitialTimestamp, }: AgentTranscriptProps): react.JSX.Element;
|
|
163
|
+
declare function AgentTranscript({ messages, activities, theme, colorScheme, linkBaseUrl, agentLabel, visitorLabel, label, formatTimestamp, showInitialTimestamp, }: AgentTranscriptProps): react.JSX.Element;
|
|
162
164
|
|
|
163
165
|
export { AGENT_ANSWER_FEEDBACK_EVENT_TYPE, AgentColorScheme, AgentInputResponse, AgentMessageFeedback, AgentPlacementConfig, AgentRail, AgentRailPhase, type AgentRailProps, AgentRailState, AgentRailTheme, AgentToolUiSurface, AgentTranscript, type AgentTranscriptActivity, type AgentTranscriptProps, AgentWidget, type AgentWidgetProps, ConversationMessage, FollowUpSuggestion, MessageActions, ResolvedVisitorToolResultPresentation, ToolStep, type UseAgentChatOptions, VisitorToolResultRegistry, buildAgentAnswerFeedbackEvent, createIdleSuggestions, findPrecedingVisitorText, hasVisitorMessages, isAgentBusy, sendAgentAnswerFeedback, useAgentChat };
|
package/dist/react.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
sendAgentAnswerFeedback,
|
|
28
28
|
useAgentChat,
|
|
29
29
|
useAgentColorScheme
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-6OCODDRO.js";
|
|
31
31
|
|
|
32
32
|
// src/react/components/AgentTranscript/AgentTranscript.tsx
|
|
33
33
|
import { Fragment as Fragment2 } from "react";
|
|
@@ -123,6 +123,7 @@ function AgentTranscript({
|
|
|
123
123
|
activities = [],
|
|
124
124
|
theme,
|
|
125
125
|
colorScheme,
|
|
126
|
+
linkBaseUrl,
|
|
126
127
|
agentLabel = "Agent",
|
|
127
128
|
visitorLabel = "Visitor",
|
|
128
129
|
label = "Conversation transcript",
|
|
@@ -162,6 +163,7 @@ function AgentTranscript({
|
|
|
162
163
|
MessageBubble,
|
|
163
164
|
{
|
|
164
165
|
message: entry.role === "agent" ? { ...entry, streaming: false } : entry,
|
|
166
|
+
linkBaseUrl,
|
|
165
167
|
bookingReadOnly: true,
|
|
166
168
|
bookingDisabled: true
|
|
167
169
|
}
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/components/AgentTranscript/AgentTranscript.tsx","../src/react/components/AgentTranscript/TranscriptActivity.tsx","../src/react/components/AgentTranscript/group-activities.ts"],"sourcesContent":["import { Fragment } from \"react\";\nimport type {\n ConversationMessage,\n AgentColorScheme,\n AgentRailTheme,\n} from \"../../types/conversation\";\nimport { useAgentColorScheme } from \"../../hooks/useAgentColorScheme\";\nimport { agentThemeStyle } from \"../../lib/agent-theme\";\nimport { VisitorToolResultView } from \"../VisitorToolResultView/VisitorToolResultView\";\nimport { MessageBubble } from \"../MessageBubble/MessageBubble\";\nimport {\n TranscriptActivity,\n type AgentTranscriptActivity,\n} from \"./TranscriptActivity\";\nimport { groupTranscriptActivities } from \"./group-activities\";\nimport \"./AgentTranscript.css\";\n\nexport type { AgentTranscriptActivity } from \"./TranscriptActivity\";\n\nexport type AgentTranscriptProps = {\n messages: readonly ConversationMessage[];\n activities?: readonly AgentTranscriptActivity[];\n theme?: Partial<AgentRailTheme>;\n colorScheme?: AgentColorScheme;\n agentLabel?: string;\n visitorLabel?: string;\n label?: string;\n /** Hide the opening marker when the host already shows the conversation date. */\n showInitialTimestamp?: boolean;\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 activities = [],\n theme,\n colorScheme,\n agentLabel = \"Agent\",\n visitorLabel = \"Visitor\",\n label = \"Conversation transcript\",\n formatTimestamp = defaultTimestamp,\n showInitialTimestamp = true,\n}: AgentTranscriptProps) {\n const scheme = useAgentColorScheme(colorScheme);\n const entries = [\n ...messages.map((message) => ({ kind: \"message\" as const, ...message })),\n ...groupTranscriptActivities(activities).map((activity) => ({\n kind: \"activity\" as const,\n ...activity,\n })),\n ].sort((left, right) => left.createdAt - right.createdAt);\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 {entries.map((entry, index) => {\n const date = new Date(entry.createdAt);\n const previous = entries[index - 1];\n const validTimestamp = Number.isFinite(date.getTime());\n const showTimestamp =\n validTimestamp &&\n (previous\n ? entry.createdAt - previous.createdAt >= 5 * 60 * 1000 ||\n date.toISOString().slice(0, 10) !==\n new Date(previous.createdAt).toJSON()?.slice(0, 10)\n : showInitialTimestamp);\n return (\n <Fragment key={`${entry.kind}:${entry.id}`}>\n {showTimestamp ? (\n <li className=\"agent-transcript__time-marker\">\n <time dateTime={date.toISOString()}>\n {formatTimestamp(entry.createdAt)}\n </time>\n </li>\n ) : null}\n {entry.kind === \"activity\" ? (\n <TranscriptActivity activity={entry} />\n ) : (\n <li\n className={`agent-transcript__message agent-transcript__message--${entry.role}`}\n >\n <div className=\"agent-transcript__meta\">\n <span>\n {entry.role === \"visitor\" ? visitorLabel : agentLabel}\n </span>\n </div>\n <MessageBubble\n message={\n entry.role === \"agent\"\n ? { ...entry, streaming: false }\n : entry\n }\n bookingReadOnly\n bookingDisabled\n />\n </li>\n )}\n </Fragment>\n );\n })}\n </ol>\n );\n}\n","import type { ResolvedVisitorToolResultPresentation } from \"../../lib/tool-result\";\nimport { VisitorToolResultView } from \"../VisitorToolResultView/VisitorToolResultView\";\nimport { SearchReferences } from \"../SearchReferences/SearchReferences\";\nimport { BookingCard } from \"../BookingCard/BookingCard\";\n\nexport type AgentTranscriptActivity = {\n id: string;\n createdAt: number;\n callId: string;\n category: \"tool\" | \"specialist\";\n label: string;\n status: \"started\" | \"completed\" | \"failed\" | \"rejected\";\n result?: ResolvedVisitorToolResultPresentation;\n};\n\nconst statusLabels = {\n started: \"No result recorded\",\n completed: \"\",\n failed: \"Failed\",\n rejected: \"Rejected\",\n};\n\nfunction RecordedResult({\n result,\n}: {\n result: ResolvedVisitorToolResultPresentation;\n}) {\n if (result.kind === \"search\") return <SearchReferences results={[result]} />;\n if (result.kind === \"booking\") {\n const card = result.card;\n if (card.type === \"booking_offer\")\n return <BookingCard readOnly offer={card} />;\n if (card.type === \"booking_confirmed\")\n return (\n <p>Booking confirmed{card.startTime ? ` · ${card.startTime}` : \"\"}</p>\n );\n if (card.type === \"booking_canceled\") return <p>Booking canceled</p>;\n return <p>Information requested</p>;\n }\n return <VisitorToolResultView disabled result={result} />;\n}\n\nexport function TranscriptActivity({\n activity,\n}: {\n activity: AgentTranscriptActivity;\n}) {\n const result =\n activity.result?.kind === \"hidden\" ? undefined : activity.result;\n const heading = (\n <>\n <span>\n {activity.category === \"specialist\"\n ? `Specialist · ${activity.label}`\n : activity.label}\n </span>\n {activity.status !== \"completed\" ? (\n <span className=\"agent-transcript__activity-status\">\n {statusLabels[activity.status]}\n </span>\n ) : null}\n </>\n );\n return (\n <li className=\"agent-transcript__activity\" data-status={activity.status}>\n {result ? (\n <details>\n <summary className=\"agent-transcript__activity-heading\">\n {heading}\n </summary>\n <div className=\"agent-transcript__activity-result\">\n <RecordedResult result={result} />\n </div>\n </details>\n ) : (\n <div className=\"agent-transcript__activity-heading\">{heading}</div>\n )}\n </li>\n );\n}\n","import type { AgentTranscriptActivity } from \"./TranscriptActivity\";\n\n/** A paginated snapshot may deliver a call and its result on different pages. */\nexport function groupTranscriptActivities(\n activities: readonly AgentTranscriptActivity[],\n) {\n const calls = new Map<\n string,\n {\n latest: AgentTranscriptActivity;\n id: string;\n startedAt: number;\n label: string;\n }\n >();\n for (const activity of activities) {\n const key = `${activity.category}:${activity.callId}`;\n const previous = calls.get(key);\n if (!previous) {\n calls.set(key, {\n latest: activity,\n id: activity.id,\n startedAt: activity.createdAt,\n label: activity.label,\n });\n continue;\n }\n const previousHasResult = previous.latest.status !== \"started\";\n const nextHasResult = activity.status !== \"started\";\n const useNext =\n (nextHasResult && !previousHasResult) ||\n (nextHasResult === previousHasResult &&\n activity.createdAt >= previous.latest.createdAt);\n const latest = useNext ? activity : previous.latest;\n calls.set(key, {\n latest,\n id: previous.id,\n startedAt: Math.min(previous.startedAt, activity.createdAt),\n label:\n activity.createdAt < previous.startedAt\n ? activity.label\n : previous.label,\n });\n }\n return [...calls.values()].map(({ latest, id, startedAt, label }) => ({\n ...latest,\n id,\n label,\n createdAt: startedAt,\n }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAAA,iBAAgB;;;AC2Bc,SAuBnC,UAvBm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AAA,KAAC,UACE,gBAAM,SAAS,YAAY,eAAe,YAC7C,GACF;AAAA,gBACA,gBAAAA;AAAA,kBAAC;AAAA;AAAA,oBACC,SACE,MAAM,SAAS,UACX,EAAE,GAAG,OAAO,WAAW,MAAM,IAC7B;AAAA,oBAEN,iBAAe;AAAA,oBACf,iBAAe;AAAA;AAAA,gBACjB;AAAA;AAAA;AAAA,UACF;AAAA,aA5BW,GAAG,MAAM,IAAI,IAAI,MAAM,EAAE,EA8BxC;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;","names":["Fragment","jsx","jsxs","Fragment"]}
|
|
1
|
+
{"version":3,"sources":["../src/react/components/AgentTranscript/AgentTranscript.tsx","../src/react/components/AgentTranscript/TranscriptActivity.tsx","../src/react/components/AgentTranscript/group-activities.ts"],"sourcesContent":["import { Fragment } from \"react\";\nimport type {\n ConversationMessage,\n AgentColorScheme,\n AgentRailTheme,\n} from \"../../types/conversation\";\nimport { useAgentColorScheme } from \"../../hooks/useAgentColorScheme\";\nimport { agentThemeStyle } from \"../../lib/agent-theme\";\nimport { VisitorToolResultView } from \"../VisitorToolResultView/VisitorToolResultView\";\nimport { MessageBubble } from \"../MessageBubble/MessageBubble\";\nimport {\n TranscriptActivity,\n type AgentTranscriptActivity,\n} from \"./TranscriptActivity\";\nimport { groupTranscriptActivities } from \"./group-activities\";\nimport \"./AgentTranscript.css\";\n\nexport type { AgentTranscriptActivity } from \"./TranscriptActivity\";\n\nexport type AgentTranscriptProps = {\n messages: readonly ConversationMessage[];\n activities?: readonly AgentTranscriptActivity[];\n theme?: Partial<AgentRailTheme>;\n colorScheme?: AgentColorScheme;\n linkBaseUrl?: string;\n agentLabel?: string;\n visitorLabel?: string;\n label?: string;\n /** Hide the opening marker when the host already shows the conversation date. */\n showInitialTimestamp?: boolean;\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 activities = [],\n theme,\n colorScheme,\n linkBaseUrl,\n agentLabel = \"Agent\",\n visitorLabel = \"Visitor\",\n label = \"Conversation transcript\",\n formatTimestamp = defaultTimestamp,\n showInitialTimestamp = true,\n}: AgentTranscriptProps) {\n const scheme = useAgentColorScheme(colorScheme);\n const entries = [\n ...messages.map((message) => ({ kind: \"message\" as const, ...message })),\n ...groupTranscriptActivities(activities).map((activity) => ({\n kind: \"activity\" as const,\n ...activity,\n })),\n ].sort((left, right) => left.createdAt - right.createdAt);\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 {entries.map((entry, index) => {\n const date = new Date(entry.createdAt);\n const previous = entries[index - 1];\n const validTimestamp = Number.isFinite(date.getTime());\n const showTimestamp =\n validTimestamp &&\n (previous\n ? entry.createdAt - previous.createdAt >= 5 * 60 * 1000 ||\n date.toISOString().slice(0, 10) !==\n new Date(previous.createdAt).toJSON()?.slice(0, 10)\n : showInitialTimestamp);\n return (\n <Fragment key={`${entry.kind}:${entry.id}`}>\n {showTimestamp ? (\n <li className=\"agent-transcript__time-marker\">\n <time dateTime={date.toISOString()}>\n {formatTimestamp(entry.createdAt)}\n </time>\n </li>\n ) : null}\n {entry.kind === \"activity\" ? (\n <TranscriptActivity activity={entry} />\n ) : (\n <li\n className={`agent-transcript__message agent-transcript__message--${entry.role}`}\n >\n <div className=\"agent-transcript__meta\">\n <span>\n {entry.role === \"visitor\" ? visitorLabel : agentLabel}\n </span>\n </div>\n <MessageBubble\n message={\n entry.role === \"agent\"\n ? { ...entry, streaming: false }\n : entry\n }\n linkBaseUrl={linkBaseUrl}\n bookingReadOnly\n bookingDisabled\n />\n </li>\n )}\n </Fragment>\n );\n })}\n </ol>\n );\n}\n","import type { ResolvedVisitorToolResultPresentation } from \"../../lib/tool-result\";\nimport { VisitorToolResultView } from \"../VisitorToolResultView/VisitorToolResultView\";\nimport { SearchReferences } from \"../SearchReferences/SearchReferences\";\nimport { BookingCard } from \"../BookingCard/BookingCard\";\n\nexport type AgentTranscriptActivity = {\n id: string;\n createdAt: number;\n callId: string;\n category: \"tool\" | \"specialist\";\n label: string;\n status: \"started\" | \"completed\" | \"failed\" | \"rejected\";\n result?: ResolvedVisitorToolResultPresentation;\n};\n\nconst statusLabels = {\n started: \"No result recorded\",\n completed: \"\",\n failed: \"Failed\",\n rejected: \"Rejected\",\n};\n\nfunction RecordedResult({\n result,\n}: {\n result: ResolvedVisitorToolResultPresentation;\n}) {\n if (result.kind === \"search\") return <SearchReferences results={[result]} />;\n if (result.kind === \"booking\") {\n const card = result.card;\n if (card.type === \"booking_offer\")\n return <BookingCard readOnly offer={card} />;\n if (card.type === \"booking_confirmed\")\n return (\n <p>Booking confirmed{card.startTime ? ` · ${card.startTime}` : \"\"}</p>\n );\n if (card.type === \"booking_canceled\") return <p>Booking canceled</p>;\n return <p>Information requested</p>;\n }\n return <VisitorToolResultView disabled result={result} />;\n}\n\nexport function TranscriptActivity({\n activity,\n}: {\n activity: AgentTranscriptActivity;\n}) {\n const result =\n activity.result?.kind === \"hidden\" ? undefined : activity.result;\n const heading = (\n <>\n <span>\n {activity.category === \"specialist\"\n ? `Specialist · ${activity.label}`\n : activity.label}\n </span>\n {activity.status !== \"completed\" ? (\n <span className=\"agent-transcript__activity-status\">\n {statusLabels[activity.status]}\n </span>\n ) : null}\n </>\n );\n return (\n <li className=\"agent-transcript__activity\" data-status={activity.status}>\n {result ? (\n <details>\n <summary className=\"agent-transcript__activity-heading\">\n {heading}\n </summary>\n <div className=\"agent-transcript__activity-result\">\n <RecordedResult result={result} />\n </div>\n </details>\n ) : (\n <div className=\"agent-transcript__activity-heading\">{heading}</div>\n )}\n </li>\n );\n}\n","import type { AgentTranscriptActivity } from \"./TranscriptActivity\";\n\n/** A paginated snapshot may deliver a call and its result on different pages. */\nexport function groupTranscriptActivities(\n activities: readonly AgentTranscriptActivity[],\n) {\n const calls = new Map<\n string,\n {\n latest: AgentTranscriptActivity;\n id: string;\n startedAt: number;\n label: string;\n }\n >();\n for (const activity of activities) {\n const key = `${activity.category}:${activity.callId}`;\n const previous = calls.get(key);\n if (!previous) {\n calls.set(key, {\n latest: activity,\n id: activity.id,\n startedAt: activity.createdAt,\n label: activity.label,\n });\n continue;\n }\n const previousHasResult = previous.latest.status !== \"started\";\n const nextHasResult = activity.status !== \"started\";\n const useNext =\n (nextHasResult && !previousHasResult) ||\n (nextHasResult === previousHasResult &&\n activity.createdAt >= previous.latest.createdAt);\n const latest = useNext ? activity : previous.latest;\n calls.set(key, {\n latest,\n id: previous.id,\n startedAt: Math.min(previous.startedAt, activity.createdAt),\n label:\n activity.createdAt < previous.startedAt\n ? activity.label\n : previous.label,\n });\n }\n return [...calls.values()].map(({ latest, id, startedAt, label }) => ({\n ...latest,\n id,\n label,\n createdAt: startedAt,\n }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAAA,iBAAgB;;;AC2Bc,SAuBnC,UAvBmC,KAO/B,YAP+B;AAZvC,IAAM,eAAe;AAAA,EACnB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,UAAU;AACZ;AAEA,SAAS,eAAe;AAAA,EACtB;AACF,GAEG;AACD,MAAI,OAAO,SAAS,SAAU,QAAO,oBAAC,oBAAiB,SAAS,CAAC,MAAM,GAAG;AAC1E,MAAI,OAAO,SAAS,WAAW;AAC7B,UAAM,OAAO,OAAO;AACpB,QAAI,KAAK,SAAS;AAChB,aAAO,oBAAC,eAAY,UAAQ,MAAC,OAAO,MAAM;AAC5C,QAAI,KAAK,SAAS;AAChB,aACE,qBAAC,OAAE;AAAA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