@webless/agent 0.7.5 → 0.9.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 +49 -2
- package/dist/chunk-5BCSXCLT.js +297 -0
- package/dist/chunk-5BCSXCLT.js.map +1 -0
- package/dist/{chunk-CD6TKXGT.js → chunk-QMTI5646.js} +69 -40
- package/dist/chunk-QMTI5646.js.map +1 -0
- package/dist/embed.cjs +62 -39
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.css +98 -0
- package/dist/embed.css.map +1 -1
- package/dist/embed.js +1 -1
- package/dist/index.d.cts +3 -180
- package/dist/index.d.ts +3 -180
- package/dist/index.js +9 -288
- package/dist/index.js.map +1 -1
- package/dist/presentation.cjs +850 -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 +549 -0
- package/dist/presentation.js.map +1 -0
- package/dist/react.cjs +218 -39
- package/dist/react.cjs.map +1 -1
- package/dist/react.css +98 -0
- package/dist/react.css.map +1 -1
- package/dist/react.d.cts +26 -3
- package/dist/react.d.ts +26 -3
- package/dist/react.js +163 -2
- package/dist/react.js.map +1 -1
- package/dist/types-ohWeTG9i.d.cts +181 -0
- package/dist/types-ohWeTG9i.d.ts +181 -0
- package/package.json +7 -2
- package/dist/chunk-CD6TKXGT.js.map +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { e as AgentIndexVersion, k as AgentPlacementConfig, d as AgentColorScheme, c as AgentBrandingConfig, b as AgentAnalyticsConfig, X as VisitorToolResultRegistry, i as AgentMessageFeedback, T as ToolStep, m as AgentRailState, n as AgentRailTheme, H as ConversationMessage, h as AgentInputResponse, C as AgentToolUiSurface, v as AgentToolResultJsonValue, J as FollowUpSuggestion, l as AgentRailPhase, V as VisitorBooking } from './manifest-DgjT8-tW.js';
|
|
3
|
-
export { A as AGENT_STRUCTURED_TOOL_INPUT_HEADER, a as AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION, f as AgentInputOption, g as AgentInputRequest, o as AgentSearchReferences, p as AgentSearchSource, q as AgentStructuredToolInput, u as AgentToolResult, w as AgentToolUiAction, x as AgentToolUiField, y as AgentToolUiFieldKind, z as AgentToolUiOption, B as AgentToolUiStep, D as AssistEdgeTab, E as AssistTabSide, F as AssistTabVariant, G as Citation, I as DEFAULT_AGENT_PLACEMENT, K as JourneyContext,
|
|
2
|
+
import { e as AgentIndexVersion, k as AgentPlacementConfig, d as AgentColorScheme, c as AgentBrandingConfig, b as AgentAnalyticsConfig, X as VisitorToolResultRegistry, i as AgentMessageFeedback, T as ToolStep, m as AgentRailState, n as AgentRailTheme, H as ConversationMessage, h as AgentInputResponse, C as AgentToolUiSurface, v as AgentToolResultJsonValue, J as FollowUpSuggestion, l as AgentRailPhase, V as VisitorBooking, R as ResolvedVisitorToolResultPresentation } from './manifest-DgjT8-tW.js';
|
|
3
|
+
export { A as AGENT_STRUCTURED_TOOL_INPUT_HEADER, a as AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION, f as AgentInputOption, g as AgentInputRequest, o as AgentSearchReferences, p as AgentSearchSource, q as AgentStructuredToolInput, u as AgentToolResult, w as AgentToolUiAction, x as AgentToolUiField, y as AgentToolUiFieldKind, z as AgentToolUiOption, B as AgentToolUiStep, D as AssistEdgeTab, E as AssistTabSide, F as AssistTabVariant, G as Citation, I as DEFAULT_AGENT_PLACEMENT, K as JourneyContext, L as ToolStepState, M as VisitorBookingResultPresentation, O as VisitorSearchResultPresentation, P as VisitorToolInputResultPresentation, Q as VisitorToolResultLink, S as VisitorToolResultPresentation, U as VisitorToolResultPresenter, W as VisitorToolResultPresenterOutput, Y as builtInVisitorToolResultRegistry, Z as defaultAgentRailTheme, _ as defaultDarkAgentRailTheme, $ as formatAgentStructuredToolInput, a0 as normalizeAgentPlacement, a2 as presentVisitorToolResult } from './manifest-DgjT8-tW.js';
|
|
4
4
|
|
|
5
5
|
type AgentWidgetProps = {
|
|
6
6
|
indexId: string;
|
|
@@ -135,4 +135,27 @@ declare function buildAgentAnswerFeedbackEvent(input: {
|
|
|
135
135
|
*/
|
|
136
136
|
declare function sendAgentAnswerFeedback(eventUrl: string, event: Record<string, unknown>): void;
|
|
137
137
|
|
|
138
|
-
|
|
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
|
+
|
|
148
|
+
type AgentTranscriptProps = {
|
|
149
|
+
messages: readonly ConversationMessage[];
|
|
150
|
+
activities?: readonly AgentTranscriptActivity[];
|
|
151
|
+
theme?: Partial<AgentRailTheme>;
|
|
152
|
+
colorScheme?: AgentColorScheme;
|
|
153
|
+
agentLabel?: string;
|
|
154
|
+
visitorLabel?: string;
|
|
155
|
+
label?: string;
|
|
156
|
+
formatTimestamp?: (createdAt: number) => string;
|
|
157
|
+
};
|
|
158
|
+
/** Renders a stored snapshot; never creates a session or exposes chat actions. */
|
|
159
|
+
declare function AgentTranscript({ messages, activities, theme, colorScheme, agentLabel, visitorLabel, label, formatTimestamp, }: AgentTranscriptProps): react.JSX.Element;
|
|
160
|
+
|
|
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,8 +6,13 @@ import {
|
|
|
6
6
|
AgentRail,
|
|
7
7
|
AgentWidget,
|
|
8
8
|
AssistEdgeTab,
|
|
9
|
+
BookingCard,
|
|
9
10
|
DEFAULT_AGENT_PLACEMENT,
|
|
10
11
|
MessageActions,
|
|
12
|
+
MessageBubble,
|
|
13
|
+
SearchReferences,
|
|
14
|
+
VisitorToolResultView,
|
|
15
|
+
agentThemeStyle,
|
|
11
16
|
buildAgentAnswerFeedbackEvent,
|
|
12
17
|
builtInVisitorToolResultRegistry,
|
|
13
18
|
createIdleSuggestions,
|
|
@@ -20,13 +25,169 @@ import {
|
|
|
20
25
|
normalizeAgentPlacement,
|
|
21
26
|
presentVisitorToolResult,
|
|
22
27
|
sendAgentAnswerFeedback,
|
|
23
|
-
useAgentChat
|
|
24
|
-
|
|
28
|
+
useAgentChat,
|
|
29
|
+
useAgentColorScheme
|
|
30
|
+
} from "./chunk-QMTI5646.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
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/react/components/AgentTranscript/AgentTranscript.tsx
|
|
111
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
112
|
+
var timestampFormat = new Intl.DateTimeFormat("en-US", {
|
|
113
|
+
month: "short",
|
|
114
|
+
day: "numeric",
|
|
115
|
+
hour: "numeric",
|
|
116
|
+
minute: "2-digit",
|
|
117
|
+
timeZone: "UTC"
|
|
118
|
+
});
|
|
119
|
+
function defaultTimestamp(createdAt) {
|
|
120
|
+
return `${timestampFormat.format(createdAt)} UTC`;
|
|
121
|
+
}
|
|
122
|
+
function AgentTranscript({
|
|
123
|
+
messages,
|
|
124
|
+
activities = [],
|
|
125
|
+
theme,
|
|
126
|
+
colorScheme,
|
|
127
|
+
agentLabel = "Agent",
|
|
128
|
+
visitorLabel = "Visitor",
|
|
129
|
+
label = "Conversation transcript",
|
|
130
|
+
formatTimestamp = defaultTimestamp
|
|
131
|
+
}) {
|
|
132
|
+
const scheme = useAgentColorScheme(colorScheme);
|
|
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(
|
|
141
|
+
"ol",
|
|
142
|
+
{
|
|
143
|
+
className: "webless-agent-root agent-transcript not-typeset",
|
|
144
|
+
"data-not-typeset": "",
|
|
145
|
+
"data-color-scheme": scheme,
|
|
146
|
+
"aria-label": label,
|
|
147
|
+
style: agentThemeStyle(theme, scheme),
|
|
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
|
+
const date = new Date(message.createdAt);
|
|
159
|
+
const validTimestamp = Number.isFinite(date.getTime());
|
|
160
|
+
return /* @__PURE__ */ jsxs2(
|
|
161
|
+
"li",
|
|
162
|
+
{
|
|
163
|
+
className: `agent-transcript__message agent-transcript__message--${message.role}`,
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ jsxs2("div", { className: "agent-transcript__meta", children: [
|
|
166
|
+
/* @__PURE__ */ jsx2("span", { children: message.role === "visitor" ? visitorLabel : agentLabel }),
|
|
167
|
+
validTimestamp ? /* @__PURE__ */ jsx2("time", { dateTime: date.toISOString(), children: formatTimestamp(message.createdAt) }) : null
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ jsx2(
|
|
170
|
+
MessageBubble,
|
|
171
|
+
{
|
|
172
|
+
message: message.role === "agent" ? { ...message, streaming: false } : message,
|
|
173
|
+
bookingReadOnly: true,
|
|
174
|
+
bookingDisabled: true
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
message.id
|
|
180
|
+
);
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
25
185
|
export {
|
|
26
186
|
AGENT_ANSWER_FEEDBACK_EVENT_TYPE,
|
|
27
187
|
AGENT_STRUCTURED_TOOL_INPUT_HEADER,
|
|
28
188
|
AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION,
|
|
29
189
|
AgentRail,
|
|
190
|
+
AgentTranscript,
|
|
30
191
|
AgentWidget,
|
|
31
192
|
AssistEdgeTab,
|
|
32
193
|
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/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 { 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 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 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,KAA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|
@@ -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";
|
|
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 };
|
|
@@ -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";
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webless/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Webless Agent SDK — Eve runtime client, React UI, and embed bundle.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,12 @@
|
|
|
31
31
|
"require": "./dist/embed.cjs"
|
|
32
32
|
},
|
|
33
33
|
"./react.css": "./dist/react.css",
|
|
34
|
-
"./embed.css": "./dist/embed.css"
|
|
34
|
+
"./embed.css": "./dist/embed.css",
|
|
35
|
+
"./presentation": {
|
|
36
|
+
"types": "./dist/presentation.d.ts",
|
|
37
|
+
"import": "./dist/presentation.js",
|
|
38
|
+
"require": "./dist/presentation.cjs"
|
|
39
|
+
}
|
|
35
40
|
},
|
|
36
41
|
"scripts": {
|
|
37
42
|
"build": "tsup && node ./scripts/ensure-css-imports.mjs",
|