@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
|
@@ -229,6 +229,98 @@ function hasOnlyKeys(value, allowed) {
|
|
|
229
229
|
return Object.keys(value).every((key) => allowedKeys.has(key));
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
// src/runtime/tool-result-envelope.ts
|
|
233
|
+
var ENVELOPE_KEYS = /* @__PURE__ */ new Set([
|
|
234
|
+
"schemaVersion",
|
|
235
|
+
"output",
|
|
236
|
+
"presentationKinds",
|
|
237
|
+
"ui"
|
|
238
|
+
]);
|
|
239
|
+
function isRecord2(value) {
|
|
240
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
241
|
+
}
|
|
242
|
+
function isJsonValue2(value, seen = /* @__PURE__ */ new Set()) {
|
|
243
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
247
|
+
if (typeof value !== "object") return false;
|
|
248
|
+
if (seen.has(value)) return false;
|
|
249
|
+
seen.add(value);
|
|
250
|
+
const valid = Array.isArray(value) ? value.every((item) => isJsonValue2(item, seen)) : Object.entries(value).every(
|
|
251
|
+
([key, item]) => typeof key === "string" && isJsonValue2(item, seen)
|
|
252
|
+
);
|
|
253
|
+
seen.delete(value);
|
|
254
|
+
return valid;
|
|
255
|
+
}
|
|
256
|
+
function decodeEnvelope(value) {
|
|
257
|
+
if (typeof value !== "string") return value;
|
|
258
|
+
try {
|
|
259
|
+
return JSON.parse(value);
|
|
260
|
+
} catch {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function parseAgentToolResultEnvelope(value) {
|
|
265
|
+
const decoded = decodeEnvelope(value);
|
|
266
|
+
if (!isRecord2(decoded)) return null;
|
|
267
|
+
const keys = Object.keys(decoded);
|
|
268
|
+
if (keys.some((key) => !ENVELOPE_KEYS.has(key)) || decoded.schemaVersion !== "webless.tool-result.v1" || !isJsonValue2(decoded.output) || !Array.isArray(decoded.presentationKinds) || decoded.presentationKinds.length < 1 || decoded.presentationKinds.length > 16) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
const presentationKinds = decoded.presentationKinds.flatMap((kind) => {
|
|
272
|
+
if (typeof kind !== "string") return [];
|
|
273
|
+
const normalized = kind.trim();
|
|
274
|
+
return normalized && normalized.length <= 128 ? [normalized] : [];
|
|
275
|
+
});
|
|
276
|
+
if (presentationKinds.length !== decoded.presentationKinds.length) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
const ui = decoded.ui === void 0 ? void 0 : parseAgentToolUiSurface(decoded.ui);
|
|
280
|
+
if (decoded.ui !== void 0 && !ui) return null;
|
|
281
|
+
return {
|
|
282
|
+
schemaVersion: "webless.tool-result.v1",
|
|
283
|
+
output: decoded.output,
|
|
284
|
+
presentationKinds,
|
|
285
|
+
...ui ? { ui } : {}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/runtime/connected-tool-work.ts
|
|
290
|
+
var HUBSPOT_ACTION_LABELS = {
|
|
291
|
+
HUBSPOT_LIST_CONTACTS: "Checking your details",
|
|
292
|
+
HUBSPOT_CREATE_CONTACT: "Saving your details",
|
|
293
|
+
HUBSPOT_UPDATE_CONTACT: "Updating your details",
|
|
294
|
+
HUBSPOT_CREATE_COMPANY: "Saving your company details"
|
|
295
|
+
};
|
|
296
|
+
function connectedToolWork(action) {
|
|
297
|
+
const slug = action.toolName === "COMPOSIO_MULTI_EXECUTE_TOOL" ? action.input.toolSlug : action.toolName;
|
|
298
|
+
if (typeof slug !== "string") return null;
|
|
299
|
+
const detail = HUBSPOT_ACTION_LABELS[slug];
|
|
300
|
+
return detail ? {
|
|
301
|
+
id: action.callId,
|
|
302
|
+
kind: "tool",
|
|
303
|
+
label: "Contact details",
|
|
304
|
+
detail,
|
|
305
|
+
state: "active"
|
|
306
|
+
} : null;
|
|
307
|
+
}
|
|
308
|
+
function toolResultFailed(result) {
|
|
309
|
+
if (result.status !== "completed") return true;
|
|
310
|
+
const output = parseAgentToolResultEnvelope(result.output)?.output ?? result.output;
|
|
311
|
+
if (typeof output !== "object" || output === null || Array.isArray(output))
|
|
312
|
+
return false;
|
|
313
|
+
return "error" in output && Boolean(output.error) || "providerError" in output && Boolean(output.providerError);
|
|
314
|
+
}
|
|
315
|
+
function completeConnectedToolWork(item, result) {
|
|
316
|
+
const failed = toolResultFailed(result);
|
|
317
|
+
return {
|
|
318
|
+
...item,
|
|
319
|
+
state: failed ? "error" : "completed",
|
|
320
|
+
detail: failed ? "Action could not be confirmed" : "Action completed"
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
232
324
|
// src/runtime/search-discovery.ts
|
|
233
325
|
function record(value) {
|
|
234
326
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
@@ -295,63 +387,6 @@ function parseAgentSearchDiscoveryOutput(value) {
|
|
|
295
387
|
} : null;
|
|
296
388
|
}
|
|
297
389
|
|
|
298
|
-
// src/runtime/tool-result-envelope.ts
|
|
299
|
-
var ENVELOPE_KEYS = /* @__PURE__ */ new Set([
|
|
300
|
-
"schemaVersion",
|
|
301
|
-
"output",
|
|
302
|
-
"presentationKinds",
|
|
303
|
-
"ui"
|
|
304
|
-
]);
|
|
305
|
-
function isRecord2(value) {
|
|
306
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
307
|
-
}
|
|
308
|
-
function isJsonValue2(value, seen = /* @__PURE__ */ new Set()) {
|
|
309
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
if (typeof value === "number") return Number.isFinite(value);
|
|
313
|
-
if (typeof value !== "object") return false;
|
|
314
|
-
if (seen.has(value)) return false;
|
|
315
|
-
seen.add(value);
|
|
316
|
-
const valid = Array.isArray(value) ? value.every((item) => isJsonValue2(item, seen)) : Object.entries(value).every(
|
|
317
|
-
([key, item]) => typeof key === "string" && isJsonValue2(item, seen)
|
|
318
|
-
);
|
|
319
|
-
seen.delete(value);
|
|
320
|
-
return valid;
|
|
321
|
-
}
|
|
322
|
-
function decodeEnvelope(value) {
|
|
323
|
-
if (typeof value !== "string") return value;
|
|
324
|
-
try {
|
|
325
|
-
return JSON.parse(value);
|
|
326
|
-
} catch {
|
|
327
|
-
return null;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
function parseAgentToolResultEnvelope(value) {
|
|
331
|
-
const decoded = decodeEnvelope(value);
|
|
332
|
-
if (!isRecord2(decoded)) return null;
|
|
333
|
-
const keys = Object.keys(decoded);
|
|
334
|
-
if (keys.some((key) => !ENVELOPE_KEYS.has(key)) || decoded.schemaVersion !== "webless.tool-result.v1" || !isJsonValue2(decoded.output) || !Array.isArray(decoded.presentationKinds) || decoded.presentationKinds.length < 1 || decoded.presentationKinds.length > 16) {
|
|
335
|
-
return null;
|
|
336
|
-
}
|
|
337
|
-
const presentationKinds = decoded.presentationKinds.flatMap((kind) => {
|
|
338
|
-
if (typeof kind !== "string") return [];
|
|
339
|
-
const normalized = kind.trim();
|
|
340
|
-
return normalized && normalized.length <= 128 ? [normalized] : [];
|
|
341
|
-
});
|
|
342
|
-
if (presentationKinds.length !== decoded.presentationKinds.length) {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
const ui = decoded.ui === void 0 ? void 0 : parseAgentToolUiSurface(decoded.ui);
|
|
346
|
-
if (decoded.ui !== void 0 && !ui) return null;
|
|
347
|
-
return {
|
|
348
|
-
schemaVersion: "webless.tool-result.v1",
|
|
349
|
-
output: decoded.output,
|
|
350
|
-
presentationKinds,
|
|
351
|
-
...ui ? { ui } : {}
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
|
|
355
390
|
// src/react/lib/composer-form.ts
|
|
356
391
|
var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
357
392
|
var MIN_FORM_FIELDS = 2;
|
|
@@ -1046,6 +1081,9 @@ function finalizeSummaryPresentation(result, proposed) {
|
|
|
1046
1081
|
};
|
|
1047
1082
|
}
|
|
1048
1083
|
function presentVisitorToolResult(result, registry = []) {
|
|
1084
|
+
if (result.status === "completed" && toolResultFailed(result)) {
|
|
1085
|
+
result = { ...result, status: "failed" };
|
|
1086
|
+
}
|
|
1049
1087
|
if (result.toolName === "search_discovery" && result.status === "completed") {
|
|
1050
1088
|
const envelope2 = parseAgentToolResultEnvelope(result.output);
|
|
1051
1089
|
const search = parseAgentSearchDiscoveryOutput(
|
|
@@ -1082,7 +1120,7 @@ function presentVisitorToolResult(result, registry = []) {
|
|
|
1082
1120
|
surface: envelope.ui
|
|
1083
1121
|
};
|
|
1084
1122
|
}
|
|
1085
|
-
if (!proposed) {
|
|
1123
|
+
if (!proposed || result.status !== "completed" && proposed.kind !== "summary") {
|
|
1086
1124
|
if (result.status === "failed" || result.status === "rejected") {
|
|
1087
1125
|
return {
|
|
1088
1126
|
id: result.callId,
|
|
@@ -1448,6 +1486,18 @@ function parseChildStreamEvent(value) {
|
|
|
1448
1486
|
return { childStreamPath, type: "subagent.called" };
|
|
1449
1487
|
}
|
|
1450
1488
|
}
|
|
1489
|
+
if (value.type === "actions.requested" && isRecord4(value.data) && Array.isArray(value.data.actions)) {
|
|
1490
|
+
const items = value.data.actions.flatMap((action) => {
|
|
1491
|
+
if (!isRecord4(action) || action.kind !== "tool-call" || typeof action.callId !== "string" || typeof action.toolName !== "string" || !isRecord4(action.input)) return [];
|
|
1492
|
+
const item = connectedToolWork({
|
|
1493
|
+
callId: action.callId,
|
|
1494
|
+
toolName: action.toolName,
|
|
1495
|
+
input: action.input
|
|
1496
|
+
});
|
|
1497
|
+
return item ? [item] : [];
|
|
1498
|
+
});
|
|
1499
|
+
return { type: "actions.requested", items };
|
|
1500
|
+
}
|
|
1451
1501
|
if (value.type !== "action.result" || !isRecord4(value.data)) {
|
|
1452
1502
|
return { type: "other" };
|
|
1453
1503
|
}
|
|
@@ -1469,7 +1519,7 @@ function parseChildStreamEvent(value) {
|
|
|
1469
1519
|
result: {
|
|
1470
1520
|
callId: result.callId,
|
|
1471
1521
|
toolName: result.toolName,
|
|
1472
|
-
status: data.status,
|
|
1522
|
+
status: result.isError === true ? "failed" : data.status,
|
|
1473
1523
|
...Object.hasOwn(result, "output") ? { output: result.output } : {},
|
|
1474
1524
|
...error ? { error } : {}
|
|
1475
1525
|
}
|
|
@@ -1570,6 +1620,7 @@ var SubagentChildStreamCoordinator = class {
|
|
|
1570
1620
|
this.tasks.set(childStreamPath, task);
|
|
1571
1621
|
}
|
|
1572
1622
|
async consume(path, signal) {
|
|
1623
|
+
const workItems = /* @__PURE__ */ new Map();
|
|
1573
1624
|
let streamIndex = 0;
|
|
1574
1625
|
let consecutiveRetries = 0;
|
|
1575
1626
|
let retryDelayMs = INITIAL_RETRY_DELAY_MS;
|
|
@@ -1598,7 +1649,18 @@ var SubagentChildStreamCoordinator = class {
|
|
|
1598
1649
|
this.beginPath(event.childStreamPath);
|
|
1599
1650
|
continue;
|
|
1600
1651
|
}
|
|
1652
|
+
if (event.type === "actions.requested") {
|
|
1653
|
+
for (const item2 of event.items) {
|
|
1654
|
+
workItems.set(item2.id, item2);
|
|
1655
|
+
this.handlers.onWork?.(item2);
|
|
1656
|
+
}
|
|
1657
|
+
continue;
|
|
1658
|
+
}
|
|
1601
1659
|
if (event.type !== "action.result") continue;
|
|
1660
|
+
const item = workItems.get(event.result.callId);
|
|
1661
|
+
if (item) {
|
|
1662
|
+
this.handlers.onWork?.(completeConnectedToolWork(item, event.result));
|
|
1663
|
+
}
|
|
1602
1664
|
this.handlers.onToolResult?.(event.result);
|
|
1603
1665
|
if (event.hasOutput) {
|
|
1604
1666
|
this.handlers.onActionResult?.(event.result.output);
|
|
@@ -1646,7 +1708,7 @@ function emitActionResult(event, handlers) {
|
|
|
1646
1708
|
handlers.onToolResult?.({
|
|
1647
1709
|
callId: result.callId,
|
|
1648
1710
|
toolName: result.toolName,
|
|
1649
|
-
status: event.data.status,
|
|
1711
|
+
status: result.isError ? "failed" : event.data.status,
|
|
1650
1712
|
output: result.output,
|
|
1651
1713
|
...event.data.error ? { error: event.data.error } : {}
|
|
1652
1714
|
});
|
|
@@ -1772,9 +1834,13 @@ function requestedWorkItem(action) {
|
|
|
1772
1834
|
state: "active"
|
|
1773
1835
|
};
|
|
1774
1836
|
}
|
|
1775
|
-
return null;
|
|
1837
|
+
return action.kind === "tool-call" ? connectedToolWork(action) : null;
|
|
1776
1838
|
}
|
|
1777
1839
|
function applyWorkEvent(event, handlers, workItems) {
|
|
1840
|
+
if (event.type === "subagent.event") {
|
|
1841
|
+
applyWorkEvent(event.data.event, handlers, workItems);
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1778
1844
|
if (event.type === "step.started" && workItems.size === 0) {
|
|
1779
1845
|
emitWorkItem(
|
|
1780
1846
|
{
|
|
@@ -1833,6 +1899,15 @@ function applyWorkEvent(event, handlers, workItems) {
|
|
|
1833
1899
|
const { result, status } = event.data;
|
|
1834
1900
|
const current = workItems.get(result.callId);
|
|
1835
1901
|
if (!current) return;
|
|
1902
|
+
if (current.kind === "tool" && result.kind === "tool-result") {
|
|
1903
|
+
emitWorkItem(completeConnectedToolWork(current, {
|
|
1904
|
+
callId: result.callId,
|
|
1905
|
+
toolName: result.toolName,
|
|
1906
|
+
status: result.isError ? "failed" : status,
|
|
1907
|
+
output: result.output
|
|
1908
|
+
}), handlers, workItems);
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1836
1911
|
const failed = status !== "completed" || result.isError === true;
|
|
1837
1912
|
emitWorkItem(
|
|
1838
1913
|
{
|
|
@@ -2344,10 +2419,15 @@ function parseMessage(value) {
|
|
|
2344
2419
|
const result = parseToolResult(value2);
|
|
2345
2420
|
return result?.kind === "search" ? [result] : [];
|
|
2346
2421
|
}) : [];
|
|
2422
|
+
const toolResults = Array.isArray(record2.toolResults) ? record2.toolResults.flatMap((value2) => {
|
|
2423
|
+
const result = parseToolResult(value2);
|
|
2424
|
+
return result && result.kind !== "search" && result.kind !== "input" ? [result] : [];
|
|
2425
|
+
}) : [];
|
|
2347
2426
|
return {
|
|
2348
2427
|
id: record2.id,
|
|
2349
2428
|
role: "agent",
|
|
2350
2429
|
...searchResults.length ? { searchResults } : {},
|
|
2430
|
+
...toolResults.length ? { toolResults } : {},
|
|
2351
2431
|
text: record2.text,
|
|
2352
2432
|
createdAt: record2.createdAt
|
|
2353
2433
|
};
|
|
@@ -2355,7 +2435,7 @@ function parseMessage(value) {
|
|
|
2355
2435
|
function parseToolStep(value) {
|
|
2356
2436
|
if (typeof value !== "object" || value === null) return null;
|
|
2357
2437
|
const record2 = value;
|
|
2358
|
-
if (typeof record2.id !== "string" || record2.kind !== "planning" && record2.kind !== "search" && record2.kind !== "specialist" || typeof record2.label !== "string" || record2.state !== "completed" && record2.state !== "active" && record2.state !== "pending" && record2.state !== "error") {
|
|
2438
|
+
if (typeof record2.id !== "string" || record2.kind !== "planning" && record2.kind !== "search" && record2.kind !== "specialist" && record2.kind !== "tool" || typeof record2.label !== "string" || record2.state !== "completed" && record2.state !== "active" && record2.state !== "pending" && record2.state !== "error") {
|
|
2359
2439
|
return null;
|
|
2360
2440
|
}
|
|
2361
2441
|
return {
|
|
@@ -2416,6 +2496,15 @@ function parseInputRequest(value) {
|
|
|
2416
2496
|
...ui ? { ui } : {}
|
|
2417
2497
|
};
|
|
2418
2498
|
}
|
|
2499
|
+
function parseResultDetails(value) {
|
|
2500
|
+
if (!Array.isArray(value)) return [];
|
|
2501
|
+
return value.slice(0, 6).flatMap((item) => {
|
|
2502
|
+
if (typeof item !== "object" || item === null) return [];
|
|
2503
|
+
const detail = item;
|
|
2504
|
+
if (typeof detail.label !== "string" || typeof detail.value !== "string") return [];
|
|
2505
|
+
return [{ label: detail.label.slice(0, 240), value: detail.value.slice(0, 240) }];
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
2419
2508
|
function parseToolResult(value) {
|
|
2420
2509
|
if (typeof value !== "object" || value === null) return null;
|
|
2421
2510
|
const record2 = value;
|
|
@@ -2451,6 +2540,7 @@ function parseToolResult(value) {
|
|
|
2451
2540
|
status: record2.status,
|
|
2452
2541
|
kind: "entity",
|
|
2453
2542
|
title: record2.title,
|
|
2543
|
+
details: parseResultDetails(record2.details),
|
|
2454
2544
|
...typeof record2.description === "string" ? { description: record2.description } : {}
|
|
2455
2545
|
};
|
|
2456
2546
|
}
|
|
@@ -2494,6 +2584,7 @@ function parseToolResult(value) {
|
|
|
2494
2584
|
status: record2.status,
|
|
2495
2585
|
kind: "summary",
|
|
2496
2586
|
title: record2.title,
|
|
2587
|
+
details: parseResultDetails(record2.details),
|
|
2497
2588
|
...typeof record2.description === "string" ? { description: record2.description } : {}
|
|
2498
2589
|
};
|
|
2499
2590
|
}
|
|
@@ -2650,14 +2741,15 @@ function isNearDuplicateAssistantText(left, right) {
|
|
|
2650
2741
|
shorter.slice(0, Math.floor(shorter.length * 0.85))
|
|
2651
2742
|
);
|
|
2652
2743
|
}
|
|
2653
|
-
function appendAgentTurnMessage(messages, displayText, searchResults = []) {
|
|
2744
|
+
function appendAgentTurnMessage(messages, displayText, searchResults = [], toolResults = []) {
|
|
2654
2745
|
const trimmed = displayText.trim();
|
|
2655
|
-
if (!trimmed && searchResults.length === 0) return [...messages];
|
|
2746
|
+
if (!trimmed && searchResults.length === 0 && toolResults.length === 0) return [...messages];
|
|
2656
2747
|
const agentMessage = {
|
|
2657
2748
|
id: `agent-${Date.now()}`,
|
|
2658
2749
|
role: "agent",
|
|
2659
2750
|
text: trimmed,
|
|
2660
2751
|
...searchResults.length ? { searchResults } : {},
|
|
2752
|
+
...toolResults.length ? { toolResults } : {},
|
|
2661
2753
|
createdAt: Date.now()
|
|
2662
2754
|
};
|
|
2663
2755
|
const last = messages.at(-1);
|
|
@@ -3039,10 +3131,11 @@ function useAgentChat({
|
|
|
3039
3131
|
messages: appendAgentTurnMessage(
|
|
3040
3132
|
prev.messages,
|
|
3041
3133
|
displayText,
|
|
3042
|
-
(prev.toolResults ?? []).filter((result) => result.kind === "search")
|
|
3134
|
+
(prev.toolResults ?? []).filter((result) => result.kind === "search"),
|
|
3135
|
+
(prev.toolResults ?? []).filter((result) => result.kind !== "search" && result.kind !== "input")
|
|
3043
3136
|
),
|
|
3044
3137
|
toolResults: (prev.toolResults ?? []).filter(
|
|
3045
|
-
(result) => result.kind
|
|
3138
|
+
(result) => result.kind === "input"
|
|
3046
3139
|
),
|
|
3047
3140
|
toolSteps: completeActivePlanning(prev.toolSteps),
|
|
3048
3141
|
streamingText: "",
|
|
@@ -3104,16 +3197,18 @@ function useAgentChat({
|
|
|
3104
3197
|
const submit = useCallback(
|
|
3105
3198
|
async (visitorText, options) => {
|
|
3106
3199
|
const trimmed = visitorText.trim();
|
|
3107
|
-
|
|
3200
|
+
const outgoing = options?.runtimeText ?? visitorText;
|
|
3201
|
+
if (!outgoing.trim()) return null;
|
|
3108
3202
|
const chatResponse = chatInputResponseForText(
|
|
3109
3203
|
state.pendingInputs ?? [],
|
|
3110
|
-
|
|
3204
|
+
outgoing.trim()
|
|
3111
3205
|
);
|
|
3112
3206
|
if (chatResponse) {
|
|
3113
3207
|
const visitorMessage2 = {
|
|
3114
3208
|
id: `visitor-${Date.now()}`,
|
|
3115
3209
|
role: "visitor",
|
|
3116
3210
|
text: trimmed,
|
|
3211
|
+
...outgoing !== trimmed ? { runtimeText: outgoing } : {},
|
|
3117
3212
|
createdAt: Date.now()
|
|
3118
3213
|
};
|
|
3119
3214
|
if (runRef.current) {
|
|
@@ -3153,7 +3248,6 @@ function useAgentChat({
|
|
|
3153
3248
|
const controller = new AbortController();
|
|
3154
3249
|
runRef.current = controller;
|
|
3155
3250
|
const booking = pendingBookingRef.current;
|
|
3156
|
-
const outgoing = options?.runtimeText ?? visitorText;
|
|
3157
3251
|
const runtimeText = booking ? `${visitorBookingPrefix(booking)}
|
|
3158
3252
|
|
|
3159
3253
|
${outgoing}` : outgoing;
|
|
@@ -4155,6 +4249,10 @@ function joinLabels(labels) {
|
|
|
4155
4249
|
return `${labels.slice(0, -1).join(", ")} and ${labels.at(-1) ?? ""}`;
|
|
4156
4250
|
}
|
|
4157
4251
|
function workSummary(steps, failed, brandLabel) {
|
|
4252
|
+
const activeTool = [...steps].reverse().find(
|
|
4253
|
+
(step) => step.kind === "tool" && step.state === "active"
|
|
4254
|
+
);
|
|
4255
|
+
if (activeTool) return activeTool.detail ?? "Working on your request";
|
|
4158
4256
|
const activeSpecialists = steps.filter(
|
|
4159
4257
|
(step) => step.kind === "specialist" && step.state === "active"
|
|
4160
4258
|
);
|
|
@@ -4475,11 +4573,15 @@ function Composer({
|
|
|
4475
4573
|
const trimmed = value.trim();
|
|
4476
4574
|
if (!trimmed || disabled) return;
|
|
4477
4575
|
const shareDismissal = savedForm && !draft.dismissalSent;
|
|
4478
|
-
|
|
4479
|
-
|
|
4576
|
+
if (shareDismissal) {
|
|
4577
|
+
onSubmit?.(trimmed, {
|
|
4578
|
+
runtimeText: `I'd like to keep chatting without sharing the requested details for now. Please don't ask for them again unless I choose to proceed with something that needs them.
|
|
4480
4579
|
|
|
4481
|
-
${trimmed}`
|
|
4482
|
-
|
|
4580
|
+
${trimmed}`
|
|
4581
|
+
});
|
|
4582
|
+
} else {
|
|
4583
|
+
onSubmit?.(trimmed);
|
|
4584
|
+
}
|
|
4483
4585
|
if (shareDismissal)
|
|
4484
4586
|
setDraft((current) => ({ ...current, dismissalSent: true }));
|
|
4485
4587
|
setValue("");
|
|
@@ -4496,7 +4598,9 @@ ${trimmed}` : trimmed
|
|
|
4496
4598
|
if (control instanceof HTMLElement) control.focus();
|
|
4497
4599
|
return;
|
|
4498
4600
|
}
|
|
4499
|
-
onSubmit?.(
|
|
4601
|
+
onSubmit?.("", {
|
|
4602
|
+
runtimeText: formatComposerFormMessage(activeForm, draft.values)
|
|
4603
|
+
});
|
|
4500
4604
|
setDraft((current) => ({
|
|
4501
4605
|
...current,
|
|
4502
4606
|
values: emptyValues(activeForm),
|
|
@@ -4760,25 +4864,11 @@ function SearchReferences({
|
|
|
4760
4864
|
});
|
|
4761
4865
|
if (!sources.length && !actions.length) return null;
|
|
4762
4866
|
return /* @__PURE__ */ jsxs6("div", { className: "search-references", children: [
|
|
4763
|
-
sources.length > 0 ? /* @__PURE__ */ jsxs6("
|
|
4764
|
-
/* @__PURE__ */ jsxs6("
|
|
4765
|
-
"Sources",
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
{
|
|
4769
|
-
viewBox: "0 0 24 24",
|
|
4770
|
-
width: "14",
|
|
4771
|
-
height: "14",
|
|
4772
|
-
fill: "none",
|
|
4773
|
-
stroke: "currentColor",
|
|
4774
|
-
strokeWidth: "1.75",
|
|
4775
|
-
"aria-hidden": "true",
|
|
4776
|
-
children: [
|
|
4777
|
-
/* @__PURE__ */ jsx6("circle", { cx: "12", cy: "12", r: "9" }),
|
|
4778
|
-
/* @__PURE__ */ jsx6("path", { d: "M12 11v6M12 7v1" })
|
|
4779
|
-
]
|
|
4780
|
-
}
|
|
4781
|
-
) })
|
|
4867
|
+
sources.length > 0 ? /* @__PURE__ */ jsxs6("details", { className: "search-references__disclosure", "aria-label": "Sources", children: [
|
|
4868
|
+
/* @__PURE__ */ jsxs6("summary", { className: "search-references__heading", children: [
|
|
4869
|
+
"Sources (",
|
|
4870
|
+
sources.length,
|
|
4871
|
+
")"
|
|
4782
4872
|
] }),
|
|
4783
4873
|
/* @__PURE__ */ jsx6("ul", { className: "search-references__list", children: sources.map((source) => {
|
|
4784
4874
|
const content = /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
@@ -4862,7 +4952,23 @@ function calendarCells(year, month) {
|
|
|
4862
4952
|
function BookingCardLoader() {
|
|
4863
4953
|
return /* @__PURE__ */ jsx7("section", { className: "booking-card", "aria-label": "Book a meeting", children: /* @__PURE__ */ jsx7("p", { className: "booking-card__loading", role: "status", children: "Finding available times\u2026" }) });
|
|
4864
4954
|
}
|
|
4865
|
-
function BookingCard({
|
|
4955
|
+
function BookingCard(props) {
|
|
4956
|
+
if (!props.readOnly) return /* @__PURE__ */ jsx7(InteractiveBookingCard, { ...props });
|
|
4957
|
+
return /* @__PURE__ */ jsxs7("section", { className: "booking-card", "aria-label": "Recorded available times", children: [
|
|
4958
|
+
/* @__PURE__ */ jsx7("p", { className: "booking-card__title", children: "Available times offered" }),
|
|
4959
|
+
props.offer.slots.length ? /* @__PURE__ */ jsx7("ul", { children: props.offer.slots.map((slot, index) => {
|
|
4960
|
+
const eventType = props.offer.eventTypes.find(
|
|
4961
|
+
(item) => item.uri === slot.eventTypeUri
|
|
4962
|
+
);
|
|
4963
|
+
const label = Number.isFinite(Date.parse(slot.startTime)) ? formatSlotLabel(slot.startTime) : "Time unavailable";
|
|
4964
|
+
return /* @__PURE__ */ jsxs7("li", { children: [
|
|
4965
|
+
eventType ? `${eventType.name} \xB7 ` : "",
|
|
4966
|
+
label
|
|
4967
|
+
] }, `${slot.eventTypeUri ?? ""}:${slot.startTime}:${index}`);
|
|
4968
|
+
}) }) : /* @__PURE__ */ jsx7("p", { children: "No available times were recorded." })
|
|
4969
|
+
] });
|
|
4970
|
+
}
|
|
4971
|
+
function InteractiveBookingCard({
|
|
4866
4972
|
disabled = false,
|
|
4867
4973
|
offer,
|
|
4868
4974
|
onBook
|
|
@@ -5228,6 +5334,7 @@ function MessageBubble({
|
|
|
5228
5334
|
message,
|
|
5229
5335
|
brandLogoUrl,
|
|
5230
5336
|
bookingDisabled = false,
|
|
5337
|
+
bookingReadOnly = false,
|
|
5231
5338
|
offer,
|
|
5232
5339
|
onBook
|
|
5233
5340
|
}) {
|
|
@@ -5245,6 +5352,7 @@ function MessageBubble({
|
|
|
5245
5352
|
offers.length > 0 ? sanitizeBookingOfferCopy(visibleText) : looksLikeBookingAvailabilityDump(visibleText) ? sanitizeBookingOfferCopy(visibleText) : visibleText || (isStreaming ? "" : message.text)
|
|
5246
5353
|
);
|
|
5247
5354
|
if (message.role === "visitor") {
|
|
5355
|
+
if (!message.text.trim()) return null;
|
|
5248
5356
|
return /* @__PURE__ */ jsx8("article", { className: "message-bubble message-bubble--visitor", children: /* @__PURE__ */ jsx8("p", { className: "message-bubble__text", children: message.text }) });
|
|
5249
5357
|
}
|
|
5250
5358
|
const citations = message.citations ?? [];
|
|
@@ -5263,8 +5371,8 @@ function MessageBubble({
|
|
|
5263
5371
|
children: displayText
|
|
5264
5372
|
}
|
|
5265
5373
|
),
|
|
5266
|
-
/* @__PURE__ */ jsx8(SearchReferences, { results: message.searchResults ?? [] }),
|
|
5267
|
-
citations.length > 0 ? /* @__PURE__ */ jsx8("ul", { className: "message-bubble__sources", "aria-label": "Sources", children: citations.map((citation) => /* @__PURE__ */ jsx8("li", { children: /* @__PURE__ */ jsxs8("a", { href: citation.url, target: "_blank", rel: "noreferrer", children: [
|
|
5374
|
+
!isStreaming ? /* @__PURE__ */ jsx8(SearchReferences, { results: message.searchResults ?? [] }) : null,
|
|
5375
|
+
!isStreaming && citations.length > 0 ? /* @__PURE__ */ jsx8("ul", { className: "message-bubble__sources", "aria-label": "Sources", children: citations.map((citation) => /* @__PURE__ */ jsx8("li", { children: /* @__PURE__ */ jsxs8("a", { href: citation.url, target: "_blank", rel: "noreferrer", children: [
|
|
5268
5376
|
/* @__PURE__ */ jsx8(
|
|
5269
5377
|
"span",
|
|
5270
5378
|
{
|
|
@@ -5276,6 +5384,7 @@ function MessageBubble({
|
|
|
5276
5384
|
/* @__PURE__ */ jsx8("span", { children: citation.label })
|
|
5277
5385
|
] }) }, citation.id)) }) : null
|
|
5278
5386
|
] });
|
|
5387
|
+
if (!displayText && !message.searchResults?.length && offers.length === 0) return null;
|
|
5279
5388
|
return /* @__PURE__ */ jsxs8("article", { className: "message-bubble message-bubble--agent", children: [
|
|
5280
5389
|
displayText || message.searchResults?.length ? showBrandLogo ? /* @__PURE__ */ jsxs8("div", { className: "message-bubble__agent-row", children: [
|
|
5281
5390
|
/* @__PURE__ */ jsx8("span", { className: "message-bubble__agent-avatar", "aria-hidden": "true", children: /* @__PURE__ */ jsx8(
|
|
@@ -5294,6 +5403,7 @@ function MessageBubble({
|
|
|
5294
5403
|
BookingCard,
|
|
5295
5404
|
{
|
|
5296
5405
|
disabled: bookingDisabled,
|
|
5406
|
+
readOnly: bookingReadOnly,
|
|
5297
5407
|
offer: nextOffer,
|
|
5298
5408
|
onBook
|
|
5299
5409
|
},
|
|
@@ -5841,6 +5951,7 @@ function CollectionResultCard({
|
|
|
5841
5951
|
{
|
|
5842
5952
|
className: `collection-result-card tool-result-card tool-result-card--${result.status}`,
|
|
5843
5953
|
"aria-label": result.title,
|
|
5954
|
+
role: result.status === "completed" ? "status" : "alert",
|
|
5844
5955
|
children: [
|
|
5845
5956
|
/* @__PURE__ */ jsxs12("div", { className: "tool-result-card__heading", children: [
|
|
5846
5957
|
/* @__PURE__ */ jsx12("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
|
|
@@ -5861,35 +5972,48 @@ function CollectionResultCard({
|
|
|
5861
5972
|
}
|
|
5862
5973
|
|
|
5863
5974
|
// src/react/components/EntityResultCard/EntityResultCard.tsx
|
|
5864
|
-
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
5975
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
5865
5976
|
function EntityResultCard({
|
|
5866
5977
|
result
|
|
5867
5978
|
}) {
|
|
5979
|
+
const compact = !result.description && !result.details?.length && !result.links?.length;
|
|
5980
|
+
const collapsible = result.status === "completed" && Boolean(result.details?.length) && !result.links?.length;
|
|
5981
|
+
const heading = /* @__PURE__ */ jsxs13("span", { className: "tool-result-card__heading", children: [
|
|
5982
|
+
/* @__PURE__ */ jsx13("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
|
|
5983
|
+
/* @__PURE__ */ jsx13("strong", { children: result.title })
|
|
5984
|
+
] });
|
|
5985
|
+
const content = /* @__PURE__ */ jsxs13(Fragment3, { children: [
|
|
5986
|
+
result.description ? /* @__PURE__ */ jsx13("p", { children: result.description }) : null,
|
|
5987
|
+
result.details?.length ? /* @__PURE__ */ jsx13("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs13("div", { children: [
|
|
5988
|
+
/* @__PURE__ */ jsx13("dt", { children: detail.label }),
|
|
5989
|
+
/* @__PURE__ */ jsx13("dd", { children: detail.value })
|
|
5990
|
+
] }, `${detail.label}:${detail.value}`)) }) : null,
|
|
5991
|
+
result.links?.length ? /* @__PURE__ */ jsx13("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx13(
|
|
5992
|
+
"a",
|
|
5993
|
+
{
|
|
5994
|
+
href: link.href,
|
|
5995
|
+
target: "_blank",
|
|
5996
|
+
rel: "noreferrer",
|
|
5997
|
+
children: link.label
|
|
5998
|
+
},
|
|
5999
|
+
link.href
|
|
6000
|
+
)) }) : null
|
|
6001
|
+
] });
|
|
6002
|
+
if (collapsible) {
|
|
6003
|
+
return /* @__PURE__ */ jsxs13("details", { className: "entity-result-card tool-result-card entity-result-card--disclosure", children: [
|
|
6004
|
+
/* @__PURE__ */ jsx13("summary", { children: /* @__PURE__ */ jsx13("span", { role: "status", children: heading }) }),
|
|
6005
|
+
content
|
|
6006
|
+
] });
|
|
6007
|
+
}
|
|
5868
6008
|
return /* @__PURE__ */ jsxs13(
|
|
5869
6009
|
"section",
|
|
5870
6010
|
{
|
|
5871
|
-
className: `entity-result-card tool-result-card tool-result-card--${result.status}`,
|
|
6011
|
+
className: `entity-result-card tool-result-card tool-result-card--${result.status}${compact ? " entity-result-card--compact" : ""}`,
|
|
5872
6012
|
"aria-label": result.title,
|
|
6013
|
+
role: result.status === "completed" ? "status" : "alert",
|
|
5873
6014
|
children: [
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
/* @__PURE__ */ jsx13("strong", { children: result.title })
|
|
5877
|
-
] }),
|
|
5878
|
-
result.description ? /* @__PURE__ */ jsx13("p", { children: result.description }) : null,
|
|
5879
|
-
result.details?.length ? /* @__PURE__ */ jsx13("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs13("div", { children: [
|
|
5880
|
-
/* @__PURE__ */ jsx13("dt", { children: detail.label }),
|
|
5881
|
-
/* @__PURE__ */ jsx13("dd", { children: detail.value })
|
|
5882
|
-
] }, `${detail.label}:${detail.value}`)) }) : null,
|
|
5883
|
-
result.links?.length ? /* @__PURE__ */ jsx13("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx13(
|
|
5884
|
-
"a",
|
|
5885
|
-
{
|
|
5886
|
-
href: link.href,
|
|
5887
|
-
target: "_blank",
|
|
5888
|
-
rel: "noreferrer",
|
|
5889
|
-
children: link.label
|
|
5890
|
-
},
|
|
5891
|
-
link.href
|
|
5892
|
-
)) }) : null
|
|
6015
|
+
heading,
|
|
6016
|
+
content
|
|
5893
6017
|
]
|
|
5894
6018
|
}
|
|
5895
6019
|
);
|
|
@@ -5938,6 +6062,7 @@ function ToolResultCard({
|
|
|
5938
6062
|
{
|
|
5939
6063
|
className: `tool-result-card tool-result-card--${result.status}`,
|
|
5940
6064
|
"aria-label": result.title,
|
|
6065
|
+
role: result.status === "completed" ? "status" : "alert",
|
|
5941
6066
|
children: [
|
|
5942
6067
|
/* @__PURE__ */ jsxs15("div", { className: "tool-result-card__heading", children: [
|
|
5943
6068
|
/* @__PURE__ */ jsx15("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
|
|
@@ -5999,7 +6124,7 @@ function isRenderableVisitorToolResult(result) {
|
|
|
5999
6124
|
}
|
|
6000
6125
|
|
|
6001
6126
|
// src/react/components/AgentRail/AgentRail.tsx
|
|
6002
|
-
import { Fragment as
|
|
6127
|
+
import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
6003
6128
|
function MinimizeIcon() {
|
|
6004
6129
|
return /* @__PURE__ */ jsx17("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx17(
|
|
6005
6130
|
"path",
|
|
@@ -6101,6 +6226,9 @@ function AgentRail({
|
|
|
6101
6226
|
const railRef = useRef6(null);
|
|
6102
6227
|
const overlayRef = useRef6(null);
|
|
6103
6228
|
const transcriptRef = useRef6(null);
|
|
6229
|
+
const responseRef = useRef6(null);
|
|
6230
|
+
const threadRef = useRef6(null);
|
|
6231
|
+
const lastScrolledVisitorIdRef = useRef6(void 0);
|
|
6104
6232
|
const pinnedToBottomRef = useRef6(true);
|
|
6105
6233
|
const smoothScrollToLatestRef = useRef6(false);
|
|
6106
6234
|
const lockedTranscriptScrollTopRef = useRef6(null);
|
|
@@ -6124,7 +6252,7 @@ function AgentRail({
|
|
|
6124
6252
|
const activeVisitorToolInput = [...visitorToolResults].reverse().find((result) => result.kind === "input");
|
|
6125
6253
|
const visibleVisitorToolResults = activeVisitorToolInput ? [activeVisitorToolInput] : visitorToolResults;
|
|
6126
6254
|
const activityActive = state.toolSteps.some((step) => step.state === "active");
|
|
6127
|
-
const showActivity = state.toolSteps.length > 0 &&
|
|
6255
|
+
const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && activityActive;
|
|
6128
6256
|
const hasVisitorMessages2 = state.messages.some(
|
|
6129
6257
|
(message) => message.role === "visitor"
|
|
6130
6258
|
);
|
|
@@ -6153,7 +6281,7 @@ function AgentRail({
|
|
|
6153
6281
|
}
|
|
6154
6282
|
}
|
|
6155
6283
|
const lastIsAgent = lastMessage?.role === "agent";
|
|
6156
|
-
const showMessageActions = state.phase === "complete" && lastIsAgent && hasVisitorMessages2;
|
|
6284
|
+
const showMessageActions = state.phase === "complete" && lastIsAgent && hasVisitorMessages2 && Boolean(hideToolCardFences(lastMessage.text).trim());
|
|
6157
6285
|
const streamingMessage = state.phase === "streaming" && state.streamingText && !lastIsAgent ? {
|
|
6158
6286
|
createdAt: 0,
|
|
6159
6287
|
id: "streaming-response",
|
|
@@ -6183,15 +6311,21 @@ function AgentRail({
|
|
|
6183
6311
|
hasPendingConfirmation,
|
|
6184
6312
|
enabled: lastIsAgent && !isBusy
|
|
6185
6313
|
});
|
|
6314
|
+
const latestResultId = [
|
|
6315
|
+
...visibleMessages.flatMap(
|
|
6316
|
+
(message) => message.role === "agent" ? message.toolResults ?? [] : []
|
|
6317
|
+
),
|
|
6318
|
+
...visibleVisitorToolResults
|
|
6319
|
+
].reverse().find((result) => result.kind !== "input")?.id;
|
|
6186
6320
|
const receiptSteps = answerReceipt && state.toolSteps.length > 0 ? state.toolSteps : void 0;
|
|
6187
6321
|
useEffect6(() => {
|
|
6188
6322
|
if (state.phase !== "complete") {
|
|
6189
6323
|
setReceiptOpen(false);
|
|
6190
6324
|
}
|
|
6191
6325
|
}, [state.phase]);
|
|
6192
|
-
function handleSubmit(message) {
|
|
6326
|
+
function handleSubmit(message, options) {
|
|
6193
6327
|
setReceiptOpen(false);
|
|
6194
|
-
onSubmit?.(message);
|
|
6328
|
+
onSubmit?.(message, options);
|
|
6195
6329
|
}
|
|
6196
6330
|
function handleRegenerate() {
|
|
6197
6331
|
setReceiptOpen(false);
|
|
@@ -6205,15 +6339,31 @@ function AgentRail({
|
|
|
6205
6339
|
setReceiptOpen(false);
|
|
6206
6340
|
onFollowUpSelect?.(label);
|
|
6207
6341
|
}
|
|
6342
|
+
const latestVisitorId = visibleMessages[lastVisitorIndex]?.id;
|
|
6208
6343
|
useEffect6(() => {
|
|
6209
6344
|
const node = transcriptRef.current;
|
|
6210
6345
|
if (!node) return;
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
node.scrollTop = node.scrollHeight;
|
|
6346
|
+
if (latestVisitorId !== lastScrolledVisitorIdRef.current) {
|
|
6347
|
+
lastScrolledVisitorIdRef.current = latestVisitorId;
|
|
6348
|
+
pinnedToBottomRef.current = true;
|
|
6215
6349
|
}
|
|
6350
|
+
const followResponse = () => {
|
|
6351
|
+
if (node.clientHeight === 0 || !pinnedToBottomRef.current) return;
|
|
6352
|
+
const bottom = Math.max(0, node.scrollHeight - node.clientHeight);
|
|
6353
|
+
const response = responseRef.current;
|
|
6354
|
+
const responseTop = response ? node.scrollTop + response.getBoundingClientRect().top - node.getBoundingClientRect().top : bottom;
|
|
6355
|
+
node.scrollTop = Math.max(node.scrollTop, Math.min(bottom, responseTop));
|
|
6356
|
+
const pinned = bottom - node.scrollTop < 48;
|
|
6357
|
+
pinnedToBottomRef.current = pinned;
|
|
6358
|
+
setShowJumpToLatest(!pinned);
|
|
6359
|
+
};
|
|
6360
|
+
followResponse();
|
|
6361
|
+
const observer = new ResizeObserver(followResponse);
|
|
6362
|
+
observer.observe(node);
|
|
6363
|
+
if (threadRef.current) observer.observe(threadRef.current);
|
|
6364
|
+
return () => observer.disconnect();
|
|
6216
6365
|
}, [
|
|
6366
|
+
latestVisitorId,
|
|
6217
6367
|
state.messages,
|
|
6218
6368
|
state.toolSteps,
|
|
6219
6369
|
state.streamingText,
|
|
@@ -6234,18 +6384,6 @@ function AgentRail({
|
|
|
6234
6384
|
handleScroll();
|
|
6235
6385
|
return () => node.removeEventListener("scroll", handleScroll);
|
|
6236
6386
|
}, []);
|
|
6237
|
-
useEffect6(() => {
|
|
6238
|
-
const node = transcriptRef.current;
|
|
6239
|
-
if (!node) return;
|
|
6240
|
-
const observer = new ResizeObserver(() => {
|
|
6241
|
-
if (node.clientHeight === 0) return;
|
|
6242
|
-
if (pinnedToBottomRef.current) {
|
|
6243
|
-
node.scrollTo({ top: node.scrollHeight, behavior: "instant" });
|
|
6244
|
-
}
|
|
6245
|
-
});
|
|
6246
|
-
observer.observe(node);
|
|
6247
|
-
return () => observer.disconnect();
|
|
6248
|
-
}, []);
|
|
6249
6387
|
useEffect6(() => {
|
|
6250
6388
|
if (!receiptOpen) {
|
|
6251
6389
|
lockedTranscriptScrollTopRef.current = null;
|
|
@@ -6362,7 +6500,7 @@ function AgentRail({
|
|
|
6362
6500
|
) : null
|
|
6363
6501
|
] })
|
|
6364
6502
|
] }) }),
|
|
6365
|
-
/* @__PURE__ */ jsx17("div", { ref: transcriptRef, className: "agent-rail__transcript", children: /* @__PURE__ */ jsxs16("div", { className: "agent-rail__thread", children: [
|
|
6503
|
+
/* @__PURE__ */ jsx17("div", { ref: transcriptRef, className: "agent-rail__transcript", children: /* @__PURE__ */ jsxs16("div", { ref: threadRef, className: "agent-rail__thread", children: [
|
|
6366
6504
|
!hasVisitorMessages2 ? /* @__PURE__ */ jsxs16("section", { className: "agent-rail__welcome", "aria-label": "Welcome", children: [
|
|
6367
6505
|
greeting?.role === "agent" ? /* @__PURE__ */ jsx17(
|
|
6368
6506
|
MessageBubble,
|
|
@@ -6409,59 +6547,68 @@ function AgentRail({
|
|
|
6409
6547
|
request.requestId
|
|
6410
6548
|
))
|
|
6411
6549
|
] }) : null,
|
|
6412
|
-
visibleMessages.map((message, index) => /* @__PURE__ */ jsxs16(
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6550
|
+
visibleMessages.map((message, index) => /* @__PURE__ */ jsxs16(
|
|
6551
|
+
"div",
|
|
6552
|
+
{
|
|
6553
|
+
ref: index === lastVisitorIndex + 1 ? responseRef : void 0,
|
|
6554
|
+
className: "agent-rail__turn-block",
|
|
6555
|
+
children: [
|
|
6556
|
+
message.role === "agent" ? message.toolResults?.map((result) => /* @__PURE__ */ jsx17(VisitorToolResultView, { result }, result.id)) : null,
|
|
6557
|
+
/* @__PURE__ */ jsx17(
|
|
6558
|
+
MessageBubble,
|
|
6559
|
+
{
|
|
6560
|
+
message,
|
|
6561
|
+
bookingDisabled: isBusy,
|
|
6562
|
+
brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
|
|
6563
|
+
offer: index === lastAgentIndex ? state.pendingOffer : void 0,
|
|
6564
|
+
onBook
|
|
6565
|
+
}
|
|
6566
|
+
),
|
|
6567
|
+
index === lastAgentIndex && showMessageActions && message.role === "agent" ? /* @__PURE__ */ jsx17(
|
|
6568
|
+
MessageActions,
|
|
6569
|
+
{
|
|
6570
|
+
answeredAt: message.createdAt,
|
|
6571
|
+
copyText: hideToolCardFences(message.text).trim() || message.text,
|
|
6572
|
+
readAloud,
|
|
6573
|
+
receiptSteps,
|
|
6574
|
+
onOpenReceipt: receiptSteps ? openReceipt : void 0,
|
|
6575
|
+
onRegenerate: onRegenerate ? handleRegenerate : void 0,
|
|
6576
|
+
onFeedback: onFeedback ? (rating) => onFeedback(rating, message) : void 0
|
|
6577
|
+
}
|
|
6578
|
+
) : null,
|
|
6579
|
+
index === lastVisitorIndex ? /* @__PURE__ */ jsxs16(Fragment4, { children: [
|
|
6580
|
+
showActivity ? /* @__PURE__ */ jsx17(
|
|
6581
|
+
AgentActivityBubble,
|
|
6582
|
+
{
|
|
6583
|
+
brandLabel: resolvedBrandLabel,
|
|
6584
|
+
brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
|
|
6585
|
+
failed: state.phase === "error",
|
|
6586
|
+
steps: state.toolSteps
|
|
6587
|
+
}
|
|
6588
|
+
) : null,
|
|
6589
|
+
visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx17(
|
|
6590
|
+
VisitorToolResultView,
|
|
6591
|
+
{
|
|
6592
|
+
result,
|
|
6593
|
+
disabled: semanticSurfaceDisabled,
|
|
6594
|
+
onToolInput
|
|
6595
|
+
},
|
|
6596
|
+
result.id
|
|
6597
|
+
)),
|
|
6598
|
+
pendingInputRequests.slice(0, 1).map((request) => /* @__PURE__ */ jsx17(
|
|
6599
|
+
HumanInputCard,
|
|
6600
|
+
{
|
|
6601
|
+
request,
|
|
6602
|
+
onRespond: onInputResponse
|
|
6603
|
+
},
|
|
6604
|
+
request.requestId
|
|
6605
|
+
))
|
|
6606
|
+
] }) : null
|
|
6607
|
+
]
|
|
6608
|
+
},
|
|
6609
|
+
message.id
|
|
6610
|
+
)),
|
|
6611
|
+
streamingMessage ? /* @__PURE__ */ jsx17("div", { ref: responseRef, children: /* @__PURE__ */ jsx17(
|
|
6465
6612
|
MessageBubble,
|
|
6466
6613
|
{
|
|
6467
6614
|
message: streamingMessage,
|
|
@@ -6470,7 +6617,7 @@ function AgentRail({
|
|
|
6470
6617
|
offer: state.pendingOffer,
|
|
6471
6618
|
onBook
|
|
6472
6619
|
}
|
|
6473
|
-
) : null,
|
|
6620
|
+
) }) : null,
|
|
6474
6621
|
waitingForBooking ? /* @__PURE__ */ jsx17(BookingCardLoader, {}) : null,
|
|
6475
6622
|
state.error ? /* @__PURE__ */ jsxs16("section", { className: "agent-rail__error", role: "alert", children: [
|
|
6476
6623
|
/* @__PURE__ */ jsxs16("div", { children: [
|
|
@@ -6511,7 +6658,7 @@ function AgentRail({
|
|
|
6511
6658
|
placeholder: composerPlaceholder,
|
|
6512
6659
|
onSubmit: handleSubmit
|
|
6513
6660
|
},
|
|
6514
|
-
state.messages.find((message) => message.role === "visitor")?.id ?? "empty"
|
|
6661
|
+
`${state.messages.find((message) => message.role === "visitor")?.id ?? "empty"}:${latestResultId ?? ""}`
|
|
6515
6662
|
),
|
|
6516
6663
|
poweredByLabel ? /* @__PURE__ */ jsx17("div", { className: "agent-rail__footer", children: /* @__PURE__ */ jsx17("p", { children: /* @__PURE__ */ jsx17("span", { children: poweredByLabel }) }) }) : null
|
|
6517
6664
|
] })
|
|
@@ -6533,7 +6680,7 @@ function AgentRail({
|
|
|
6533
6680
|
}
|
|
6534
6681
|
|
|
6535
6682
|
// src/react/components/AssistEdgeTab/AssistEdgeTab.tsx
|
|
6536
|
-
import { Fragment as
|
|
6683
|
+
import { Fragment as Fragment5, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6537
6684
|
function SparklesIcon() {
|
|
6538
6685
|
return /* @__PURE__ */ jsxs17(
|
|
6539
6686
|
"svg",
|
|
@@ -6666,7 +6813,7 @@ function AssistEdgeTab({
|
|
|
6666
6813
|
tabIndex: visible ? 0 : -1,
|
|
6667
6814
|
onClick: onOpen,
|
|
6668
6815
|
children: [
|
|
6669
|
-
mobile ? /* @__PURE__ */ jsxs17(
|
|
6816
|
+
mobile ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
6670
6817
|
/* @__PURE__ */ jsxs17(
|
|
6671
6818
|
"span",
|
|
6672
6819
|
{
|
|
@@ -6689,7 +6836,7 @@ function AssistEdgeTab({
|
|
|
6689
6836
|
}
|
|
6690
6837
|
),
|
|
6691
6838
|
/* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__label", children: visibleLabel })
|
|
6692
|
-
] }) : variant === "outline" ? /* @__PURE__ */ jsxs17(
|
|
6839
|
+
] }) : variant === "outline" ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
6693
6840
|
/* @__PURE__ */ jsxs17("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
|
|
6694
6841
|
/* @__PURE__ */ jsx18(TabMarkIcon, { customIconUrl }),
|
|
6695
6842
|
showLogo ? /* @__PURE__ */ jsx18(
|
|
@@ -6707,12 +6854,12 @@ function AssistEdgeTab({
|
|
|
6707
6854
|
/* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__label", children: visibleLabel }),
|
|
6708
6855
|
/* @__PURE__ */ jsx18(ChevronDownIcon2, {})
|
|
6709
6856
|
] }) : null,
|
|
6710
|
-
variant === "ask" ? /* @__PURE__ */ jsxs17(
|
|
6857
|
+
variant === "ask" ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
6711
6858
|
/* @__PURE__ */ jsx18(ChevronLeftIcon, {}),
|
|
6712
6859
|
/* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__label", children: visibleLabel }),
|
|
6713
6860
|
/* @__PURE__ */ jsx18(DragDots, {})
|
|
6714
6861
|
] }) : null,
|
|
6715
|
-
variant === "fill" ? /* @__PURE__ */ jsxs17(
|
|
6862
|
+
variant === "fill" ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
6716
6863
|
/* @__PURE__ */ jsxs17("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
|
|
6717
6864
|
/* @__PURE__ */ jsx18(TabMarkIcon, { customIconUrl }),
|
|
6718
6865
|
showLogo ? /* @__PURE__ */ jsx18(
|
|
@@ -6978,9 +7125,9 @@ function AgentWidget({
|
|
|
6978
7125
|
});
|
|
6979
7126
|
return () => unregisterAgentPanelController(customerId);
|
|
6980
7127
|
}, [customerId, registerPanelController, reset, submit]);
|
|
6981
|
-
async function handleSubmit(message) {
|
|
7128
|
+
async function handleSubmit(message, options) {
|
|
6982
7129
|
if (isMobile) setRailCollapsed(false);
|
|
6983
|
-
await submit(message);
|
|
7130
|
+
await submit(message, options);
|
|
6984
7131
|
}
|
|
6985
7132
|
function handleFeedback(rating, message) {
|
|
6986
7133
|
if (!analytics) return;
|
|
@@ -7109,11 +7256,11 @@ function AgentWidget({
|
|
|
7109
7256
|
}
|
|
7110
7257
|
|
|
7111
7258
|
export {
|
|
7112
|
-
DEFAULT_RUNTIME_ORIGIN,
|
|
7113
|
-
resolveAgentRuntimeConfig,
|
|
7114
7259
|
AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION,
|
|
7115
7260
|
AGENT_STRUCTURED_TOOL_INPUT_HEADER,
|
|
7116
7261
|
formatAgentStructuredToolInput,
|
|
7262
|
+
DEFAULT_RUNTIME_ORIGIN,
|
|
7263
|
+
resolveAgentRuntimeConfig,
|
|
7117
7264
|
builtInVisitorToolResultRegistry,
|
|
7118
7265
|
presentVisitorToolResult,
|
|
7119
7266
|
useAgentChat,
|
|
@@ -7130,8 +7277,11 @@ export {
|
|
|
7130
7277
|
defaultDarkAgentRailTheme,
|
|
7131
7278
|
agentThemeStyle,
|
|
7132
7279
|
useAgentColorScheme,
|
|
7280
|
+
SearchReferences,
|
|
7281
|
+
BookingCard,
|
|
7133
7282
|
MessageBubble,
|
|
7134
7283
|
MessageActions,
|
|
7284
|
+
VisitorToolResultView,
|
|
7135
7285
|
AgentRail,
|
|
7136
7286
|
AssistEdgeTab,
|
|
7137
7287
|
AGENT_ANSWER_FEEDBACK_EVENT_TYPE,
|
|
@@ -7140,4 +7290,4 @@ export {
|
|
|
7140
7290
|
sendAgentAnswerFeedback,
|
|
7141
7291
|
AgentWidget
|
|
7142
7292
|
};
|
|
7143
|
-
//# sourceMappingURL=chunk-
|
|
7293
|
+
//# sourceMappingURL=chunk-3E632FNE.js.map
|