@invergent/agent-chat-react 2.16.2 → 2.16.4
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/dist/index.cjs +41 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -253,14 +253,6 @@ function normalizePoint(clientX, clientY, rect, naturalWidth, naturalHeight) {
|
|
|
253
253
|
if (x < 0 || x > 1 || y < 0 || y > 1) return null;
|
|
254
254
|
return { x, y };
|
|
255
255
|
}
|
|
256
|
-
function hostOf(url) {
|
|
257
|
-
try {
|
|
258
|
-
const parsed = new URL(url);
|
|
259
|
-
return { origin: parsed.host, rest: `${parsed.pathname}${parsed.search}` };
|
|
260
|
-
} catch {
|
|
261
|
-
return { origin: url, rest: "" };
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
256
|
var ICON = "flex size-[26px] shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground disabled:pointer-events-none disabled:opacity-40";
|
|
265
257
|
function BrowserShell({
|
|
266
258
|
src,
|
|
@@ -281,6 +273,8 @@ function BrowserShell({
|
|
|
281
273
|
const [tabs, setTabs] = react.useState([]);
|
|
282
274
|
const [nav, setNav] = react.useState({ url: "", title: "" });
|
|
283
275
|
const [menuOpen, setMenuOpen] = react.useState(false);
|
|
276
|
+
const [address, setAddress] = react.useState("");
|
|
277
|
+
const editingRef = react.useRef(false);
|
|
284
278
|
react.useEffect(() => {
|
|
285
279
|
setState("connecting");
|
|
286
280
|
let disposed = false;
|
|
@@ -319,7 +313,9 @@ function BrowserShell({
|
|
|
319
313
|
const next = message.tabs ?? [];
|
|
320
314
|
setTabs(next);
|
|
321
315
|
const active = next.find((tab) => tab.active);
|
|
322
|
-
if (active)
|
|
316
|
+
if (active) {
|
|
317
|
+
setNav({ url: active.url, title: active.title });
|
|
318
|
+
}
|
|
323
319
|
} else if (message.t === "nav") {
|
|
324
320
|
setNav({
|
|
325
321
|
url: String(message.url ?? ""),
|
|
@@ -339,6 +335,9 @@ function BrowserShell({
|
|
|
339
335
|
socketRef.current = null;
|
|
340
336
|
};
|
|
341
337
|
}, [src]);
|
|
338
|
+
react.useEffect(() => {
|
|
339
|
+
if (!editingRef.current) setAddress(nav.url);
|
|
340
|
+
}, [nav.url]);
|
|
342
341
|
const send = react.useCallback((message) => {
|
|
343
342
|
const socket = socketRef.current;
|
|
344
343
|
if (!socket || socket.readyState !== WebSocket.OPEN) return;
|
|
@@ -383,7 +382,6 @@ function BrowserShell({
|
|
|
383
382
|
command({ t: "type", text: event.key });
|
|
384
383
|
}
|
|
385
384
|
};
|
|
386
|
-
const { origin, rest } = hostOf(nav.url);
|
|
387
385
|
const showTabs = tabs.length > 1;
|
|
388
386
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
389
387
|
"div",
|
|
@@ -450,10 +448,35 @@ function BrowserShell({
|
|
|
450
448
|
className: `size-1.5 shrink-0 rounded-full ${state === "connected" ? "bg-emerald-500" : "bg-muted-foreground"}`
|
|
451
449
|
}
|
|
452
450
|
),
|
|
453
|
-
/* @__PURE__ */ jsxRuntime.
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
451
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
452
|
+
"input",
|
|
453
|
+
{
|
|
454
|
+
type: "text",
|
|
455
|
+
"aria-label": "Address",
|
|
456
|
+
placeholder: "Type a URL and press Enter",
|
|
457
|
+
className: "h-full min-w-0 flex-grow bg-transparent outline-none placeholder:text-muted-foreground",
|
|
458
|
+
disabled: !hasControl,
|
|
459
|
+
value: address,
|
|
460
|
+
onChange: (event) => setAddress(event.target.value),
|
|
461
|
+
onFocus: () => {
|
|
462
|
+
editingRef.current = true;
|
|
463
|
+
},
|
|
464
|
+
onBlur: () => {
|
|
465
|
+
editingRef.current = false;
|
|
466
|
+
setAddress(nav.url);
|
|
467
|
+
},
|
|
468
|
+
onKeyDown: (event) => {
|
|
469
|
+
if (event.key !== "Enter") return;
|
|
470
|
+
event.preventDefault();
|
|
471
|
+
event.target.blur();
|
|
472
|
+
const typed = address.trim();
|
|
473
|
+
if (!typed) return;
|
|
474
|
+
const url = /^[a-z][a-z0-9+.-]*:\/\//i.test(typed) ? typed : `https://${typed}`;
|
|
475
|
+
setAddress(url);
|
|
476
|
+
command({ t: "navigate", url });
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
)
|
|
457
480
|
]
|
|
458
481
|
}
|
|
459
482
|
),
|
|
@@ -4223,7 +4246,6 @@ function ExpertToolBlock({ tc }) {
|
|
|
4223
4246
|
]
|
|
4224
4247
|
}
|
|
4225
4248
|
),
|
|
4226
|
-
result?.summary && !expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-6 rounded-md border-l-2 border-primary/50 bg-muted/30 px-3 py-2 text-sm text-foreground/90", children: result.summary }),
|
|
4227
4249
|
expanded && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-6 mt-0.5 space-y-1.5 text-sm", children: [
|
|
4228
4250
|
question && /* @__PURE__ */ jsxRuntime.jsx(ExpertDetail, { label: "Question", content: question }),
|
|
4229
4251
|
result?.summary && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4324,7 +4346,7 @@ function ExpertDetail({
|
|
|
4324
4346
|
),
|
|
4325
4347
|
children: [
|
|
4326
4348
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-1 text-[10px] uppercase tracking-wide text-muted-foreground/70", children: label }),
|
|
4327
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4349
|
+
/* @__PURE__ */ jsxRuntime.jsx(MessageResponse, { className: "wrap-break-word text-foreground/90", children: content })
|
|
4328
4350
|
]
|
|
4329
4351
|
}
|
|
4330
4352
|
);
|
|
@@ -5592,7 +5614,7 @@ function extractToolDetail(tc) {
|
|
|
5592
5614
|
case "web_crawl":
|
|
5593
5615
|
case "web_extract": {
|
|
5594
5616
|
const url = stringArg("url");
|
|
5595
|
-
return url ?
|
|
5617
|
+
return url ? hostOf(url) : null;
|
|
5596
5618
|
}
|
|
5597
5619
|
case "kb_search_pages": {
|
|
5598
5620
|
const query = stringArg("query");
|
|
@@ -5644,7 +5666,7 @@ function extractToolDetail(tc) {
|
|
|
5644
5666
|
const title = stringArg("title");
|
|
5645
5667
|
if (title) return truncate3(title, 60);
|
|
5646
5668
|
const url = stringArg("url");
|
|
5647
|
-
return url ?
|
|
5669
|
+
return url ? hostOf(url) : null;
|
|
5648
5670
|
}
|
|
5649
5671
|
if (action === "retrieve") {
|
|
5650
5672
|
return stringArg("query");
|
|
@@ -5677,7 +5699,7 @@ function lastPathSegment(path) {
|
|
|
5677
5699
|
function truncate3(s, max) {
|
|
5678
5700
|
return s.length > max ? `${s.slice(0, max - 1)}\u2026` : s;
|
|
5679
5701
|
}
|
|
5680
|
-
function
|
|
5702
|
+
function hostOf(url) {
|
|
5681
5703
|
try {
|
|
5682
5704
|
return new URL(url).hostname.replace(/^www\./, "") || truncate3(url, 40);
|
|
5683
5705
|
} catch {
|