@webless/agent 0.9.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 +6 -0
- package/dist/{chunk-QMTI5646.js → chunk-3E632FNE.js} +332 -203
- package/dist/chunk-3E632FNE.js.map +1 -0
- package/dist/{chunk-5BCSXCLT.js → chunk-TCO62TRN.js} +40 -2
- package/dist/chunk-TCO62TRN.js.map +1 -0
- package/dist/embed.cjs +754 -625
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.css +60 -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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +43 -4
- 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 +79 -67
- package/dist/presentation.cjs.map +1 -1
- package/dist/presentation.d.cts +1 -1
- package/dist/presentation.d.ts +1 -1
- package/dist/presentation.js +7 -3
- package/dist/presentation.js.map +1 -1
- package/dist/react.cjs +756 -625
- package/dist/react.cjs.map +1 -1
- package/dist/react.css +60 -10
- package/dist/react.css.map +1 -1
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +3 -1
- package/dist/react.js.map +1 -1
- package/dist/{types-ohWeTG9i.d.cts → types-sLEIYDqm.d.cts} +1 -1
- package/dist/{types-ohWeTG9i.d.ts → types-sLEIYDqm.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-5BCSXCLT.js.map +0 -1
- package/dist/chunk-QMTI5646.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: [
|
|
@@ -5262,6 +5352,7 @@ function MessageBubble({
|
|
|
5262
5352
|
offers.length > 0 ? sanitizeBookingOfferCopy(visibleText) : looksLikeBookingAvailabilityDump(visibleText) ? sanitizeBookingOfferCopy(visibleText) : visibleText || (isStreaming ? "" : message.text)
|
|
5263
5353
|
);
|
|
5264
5354
|
if (message.role === "visitor") {
|
|
5355
|
+
if (!message.text.trim()) return null;
|
|
5265
5356
|
return /* @__PURE__ */ jsx8("article", { className: "message-bubble message-bubble--visitor", children: /* @__PURE__ */ jsx8("p", { className: "message-bubble__text", children: message.text }) });
|
|
5266
5357
|
}
|
|
5267
5358
|
const citations = message.citations ?? [];
|
|
@@ -5280,8 +5371,8 @@ function MessageBubble({
|
|
|
5280
5371
|
children: displayText
|
|
5281
5372
|
}
|
|
5282
5373
|
),
|
|
5283
|
-
/* @__PURE__ */ jsx8(SearchReferences, { results: message.searchResults ?? [] }),
|
|
5284
|
-
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: [
|
|
5285
5376
|
/* @__PURE__ */ jsx8(
|
|
5286
5377
|
"span",
|
|
5287
5378
|
{
|
|
@@ -5293,6 +5384,7 @@ function MessageBubble({
|
|
|
5293
5384
|
/* @__PURE__ */ jsx8("span", { children: citation.label })
|
|
5294
5385
|
] }) }, citation.id)) }) : null
|
|
5295
5386
|
] });
|
|
5387
|
+
if (!displayText && !message.searchResults?.length && offers.length === 0) return null;
|
|
5296
5388
|
return /* @__PURE__ */ jsxs8("article", { className: "message-bubble message-bubble--agent", children: [
|
|
5297
5389
|
displayText || message.searchResults?.length ? showBrandLogo ? /* @__PURE__ */ jsxs8("div", { className: "message-bubble__agent-row", children: [
|
|
5298
5390
|
/* @__PURE__ */ jsx8("span", { className: "message-bubble__agent-avatar", "aria-hidden": "true", children: /* @__PURE__ */ jsx8(
|
|
@@ -5859,6 +5951,7 @@ function CollectionResultCard({
|
|
|
5859
5951
|
{
|
|
5860
5952
|
className: `collection-result-card tool-result-card tool-result-card--${result.status}`,
|
|
5861
5953
|
"aria-label": result.title,
|
|
5954
|
+
role: result.status === "completed" ? "status" : "alert",
|
|
5862
5955
|
children: [
|
|
5863
5956
|
/* @__PURE__ */ jsxs12("div", { className: "tool-result-card__heading", children: [
|
|
5864
5957
|
/* @__PURE__ */ jsx12("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
|
|
@@ -5879,35 +5972,48 @@ function CollectionResultCard({
|
|
|
5879
5972
|
}
|
|
5880
5973
|
|
|
5881
5974
|
// src/react/components/EntityResultCard/EntityResultCard.tsx
|
|
5882
|
-
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";
|
|
5883
5976
|
function EntityResultCard({
|
|
5884
5977
|
result
|
|
5885
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
|
+
}
|
|
5886
6008
|
return /* @__PURE__ */ jsxs13(
|
|
5887
6009
|
"section",
|
|
5888
6010
|
{
|
|
5889
|
-
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" : ""}`,
|
|
5890
6012
|
"aria-label": result.title,
|
|
6013
|
+
role: result.status === "completed" ? "status" : "alert",
|
|
5891
6014
|
children: [
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
/* @__PURE__ */ jsx13("strong", { children: result.title })
|
|
5895
|
-
] }),
|
|
5896
|
-
result.description ? /* @__PURE__ */ jsx13("p", { children: result.description }) : null,
|
|
5897
|
-
result.details?.length ? /* @__PURE__ */ jsx13("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs13("div", { children: [
|
|
5898
|
-
/* @__PURE__ */ jsx13("dt", { children: detail.label }),
|
|
5899
|
-
/* @__PURE__ */ jsx13("dd", { children: detail.value })
|
|
5900
|
-
] }, `${detail.label}:${detail.value}`)) }) : null,
|
|
5901
|
-
result.links?.length ? /* @__PURE__ */ jsx13("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx13(
|
|
5902
|
-
"a",
|
|
5903
|
-
{
|
|
5904
|
-
href: link.href,
|
|
5905
|
-
target: "_blank",
|
|
5906
|
-
rel: "noreferrer",
|
|
5907
|
-
children: link.label
|
|
5908
|
-
},
|
|
5909
|
-
link.href
|
|
5910
|
-
)) }) : null
|
|
6015
|
+
heading,
|
|
6016
|
+
content
|
|
5911
6017
|
]
|
|
5912
6018
|
}
|
|
5913
6019
|
);
|
|
@@ -5956,6 +6062,7 @@ function ToolResultCard({
|
|
|
5956
6062
|
{
|
|
5957
6063
|
className: `tool-result-card tool-result-card--${result.status}`,
|
|
5958
6064
|
"aria-label": result.title,
|
|
6065
|
+
role: result.status === "completed" ? "status" : "alert",
|
|
5959
6066
|
children: [
|
|
5960
6067
|
/* @__PURE__ */ jsxs15("div", { className: "tool-result-card__heading", children: [
|
|
5961
6068
|
/* @__PURE__ */ jsx15("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
|
|
@@ -6017,7 +6124,7 @@ function isRenderableVisitorToolResult(result) {
|
|
|
6017
6124
|
}
|
|
6018
6125
|
|
|
6019
6126
|
// src/react/components/AgentRail/AgentRail.tsx
|
|
6020
|
-
import { Fragment as
|
|
6127
|
+
import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
6021
6128
|
function MinimizeIcon() {
|
|
6022
6129
|
return /* @__PURE__ */ jsx17("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx17(
|
|
6023
6130
|
"path",
|
|
@@ -6119,6 +6226,9 @@ function AgentRail({
|
|
|
6119
6226
|
const railRef = useRef6(null);
|
|
6120
6227
|
const overlayRef = useRef6(null);
|
|
6121
6228
|
const transcriptRef = useRef6(null);
|
|
6229
|
+
const responseRef = useRef6(null);
|
|
6230
|
+
const threadRef = useRef6(null);
|
|
6231
|
+
const lastScrolledVisitorIdRef = useRef6(void 0);
|
|
6122
6232
|
const pinnedToBottomRef = useRef6(true);
|
|
6123
6233
|
const smoothScrollToLatestRef = useRef6(false);
|
|
6124
6234
|
const lockedTranscriptScrollTopRef = useRef6(null);
|
|
@@ -6142,7 +6252,7 @@ function AgentRail({
|
|
|
6142
6252
|
const activeVisitorToolInput = [...visitorToolResults].reverse().find((result) => result.kind === "input");
|
|
6143
6253
|
const visibleVisitorToolResults = activeVisitorToolInput ? [activeVisitorToolInput] : visitorToolResults;
|
|
6144
6254
|
const activityActive = state.toolSteps.some((step) => step.state === "active");
|
|
6145
|
-
const showActivity = state.toolSteps.length > 0 &&
|
|
6255
|
+
const showActivity = state.toolSteps.length > 0 && pendingInputRequests.length === 0 && !state.pendingOffer && activityActive;
|
|
6146
6256
|
const hasVisitorMessages2 = state.messages.some(
|
|
6147
6257
|
(message) => message.role === "visitor"
|
|
6148
6258
|
);
|
|
@@ -6171,7 +6281,7 @@ function AgentRail({
|
|
|
6171
6281
|
}
|
|
6172
6282
|
}
|
|
6173
6283
|
const lastIsAgent = lastMessage?.role === "agent";
|
|
6174
|
-
const showMessageActions = state.phase === "complete" && lastIsAgent && hasVisitorMessages2;
|
|
6284
|
+
const showMessageActions = state.phase === "complete" && lastIsAgent && hasVisitorMessages2 && Boolean(hideToolCardFences(lastMessage.text).trim());
|
|
6175
6285
|
const streamingMessage = state.phase === "streaming" && state.streamingText && !lastIsAgent ? {
|
|
6176
6286
|
createdAt: 0,
|
|
6177
6287
|
id: "streaming-response",
|
|
@@ -6201,15 +6311,21 @@ function AgentRail({
|
|
|
6201
6311
|
hasPendingConfirmation,
|
|
6202
6312
|
enabled: lastIsAgent && !isBusy
|
|
6203
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;
|
|
6204
6320
|
const receiptSteps = answerReceipt && state.toolSteps.length > 0 ? state.toolSteps : void 0;
|
|
6205
6321
|
useEffect6(() => {
|
|
6206
6322
|
if (state.phase !== "complete") {
|
|
6207
6323
|
setReceiptOpen(false);
|
|
6208
6324
|
}
|
|
6209
6325
|
}, [state.phase]);
|
|
6210
|
-
function handleSubmit(message) {
|
|
6326
|
+
function handleSubmit(message, options) {
|
|
6211
6327
|
setReceiptOpen(false);
|
|
6212
|
-
onSubmit?.(message);
|
|
6328
|
+
onSubmit?.(message, options);
|
|
6213
6329
|
}
|
|
6214
6330
|
function handleRegenerate() {
|
|
6215
6331
|
setReceiptOpen(false);
|
|
@@ -6223,15 +6339,31 @@ function AgentRail({
|
|
|
6223
6339
|
setReceiptOpen(false);
|
|
6224
6340
|
onFollowUpSelect?.(label);
|
|
6225
6341
|
}
|
|
6342
|
+
const latestVisitorId = visibleMessages[lastVisitorIndex]?.id;
|
|
6226
6343
|
useEffect6(() => {
|
|
6227
6344
|
const node = transcriptRef.current;
|
|
6228
6345
|
if (!node) return;
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
node.scrollTop = node.scrollHeight;
|
|
6346
|
+
if (latestVisitorId !== lastScrolledVisitorIdRef.current) {
|
|
6347
|
+
lastScrolledVisitorIdRef.current = latestVisitorId;
|
|
6348
|
+
pinnedToBottomRef.current = true;
|
|
6233
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();
|
|
6234
6365
|
}, [
|
|
6366
|
+
latestVisitorId,
|
|
6235
6367
|
state.messages,
|
|
6236
6368
|
state.toolSteps,
|
|
6237
6369
|
state.streamingText,
|
|
@@ -6252,18 +6384,6 @@ function AgentRail({
|
|
|
6252
6384
|
handleScroll();
|
|
6253
6385
|
return () => node.removeEventListener("scroll", handleScroll);
|
|
6254
6386
|
}, []);
|
|
6255
|
-
useEffect6(() => {
|
|
6256
|
-
const node = transcriptRef.current;
|
|
6257
|
-
if (!node) return;
|
|
6258
|
-
const observer = new ResizeObserver(() => {
|
|
6259
|
-
if (node.clientHeight === 0) return;
|
|
6260
|
-
if (pinnedToBottomRef.current) {
|
|
6261
|
-
node.scrollTo({ top: node.scrollHeight, behavior: "instant" });
|
|
6262
|
-
}
|
|
6263
|
-
});
|
|
6264
|
-
observer.observe(node);
|
|
6265
|
-
return () => observer.disconnect();
|
|
6266
|
-
}, []);
|
|
6267
6387
|
useEffect6(() => {
|
|
6268
6388
|
if (!receiptOpen) {
|
|
6269
6389
|
lockedTranscriptScrollTopRef.current = null;
|
|
@@ -6380,7 +6500,7 @@ function AgentRail({
|
|
|
6380
6500
|
) : null
|
|
6381
6501
|
] })
|
|
6382
6502
|
] }) }),
|
|
6383
|
-
/* @__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: [
|
|
6384
6504
|
!hasVisitorMessages2 ? /* @__PURE__ */ jsxs16("section", { className: "agent-rail__welcome", "aria-label": "Welcome", children: [
|
|
6385
6505
|
greeting?.role === "agent" ? /* @__PURE__ */ jsx17(
|
|
6386
6506
|
MessageBubble,
|
|
@@ -6427,59 +6547,68 @@ function AgentRail({
|
|
|
6427
6547
|
request.requestId
|
|
6428
6548
|
))
|
|
6429
6549
|
] }) : null,
|
|
6430
|
-
visibleMessages.map((message, index) => /* @__PURE__ */ jsxs16(
|
|
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
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
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(
|
|
6483
6612
|
MessageBubble,
|
|
6484
6613
|
{
|
|
6485
6614
|
message: streamingMessage,
|
|
@@ -6488,7 +6617,7 @@ function AgentRail({
|
|
|
6488
6617
|
offer: state.pendingOffer,
|
|
6489
6618
|
onBook
|
|
6490
6619
|
}
|
|
6491
|
-
) : null,
|
|
6620
|
+
) }) : null,
|
|
6492
6621
|
waitingForBooking ? /* @__PURE__ */ jsx17(BookingCardLoader, {}) : null,
|
|
6493
6622
|
state.error ? /* @__PURE__ */ jsxs16("section", { className: "agent-rail__error", role: "alert", children: [
|
|
6494
6623
|
/* @__PURE__ */ jsxs16("div", { children: [
|
|
@@ -6529,7 +6658,7 @@ function AgentRail({
|
|
|
6529
6658
|
placeholder: composerPlaceholder,
|
|
6530
6659
|
onSubmit: handleSubmit
|
|
6531
6660
|
},
|
|
6532
|
-
state.messages.find((message) => message.role === "visitor")?.id ?? "empty"
|
|
6661
|
+
`${state.messages.find((message) => message.role === "visitor")?.id ?? "empty"}:${latestResultId ?? ""}`
|
|
6533
6662
|
),
|
|
6534
6663
|
poweredByLabel ? /* @__PURE__ */ jsx17("div", { className: "agent-rail__footer", children: /* @__PURE__ */ jsx17("p", { children: /* @__PURE__ */ jsx17("span", { children: poweredByLabel }) }) }) : null
|
|
6535
6664
|
] })
|
|
@@ -6551,7 +6680,7 @@ function AgentRail({
|
|
|
6551
6680
|
}
|
|
6552
6681
|
|
|
6553
6682
|
// src/react/components/AssistEdgeTab/AssistEdgeTab.tsx
|
|
6554
|
-
import { Fragment as
|
|
6683
|
+
import { Fragment as Fragment5, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6555
6684
|
function SparklesIcon() {
|
|
6556
6685
|
return /* @__PURE__ */ jsxs17(
|
|
6557
6686
|
"svg",
|
|
@@ -6684,7 +6813,7 @@ function AssistEdgeTab({
|
|
|
6684
6813
|
tabIndex: visible ? 0 : -1,
|
|
6685
6814
|
onClick: onOpen,
|
|
6686
6815
|
children: [
|
|
6687
|
-
mobile ? /* @__PURE__ */ jsxs17(
|
|
6816
|
+
mobile ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
6688
6817
|
/* @__PURE__ */ jsxs17(
|
|
6689
6818
|
"span",
|
|
6690
6819
|
{
|
|
@@ -6707,7 +6836,7 @@ function AssistEdgeTab({
|
|
|
6707
6836
|
}
|
|
6708
6837
|
),
|
|
6709
6838
|
/* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__label", children: visibleLabel })
|
|
6710
|
-
] }) : variant === "outline" ? /* @__PURE__ */ jsxs17(
|
|
6839
|
+
] }) : variant === "outline" ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
6711
6840
|
/* @__PURE__ */ jsxs17("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
|
|
6712
6841
|
/* @__PURE__ */ jsx18(TabMarkIcon, { customIconUrl }),
|
|
6713
6842
|
showLogo ? /* @__PURE__ */ jsx18(
|
|
@@ -6725,12 +6854,12 @@ function AssistEdgeTab({
|
|
|
6725
6854
|
/* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__label", children: visibleLabel }),
|
|
6726
6855
|
/* @__PURE__ */ jsx18(ChevronDownIcon2, {})
|
|
6727
6856
|
] }) : null,
|
|
6728
|
-
variant === "ask" ? /* @__PURE__ */ jsxs17(
|
|
6857
|
+
variant === "ask" ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
6729
6858
|
/* @__PURE__ */ jsx18(ChevronLeftIcon, {}),
|
|
6730
6859
|
/* @__PURE__ */ jsx18("span", { className: "assist-edge-tab__label", children: visibleLabel }),
|
|
6731
6860
|
/* @__PURE__ */ jsx18(DragDots, {})
|
|
6732
6861
|
] }) : null,
|
|
6733
|
-
variant === "fill" ? /* @__PURE__ */ jsxs17(
|
|
6862
|
+
variant === "fill" ? /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
6734
6863
|
/* @__PURE__ */ jsxs17("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
|
|
6735
6864
|
/* @__PURE__ */ jsx18(TabMarkIcon, { customIconUrl }),
|
|
6736
6865
|
showLogo ? /* @__PURE__ */ jsx18(
|
|
@@ -6996,9 +7125,9 @@ function AgentWidget({
|
|
|
6996
7125
|
});
|
|
6997
7126
|
return () => unregisterAgentPanelController(customerId);
|
|
6998
7127
|
}, [customerId, registerPanelController, reset, submit]);
|
|
6999
|
-
async function handleSubmit(message) {
|
|
7128
|
+
async function handleSubmit(message, options) {
|
|
7000
7129
|
if (isMobile) setRailCollapsed(false);
|
|
7001
|
-
await submit(message);
|
|
7130
|
+
await submit(message, options);
|
|
7002
7131
|
}
|
|
7003
7132
|
function handleFeedback(rating, message) {
|
|
7004
7133
|
if (!analytics) return;
|
|
@@ -7127,11 +7256,11 @@ function AgentWidget({
|
|
|
7127
7256
|
}
|
|
7128
7257
|
|
|
7129
7258
|
export {
|
|
7130
|
-
DEFAULT_RUNTIME_ORIGIN,
|
|
7131
|
-
resolveAgentRuntimeConfig,
|
|
7132
7259
|
AGENT_STRUCTURED_TOOL_INPUT_SCHEMA_VERSION,
|
|
7133
7260
|
AGENT_STRUCTURED_TOOL_INPUT_HEADER,
|
|
7134
7261
|
formatAgentStructuredToolInput,
|
|
7262
|
+
DEFAULT_RUNTIME_ORIGIN,
|
|
7263
|
+
resolveAgentRuntimeConfig,
|
|
7135
7264
|
builtInVisitorToolResultRegistry,
|
|
7136
7265
|
presentVisitorToolResult,
|
|
7137
7266
|
useAgentChat,
|
|
@@ -7161,4 +7290,4 @@ export {
|
|
|
7161
7290
|
sendAgentAnswerFeedback,
|
|
7162
7291
|
AgentWidget
|
|
7163
7292
|
};
|
|
7164
|
-
//# sourceMappingURL=chunk-
|
|
7293
|
+
//# sourceMappingURL=chunk-3E632FNE.js.map
|