@webless/agent 0.8.0 → 0.9.1
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 +39 -5
- package/dist/{chunk-JZPXXG76.js → chunk-3E632FNE.js} +354 -204
- package/dist/chunk-3E632FNE.js.map +1 -0
- package/dist/chunk-TCO62TRN.js +335 -0
- package/dist/chunk-TCO62TRN.js.map +1 -0
- package/dist/embed.cjs +770 -623
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.css +102 -10
- package/dist/embed.css.map +1 -1
- package/dist/embed.d.cts +3 -9
- package/dist/embed.d.ts +3 -9
- package/dist/embed.js +1 -1
- package/dist/index.cjs +752 -680
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -180
- package/dist/index.d.ts +3 -180
- package/dist/index.js +51 -291
- package/dist/index.js.map +1 -1
- package/dist/{manifest-DgjT8-tW.d.cts → panel-controller-D_XIQa1U.d.cts} +9 -2
- package/dist/{manifest-DgjT8-tW.d.ts → panel-controller-D_XIQa1U.d.ts} +9 -2
- package/dist/presentation.cjs +862 -0
- package/dist/presentation.cjs.map +1 -0
- package/dist/presentation.d.cts +160 -0
- package/dist/presentation.d.ts +160 -0
- package/dist/presentation.js +553 -0
- package/dist/presentation.js.map +1 -0
- package/dist/react.cjs +749 -504
- package/dist/react.cjs.map +1 -1
- package/dist/react.css +102 -10
- package/dist/react.css.map +1 -1
- package/dist/react.d.cts +16 -5
- package/dist/react.d.ts +16 -5
- package/dist/react.js +110 -9
- package/dist/react.js.map +1 -1
- package/dist/types-sLEIYDqm.d.cts +181 -0
- package/dist/types-sLEIYDqm.d.ts +181 -0
- package/package.json +7 -2
- package/dist/chunk-JZPXXG76.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,
|
|
3
|
-
export { A as AGENT_STRUCTURED_TOOL_INPUT_HEADER, a as AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION, f as AgentInputOption, g as AgentInputRequest,
|
|
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-D_XIQa1U.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-D_XIQa1U.cjs';
|
|
4
4
|
|
|
5
5
|
type AgentWidgetProps = {
|
|
6
6
|
indexId: string;
|
|
@@ -54,7 +54,7 @@ type AgentRailProps = {
|
|
|
54
54
|
onRetry?: () => void;
|
|
55
55
|
onRegenerate?: () => void;
|
|
56
56
|
onFeedback?: (rating: AgentMessageFeedback, message: ConversationMessage) => void;
|
|
57
|
-
onSubmit?: (message: string) => void;
|
|
57
|
+
onSubmit?: (message: string, options?: AgentPanelSubmitOptions) => void;
|
|
58
58
|
onFollowUpSelect?: (label: string) => void;
|
|
59
59
|
onBook?: (input: {
|
|
60
60
|
displayText: string;
|
|
@@ -135,8 +135,19 @@ declare function buildAgentAnswerFeedbackEvent(input: {
|
|
|
135
135
|
*/
|
|
136
136
|
declare function sendAgentAnswerFeedback(eventUrl: string, event: Record<string, unknown>): void;
|
|
137
137
|
|
|
138
|
+
type AgentTranscriptActivity = {
|
|
139
|
+
id: string;
|
|
140
|
+
createdAt: number;
|
|
141
|
+
callId: string;
|
|
142
|
+
category: "tool" | "specialist";
|
|
143
|
+
label: string;
|
|
144
|
+
status: "started" | "completed" | "failed" | "rejected";
|
|
145
|
+
result?: ResolvedVisitorToolResultPresentation;
|
|
146
|
+
};
|
|
147
|
+
|
|
138
148
|
type AgentTranscriptProps = {
|
|
139
149
|
messages: readonly ConversationMessage[];
|
|
150
|
+
activities?: readonly AgentTranscriptActivity[];
|
|
140
151
|
theme?: Partial<AgentRailTheme>;
|
|
141
152
|
colorScheme?: AgentColorScheme;
|
|
142
153
|
agentLabel?: string;
|
|
@@ -145,6 +156,6 @@ type AgentTranscriptProps = {
|
|
|
145
156
|
formatTimestamp?: (createdAt: number) => string;
|
|
146
157
|
};
|
|
147
158
|
/** 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;
|
|
159
|
+
declare function AgentTranscript({ messages, activities, theme, colorScheme, agentLabel, visitorLabel, label, formatTimestamp, }: AgentTranscriptProps): react.JSX.Element;
|
|
149
160
|
|
|
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 };
|
|
161
|
+
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,
|
|
3
|
-
export { A as AGENT_STRUCTURED_TOOL_INPUT_HEADER, a as AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION, f as AgentInputOption, g as AgentInputRequest,
|
|
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-D_XIQa1U.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-D_XIQa1U.js';
|
|
4
4
|
|
|
5
5
|
type AgentWidgetProps = {
|
|
6
6
|
indexId: string;
|
|
@@ -54,7 +54,7 @@ type AgentRailProps = {
|
|
|
54
54
|
onRetry?: () => void;
|
|
55
55
|
onRegenerate?: () => void;
|
|
56
56
|
onFeedback?: (rating: AgentMessageFeedback, message: ConversationMessage) => void;
|
|
57
|
-
onSubmit?: (message: string) => void;
|
|
57
|
+
onSubmit?: (message: string, options?: AgentPanelSubmitOptions) => void;
|
|
58
58
|
onFollowUpSelect?: (label: string) => void;
|
|
59
59
|
onBook?: (input: {
|
|
60
60
|
displayText: string;
|
|
@@ -135,8 +135,19 @@ declare function buildAgentAnswerFeedbackEvent(input: {
|
|
|
135
135
|
*/
|
|
136
136
|
declare function sendAgentAnswerFeedback(eventUrl: string, event: Record<string, unknown>): void;
|
|
137
137
|
|
|
138
|
+
type AgentTranscriptActivity = {
|
|
139
|
+
id: string;
|
|
140
|
+
createdAt: number;
|
|
141
|
+
callId: string;
|
|
142
|
+
category: "tool" | "specialist";
|
|
143
|
+
label: string;
|
|
144
|
+
status: "started" | "completed" | "failed" | "rejected";
|
|
145
|
+
result?: ResolvedVisitorToolResultPresentation;
|
|
146
|
+
};
|
|
147
|
+
|
|
138
148
|
type AgentTranscriptProps = {
|
|
139
149
|
messages: readonly ConversationMessage[];
|
|
150
|
+
activities?: readonly AgentTranscriptActivity[];
|
|
140
151
|
theme?: Partial<AgentRailTheme>;
|
|
141
152
|
colorScheme?: AgentColorScheme;
|
|
142
153
|
agentLabel?: string;
|
|
@@ -145,6 +156,6 @@ type AgentTranscriptProps = {
|
|
|
145
156
|
formatTimestamp?: (createdAt: number) => string;
|
|
146
157
|
};
|
|
147
158
|
/** 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;
|
|
159
|
+
declare function AgentTranscript({ messages, activities, theme, colorScheme, agentLabel, visitorLabel, label, formatTimestamp, }: AgentTranscriptProps): react.JSX.Element;
|
|
149
160
|
|
|
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 };
|
|
161
|
+
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
|
@@ -6,9 +6,12 @@ import {
|
|
|
6
6
|
AgentRail,
|
|
7
7
|
AgentWidget,
|
|
8
8
|
AssistEdgeTab,
|
|
9
|
+
BookingCard,
|
|
9
10
|
DEFAULT_AGENT_PLACEMENT,
|
|
10
11
|
MessageActions,
|
|
11
12
|
MessageBubble,
|
|
13
|
+
SearchReferences,
|
|
14
|
+
VisitorToolResultView,
|
|
12
15
|
agentThemeStyle,
|
|
13
16
|
buildAgentAnswerFeedbackEvent,
|
|
14
17
|
builtInVisitorToolResultRegistry,
|
|
@@ -24,10 +27,88 @@ import {
|
|
|
24
27
|
sendAgentAnswerFeedback,
|
|
25
28
|
useAgentChat,
|
|
26
29
|
useAgentColorScheme
|
|
27
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-3E632FNE.js";
|
|
31
|
+
|
|
32
|
+
// src/react/components/AgentTranscript/TranscriptActivity.tsx
|
|
33
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
34
|
+
var statusLabels = {
|
|
35
|
+
started: "No result recorded",
|
|
36
|
+
completed: "",
|
|
37
|
+
failed: "Failed",
|
|
38
|
+
rejected: "Rejected"
|
|
39
|
+
};
|
|
40
|
+
function RecordedResult({
|
|
41
|
+
result
|
|
42
|
+
}) {
|
|
43
|
+
if (result.kind === "search") return /* @__PURE__ */ jsx(SearchReferences, { results: [result] });
|
|
44
|
+
if (result.kind === "booking") {
|
|
45
|
+
const card = result.card;
|
|
46
|
+
if (card.type === "booking_offer")
|
|
47
|
+
return /* @__PURE__ */ jsx(BookingCard, { readOnly: true, offer: card });
|
|
48
|
+
if (card.type === "booking_confirmed")
|
|
49
|
+
return /* @__PURE__ */ jsxs("p", { children: [
|
|
50
|
+
"Booking confirmed",
|
|
51
|
+
card.startTime ? ` \xB7 ${card.startTime}` : ""
|
|
52
|
+
] });
|
|
53
|
+
if (card.type === "booking_canceled") return /* @__PURE__ */ jsx("p", { children: "Booking canceled" });
|
|
54
|
+
return /* @__PURE__ */ jsx("p", { children: "Information requested" });
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsx(VisitorToolResultView, { disabled: true, result });
|
|
57
|
+
}
|
|
58
|
+
function TranscriptActivity({
|
|
59
|
+
activity,
|
|
60
|
+
formatTimestamp
|
|
61
|
+
}) {
|
|
62
|
+
const date = new Date(activity.createdAt);
|
|
63
|
+
const validTimestamp = Number.isFinite(date.getTime());
|
|
64
|
+
const result = activity.result?.kind === "hidden" ? void 0 : activity.result;
|
|
65
|
+
const heading = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
66
|
+
/* @__PURE__ */ jsx("span", { children: activity.category === "specialist" ? `Specialist \xB7 ${activity.label}` : activity.label }),
|
|
67
|
+
activity.status !== "completed" ? /* @__PURE__ */ jsx("span", { className: "agent-transcript__activity-status", children: statusLabels[activity.status] }) : null,
|
|
68
|
+
validTimestamp ? /* @__PURE__ */ jsx("time", { dateTime: date.toISOString(), children: formatTimestamp(activity.createdAt) }) : null
|
|
69
|
+
] });
|
|
70
|
+
return /* @__PURE__ */ jsx("li", { className: "agent-transcript__activity", "data-status": activity.status, children: result ? /* @__PURE__ */ jsxs("details", { children: [
|
|
71
|
+
/* @__PURE__ */ jsx("summary", { className: "agent-transcript__activity-heading", children: heading }),
|
|
72
|
+
/* @__PURE__ */ jsx("div", { className: "agent-transcript__activity-result", children: /* @__PURE__ */ jsx(RecordedResult, { result }) })
|
|
73
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "agent-transcript__activity-heading", children: heading }) });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/react/components/AgentTranscript/group-activities.ts
|
|
77
|
+
function groupTranscriptActivities(activities) {
|
|
78
|
+
const calls = /* @__PURE__ */ new Map();
|
|
79
|
+
for (const activity of activities) {
|
|
80
|
+
const key = `${activity.category}:${activity.callId}`;
|
|
81
|
+
const previous = calls.get(key);
|
|
82
|
+
if (!previous) {
|
|
83
|
+
calls.set(key, {
|
|
84
|
+
latest: activity,
|
|
85
|
+
id: activity.id,
|
|
86
|
+
startedAt: activity.createdAt,
|
|
87
|
+
label: activity.label
|
|
88
|
+
});
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const previousHasResult = previous.latest.status !== "started";
|
|
92
|
+
const nextHasResult = activity.status !== "started";
|
|
93
|
+
const useNext = nextHasResult && !previousHasResult || nextHasResult === previousHasResult && activity.createdAt >= previous.latest.createdAt;
|
|
94
|
+
const latest = useNext ? activity : previous.latest;
|
|
95
|
+
calls.set(key, {
|
|
96
|
+
latest,
|
|
97
|
+
id: previous.id,
|
|
98
|
+
startedAt: Math.min(previous.startedAt, activity.createdAt),
|
|
99
|
+
label: activity.createdAt < previous.startedAt ? activity.label : previous.label
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return [...calls.values()].map(({ latest, id, startedAt, label }) => ({
|
|
103
|
+
...latest,
|
|
104
|
+
id,
|
|
105
|
+
label,
|
|
106
|
+
createdAt: startedAt
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
28
109
|
|
|
29
110
|
// src/react/components/AgentTranscript/AgentTranscript.tsx
|
|
30
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
111
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
31
112
|
var timestampFormat = new Intl.DateTimeFormat("en-US", {
|
|
32
113
|
month: "short",
|
|
33
114
|
day: "numeric",
|
|
@@ -40,6 +121,7 @@ function defaultTimestamp(createdAt) {
|
|
|
40
121
|
}
|
|
41
122
|
function AgentTranscript({
|
|
42
123
|
messages,
|
|
124
|
+
activities = [],
|
|
43
125
|
theme,
|
|
44
126
|
colorScheme,
|
|
45
127
|
agentLabel = "Agent",
|
|
@@ -48,7 +130,14 @@ function AgentTranscript({
|
|
|
48
130
|
formatTimestamp = defaultTimestamp
|
|
49
131
|
}) {
|
|
50
132
|
const scheme = useAgentColorScheme(colorScheme);
|
|
51
|
-
|
|
133
|
+
const entries = [
|
|
134
|
+
...messages.map((message) => ({ kind: "message", ...message })),
|
|
135
|
+
...groupTranscriptActivities(activities).map((activity) => ({
|
|
136
|
+
kind: "activity",
|
|
137
|
+
...activity
|
|
138
|
+
}))
|
|
139
|
+
].sort((left, right) => left.createdAt - right.createdAt);
|
|
140
|
+
return /* @__PURE__ */ jsx2(
|
|
52
141
|
"ol",
|
|
53
142
|
{
|
|
54
143
|
className: "webless-agent-root agent-transcript not-typeset",
|
|
@@ -56,22 +145,34 @@ function AgentTranscript({
|
|
|
56
145
|
"data-color-scheme": scheme,
|
|
57
146
|
"aria-label": label,
|
|
58
147
|
style: agentThemeStyle(theme, scheme),
|
|
59
|
-
children:
|
|
148
|
+
children: entries.map((message) => {
|
|
149
|
+
if (message.kind === "activity")
|
|
150
|
+
return /* @__PURE__ */ jsx2(
|
|
151
|
+
TranscriptActivity,
|
|
152
|
+
{
|
|
153
|
+
activity: message,
|
|
154
|
+
formatTimestamp
|
|
155
|
+
},
|
|
156
|
+
message.id
|
|
157
|
+
);
|
|
158
|
+
if (message.role === "visitor" && !message.text.trim()) return null;
|
|
60
159
|
const date = new Date(message.createdAt);
|
|
61
160
|
const validTimestamp = Number.isFinite(date.getTime());
|
|
62
|
-
return /* @__PURE__ */
|
|
161
|
+
return /* @__PURE__ */ jsxs2(
|
|
63
162
|
"li",
|
|
64
163
|
{
|
|
65
164
|
className: `agent-transcript__message agent-transcript__message--${message.role}`,
|
|
66
165
|
children: [
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
validTimestamp ? /* @__PURE__ */
|
|
166
|
+
/* @__PURE__ */ jsxs2("div", { className: "agent-transcript__meta", children: [
|
|
167
|
+
/* @__PURE__ */ jsx2("span", { children: message.role === "visitor" ? visitorLabel : agentLabel }),
|
|
168
|
+
validTimestamp ? /* @__PURE__ */ jsx2("time", { dateTime: date.toISOString(), children: formatTimestamp(message.createdAt) }) : null
|
|
70
169
|
] }),
|
|
71
|
-
/* @__PURE__ */
|
|
170
|
+
message.role === "agent" ? message.toolResults?.map((result) => /* @__PURE__ */ jsx2(VisitorToolResultView, { result }, result.id)) : null,
|
|
171
|
+
/* @__PURE__ */ jsx2(
|
|
72
172
|
MessageBubble,
|
|
73
173
|
{
|
|
74
174
|
message: message.role === "agent" ? { ...message, streaming: false } : message,
|
|
175
|
+
bookingReadOnly: true,
|
|
75
176
|
bookingDisabled: true
|
|
76
177
|
}
|
|
77
178
|
)
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DY,SACE,KADF;AAtCZ,IAAM,kBAAkB,IAAI,KAAK,eAAe,SAAS;AAAA,EACvD,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,UAAU;AACZ,CAAC;AACD,SAAS,iBAAiB,WAAmB;AAC3C,SAAO,GAAG,gBAAgB,OAAO,SAAS,CAAC;AAC7C;AAGO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,kBAAkB;AACpB,GAAyB;AACvB,QAAM,SAAS,oBAAoB,WAAW;AAC9C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,oBAAiB;AAAA,MACjB,qBAAmB;AAAA,MACnB,cAAY;AAAA,MACZ,OAAO,gBAAgB,OAAO,MAAM;AAAA,MAEnC,mBAAS,IAAI,CAAC,YAAY;AACzB,cAAM,OAAO,IAAI,KAAK,QAAQ,SAAS;AACvC,cAAM,iBAAiB,OAAO,SAAS,KAAK,QAAQ,CAAC;AACrD,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,WAAW,wDAAwD,QAAQ,IAAI;AAAA,YAE/E;AAAA,mCAAC,SAAI,WAAU,0BACb;AAAA,oCAAC,UACE,kBAAQ,SAAS,YAAY,eAAe,YAC/C;AAAA,gBACC,iBACC,oBAAC,UAAK,UAAU,KAAK,YAAY,GAC9B,0BAAgB,QAAQ,SAAS,GACpC,IACE;AAAA,iBACN;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,SACE,QAAQ,SAAS,UACb,EAAE,GAAG,SAAS,WAAW,MAAM,IAC/B;AAAA,kBAEN,iBAAe;AAAA;AAAA,cACjB;AAAA;AAAA;AAAA,UApBK,QAAQ;AAAA,QAqBf;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/react/components/AgentTranscript/TranscriptActivity.tsx","../src/react/components/AgentTranscript/group-activities.ts","../src/react/components/AgentTranscript/AgentTranscript.tsx"],"sourcesContent":["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 formatTimestamp,\n}: {\n activity: AgentTranscriptActivity;\n formatTimestamp: (createdAt: number) => string;\n}) {\n const date = new Date(activity.createdAt);\n const validTimestamp = Number.isFinite(date.getTime());\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 {validTimestamp ? (\n <time dateTime={date.toISOString()}>\n {formatTimestamp(activity.createdAt)}\n </time>\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","import 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 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}: 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((message) => {\n if (message.kind === \"activity\")\n return (\n <TranscriptActivity\n key={message.id}\n activity={message}\n formatTimestamp={formatTimestamp}\n />\n );\n if (message.role === \"visitor\" && !message.text.trim()) return null;\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 {message.role === \"agent\" ? message.toolResults?.map((result) => (\n <VisitorToolResultView key={result.id} result={result} />\n )) : null}\n <MessageBubble\n message={\n message.role === \"agent\"\n ? { ...message, streaming: false }\n : message\n }\n bookingReadOnly\n bookingDisabled\n />\n </li>\n );\n })}\n </ol>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BuC,SA2BnC,UA3BmC,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,MA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,kBACf,iBAAe;AAAA;AAAA,cACjB;AAAA;AAAA;AAAA,UAxBK,QAAQ;AAAA,QAyBf;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;","names":["jsx","jsxs"]}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
declare const AGENT_TOOL_UI_SCHEMA_VERSION: "webless.tool-ui.v1";
|
|
2
|
+
declare const AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION: "webless.structured-tool-input.v1";
|
|
3
|
+
declare const AGENT_STRUCTURED_TOOL_INPUT_HEADER: "Webless-Structured-Tool-Input-JSON:";
|
|
4
|
+
type AgentToolUiFieldKind = "text" | "textarea" | "email" | "number" | "select" | "multi-select" | "checkbox" | "confirmation" | "radio" | "date" | "time" | "date-time" | "calendar" | "range" | "json";
|
|
5
|
+
type AgentToolUiOption = {
|
|
6
|
+
label: string;
|
|
7
|
+
value: AgentToolResultJsonValue;
|
|
8
|
+
};
|
|
9
|
+
type AgentToolUiField = {
|
|
10
|
+
description?: string;
|
|
11
|
+
kind: AgentToolUiFieldKind;
|
|
12
|
+
label: string;
|
|
13
|
+
max?: number;
|
|
14
|
+
maxItems?: number;
|
|
15
|
+
maxLength?: number;
|
|
16
|
+
min?: number;
|
|
17
|
+
minLength?: number;
|
|
18
|
+
options?: readonly AgentToolUiOption[];
|
|
19
|
+
path: string;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
step?: number;
|
|
23
|
+
defaultValue?: AgentToolResultJsonValue;
|
|
24
|
+
};
|
|
25
|
+
type AgentToolUiStep = {
|
|
26
|
+
description?: string;
|
|
27
|
+
fieldPaths: readonly string[];
|
|
28
|
+
id: string;
|
|
29
|
+
label: string;
|
|
30
|
+
};
|
|
31
|
+
type AgentToolUiAction = {
|
|
32
|
+
id: "submit" | "back" | "next" | "reset";
|
|
33
|
+
label: string;
|
|
34
|
+
};
|
|
35
|
+
type AgentToolUiSurface = {
|
|
36
|
+
actions?: readonly AgentToolUiAction[];
|
|
37
|
+
description?: string;
|
|
38
|
+
fields: readonly AgentToolUiField[];
|
|
39
|
+
id: string;
|
|
40
|
+
operationId?: string;
|
|
41
|
+
requestId?: string;
|
|
42
|
+
schemaVersion: typeof AGENT_TOOL_UI_SCHEMA_VERSION;
|
|
43
|
+
steps?: readonly AgentToolUiStep[];
|
|
44
|
+
submitLabel?: string;
|
|
45
|
+
title: string;
|
|
46
|
+
toolSlug: string;
|
|
47
|
+
values?: Readonly<Record<string, AgentToolResultJsonValue>>;
|
|
48
|
+
};
|
|
49
|
+
type AgentStructuredToolInput = {
|
|
50
|
+
schemaVersion: typeof AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION;
|
|
51
|
+
operationId?: string;
|
|
52
|
+
toolSlug: string;
|
|
53
|
+
values: Readonly<Record<string, AgentToolResultJsonValue>>;
|
|
54
|
+
};
|
|
55
|
+
declare function formatAgentStructuredToolInput(surface: AgentToolUiSurface, values: Readonly<Record<string, AgentToolResultJsonValue>>): string;
|
|
56
|
+
declare function parseAgentToolUiSurface(value: unknown): AgentToolUiSurface | null;
|
|
57
|
+
|
|
58
|
+
type AgentToolResultJsonValue = null | boolean | number | string | AgentToolResultJsonValue[] | {
|
|
59
|
+
[key: string]: AgentToolResultJsonValue;
|
|
60
|
+
};
|
|
61
|
+
type AgentToolResultEnvelope = {
|
|
62
|
+
schemaVersion: "webless.tool-result.v1";
|
|
63
|
+
output: AgentToolResultJsonValue;
|
|
64
|
+
presentationKinds: string[];
|
|
65
|
+
ui?: AgentToolUiSurface;
|
|
66
|
+
};
|
|
67
|
+
declare function parseAgentToolResultEnvelope(value: unknown): AgentToolResultEnvelope | null;
|
|
68
|
+
|
|
69
|
+
type AgentIndexVersion = "published" | "unpublished";
|
|
70
|
+
type AgentRuntimeConfig = {
|
|
71
|
+
origin: string;
|
|
72
|
+
indexId: string;
|
|
73
|
+
version: AgentIndexVersion;
|
|
74
|
+
host: string;
|
|
75
|
+
};
|
|
76
|
+
type AgentWorkItem = {
|
|
77
|
+
id: string;
|
|
78
|
+
kind: "planning" | "search" | "specialist" | "tool";
|
|
79
|
+
label: string;
|
|
80
|
+
state: "completed" | "active" | "pending" | "error";
|
|
81
|
+
detail?: string;
|
|
82
|
+
};
|
|
83
|
+
type AgentInputOption = {
|
|
84
|
+
id: string;
|
|
85
|
+
label: string;
|
|
86
|
+
description?: string;
|
|
87
|
+
style?: "default" | "primary" | "danger";
|
|
88
|
+
};
|
|
89
|
+
type AgentInputRequest = {
|
|
90
|
+
requestId: string;
|
|
91
|
+
kind: "question" | "session-limit" | "tool-approval";
|
|
92
|
+
prompt: string;
|
|
93
|
+
display?: "confirmation" | "select" | "text";
|
|
94
|
+
allowFreeform?: boolean;
|
|
95
|
+
options?: readonly AgentInputOption[];
|
|
96
|
+
ui?: AgentToolUiSurface;
|
|
97
|
+
action: {
|
|
98
|
+
callId: string;
|
|
99
|
+
kind: "tool-call";
|
|
100
|
+
toolName: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
type AgentInputResponse = {
|
|
104
|
+
requestId: string;
|
|
105
|
+
optionId?: string;
|
|
106
|
+
text?: string;
|
|
107
|
+
value?: AgentToolResultJsonValue;
|
|
108
|
+
};
|
|
109
|
+
type AgentToolResult = {
|
|
110
|
+
callId: string;
|
|
111
|
+
toolName: string;
|
|
112
|
+
status: "completed" | "failed" | "rejected";
|
|
113
|
+
output?: unknown;
|
|
114
|
+
error?: {
|
|
115
|
+
code: string;
|
|
116
|
+
message: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
type AgentStreamHandlers = {
|
|
120
|
+
onWork?: (item: AgentWorkItem) => void;
|
|
121
|
+
/** @deprecated Use onWork for semantic progress events. */
|
|
122
|
+
onStep?: (label: string, detail?: string) => void;
|
|
123
|
+
onDelta: (delta: string) => void;
|
|
124
|
+
onComplete?: () => void;
|
|
125
|
+
onActionResult?: (output: unknown) => void;
|
|
126
|
+
onToolResult?: (result: AgentToolResult) => void;
|
|
127
|
+
onInputRequest?: (requests: readonly AgentInputRequest[]) => void;
|
|
128
|
+
};
|
|
129
|
+
type AgentSendTurnOptions = {
|
|
130
|
+
signal?: AbortSignal;
|
|
131
|
+
handlers: AgentStreamHandlers;
|
|
132
|
+
};
|
|
133
|
+
type AgentResumeTurnOptions = AgentSendTurnOptions & {
|
|
134
|
+
initialText?: string;
|
|
135
|
+
message: string;
|
|
136
|
+
};
|
|
137
|
+
type AgentRespondTurnOptions = AgentSendTurnOptions & {
|
|
138
|
+
responses: readonly AgentInputResponse[];
|
|
139
|
+
};
|
|
140
|
+
type PersistedAgentSession = {
|
|
141
|
+
sessionId: string;
|
|
142
|
+
streamIndex: number;
|
|
143
|
+
lastMessage?: string;
|
|
144
|
+
};
|
|
145
|
+
type AgentClientOptions = {
|
|
146
|
+
/** Index id sent as `indexId` query param to the runtime. */
|
|
147
|
+
indexId: string;
|
|
148
|
+
/** Selects the published index by default, or its unpublished preview. */
|
|
149
|
+
version?: AgentIndexVersion;
|
|
150
|
+
/** Supplies a fresh Console authorization grant for unpublished previews. */
|
|
151
|
+
getUnpublishedPreviewGrant?: () => Promise<string>;
|
|
152
|
+
/** Ready unpublished build id carried by a generated preview URL. */
|
|
153
|
+
previewBuildId?: string;
|
|
154
|
+
/** Customer id used to isolate browser session storage when omitted from storageKeyPrefix. */
|
|
155
|
+
customerId?: string;
|
|
156
|
+
/** Agent runtime origin, e.g. `https://runtime.staging.webless.ai`. */
|
|
157
|
+
runtimeOrigin?: string;
|
|
158
|
+
/** Stable browser conversation id; generated and stored when omitted. */
|
|
159
|
+
visitorSessionId?: string;
|
|
160
|
+
/** Override sessionStorage key prefix (derived from agent identity when omitted). */
|
|
161
|
+
storageKeyPrefix?: string;
|
|
162
|
+
};
|
|
163
|
+
type AgentClient = {
|
|
164
|
+
readonly indexId: string;
|
|
165
|
+
readonly version: AgentIndexVersion;
|
|
166
|
+
readonly runtimeOrigin: string;
|
|
167
|
+
readonly visitorSessionId: string;
|
|
168
|
+
sendTurn: (message: string, options: AgentSendTurnOptions) => Promise<string>;
|
|
169
|
+
regenerateTurn: (message: string, options: AgentSendTurnOptions) => Promise<string>;
|
|
170
|
+
resumeTurn: (options: AgentResumeTurnOptions) => Promise<string | null>;
|
|
171
|
+
respondTurn: (options: AgentRespondTurnOptions) => Promise<string>;
|
|
172
|
+
reset: () => void;
|
|
173
|
+
cancelActive: () => void;
|
|
174
|
+
getActiveSessionId: () => string | undefined;
|
|
175
|
+
};
|
|
176
|
+
type AgentHealthResult = {
|
|
177
|
+
ok: boolean;
|
|
178
|
+
detail: string;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export { AGENT_STRUCTURED_TOOL_INPUT_HEADER as A, parseAgentToolResultEnvelope as B, parseAgentToolUiSurface as C, type PersistedAgentSession as P, AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION as a, AGENT_TOOL_UI_SCHEMA_VERSION as b, type AgentClient as c, type AgentClientOptions as d, type AgentHealthResult as e, type AgentIndexVersion as f, type AgentInputOption as g, type AgentInputRequest as h, type AgentInputResponse as i, type AgentRespondTurnOptions as j, type AgentResumeTurnOptions as k, type AgentRuntimeConfig as l, type AgentSendTurnOptions as m, type AgentStreamHandlers as n, type AgentStructuredToolInput as o, type AgentToolResult as p, type AgentToolResultEnvelope as q, type AgentToolResultJsonValue as r, type AgentToolUiAction as s, type AgentToolUiField as t, type AgentToolUiFieldKind as u, type AgentToolUiOption as v, type AgentToolUiStep as w, type AgentToolUiSurface as x, type AgentWorkItem as y, formatAgentStructuredToolInput as z };
|