@invergent/agent-chat-react 2.16.3 → 2.16.5
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.js
CHANGED
|
@@ -70,14 +70,6 @@ function normalizePoint(clientX, clientY, rect, naturalWidth, naturalHeight) {
|
|
|
70
70
|
if (x < 0 || x > 1 || y < 0 || y > 1) return null;
|
|
71
71
|
return { x, y };
|
|
72
72
|
}
|
|
73
|
-
function hostOf(url) {
|
|
74
|
-
try {
|
|
75
|
-
const parsed = new URL(url);
|
|
76
|
-
return { origin: parsed.host, rest: `${parsed.pathname}${parsed.search}` };
|
|
77
|
-
} catch {
|
|
78
|
-
return { origin: url, rest: "" };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
73
|
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";
|
|
82
74
|
function BrowserShell({
|
|
83
75
|
src,
|
|
@@ -98,6 +90,8 @@ function BrowserShell({
|
|
|
98
90
|
const [tabs, setTabs] = useState([]);
|
|
99
91
|
const [nav, setNav] = useState({ url: "", title: "" });
|
|
100
92
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
93
|
+
const [address, setAddress] = useState("");
|
|
94
|
+
const editingRef = useRef(false);
|
|
101
95
|
useEffect(() => {
|
|
102
96
|
setState("connecting");
|
|
103
97
|
let disposed = false;
|
|
@@ -136,7 +130,9 @@ function BrowserShell({
|
|
|
136
130
|
const next = message.tabs ?? [];
|
|
137
131
|
setTabs(next);
|
|
138
132
|
const active = next.find((tab) => tab.active);
|
|
139
|
-
if (active)
|
|
133
|
+
if (active) {
|
|
134
|
+
setNav({ url: active.url, title: active.title });
|
|
135
|
+
}
|
|
140
136
|
} else if (message.t === "nav") {
|
|
141
137
|
setNav({
|
|
142
138
|
url: String(message.url ?? ""),
|
|
@@ -156,6 +152,9 @@ function BrowserShell({
|
|
|
156
152
|
socketRef.current = null;
|
|
157
153
|
};
|
|
158
154
|
}, [src]);
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (!editingRef.current) setAddress(nav.url);
|
|
157
|
+
}, [nav.url]);
|
|
159
158
|
const send = useCallback((message) => {
|
|
160
159
|
const socket = socketRef.current;
|
|
161
160
|
if (!socket || socket.readyState !== WebSocket.OPEN) return;
|
|
@@ -200,7 +199,6 @@ function BrowserShell({
|
|
|
200
199
|
command({ t: "type", text: event.key });
|
|
201
200
|
}
|
|
202
201
|
};
|
|
203
|
-
const { origin, rest } = hostOf(nav.url);
|
|
204
202
|
const showTabs = tabs.length > 1;
|
|
205
203
|
return /* @__PURE__ */ jsxs(
|
|
206
204
|
"div",
|
|
@@ -267,10 +265,35 @@ function BrowserShell({
|
|
|
267
265
|
className: `size-1.5 shrink-0 rounded-full ${state === "connected" ? "bg-emerald-500" : "bg-muted-foreground"}`
|
|
268
266
|
}
|
|
269
267
|
),
|
|
270
|
-
/* @__PURE__ */
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
268
|
+
/* @__PURE__ */ jsx(
|
|
269
|
+
"input",
|
|
270
|
+
{
|
|
271
|
+
type: "text",
|
|
272
|
+
"aria-label": "Address",
|
|
273
|
+
placeholder: "Type a URL and press Enter",
|
|
274
|
+
className: "h-full min-w-0 flex-grow bg-transparent outline-none placeholder:text-muted-foreground",
|
|
275
|
+
disabled: !hasControl,
|
|
276
|
+
value: address,
|
|
277
|
+
onChange: (event) => setAddress(event.target.value),
|
|
278
|
+
onFocus: () => {
|
|
279
|
+
editingRef.current = true;
|
|
280
|
+
},
|
|
281
|
+
onBlur: () => {
|
|
282
|
+
editingRef.current = false;
|
|
283
|
+
setAddress(nav.url);
|
|
284
|
+
},
|
|
285
|
+
onKeyDown: (event) => {
|
|
286
|
+
if (event.key !== "Enter") return;
|
|
287
|
+
event.preventDefault();
|
|
288
|
+
event.target.blur();
|
|
289
|
+
const typed = address.trim();
|
|
290
|
+
if (!typed) return;
|
|
291
|
+
const url = /^[a-z][a-z0-9+.-]*:\/\//i.test(typed) ? typed : `https://${typed}`;
|
|
292
|
+
setAddress(url);
|
|
293
|
+
command({ t: "navigate", url });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
)
|
|
274
297
|
]
|
|
275
298
|
}
|
|
276
299
|
),
|
|
@@ -3974,7 +3997,6 @@ function ExpertToolBlock({ tc }) {
|
|
|
3974
3997
|
]
|
|
3975
3998
|
}
|
|
3976
3999
|
),
|
|
3977
|
-
result?.summary && !expanded && /* @__PURE__ */ 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 }),
|
|
3978
4000
|
expanded && /* @__PURE__ */ jsxs("div", { className: "ml-6 mt-0.5 space-y-1.5 text-sm", children: [
|
|
3979
4001
|
question && /* @__PURE__ */ jsx(ExpertDetail, { label: "Question", content: question }),
|
|
3980
4002
|
result?.summary && /* @__PURE__ */ jsx(
|
|
@@ -4075,7 +4097,7 @@ function ExpertDetail({
|
|
|
4075
4097
|
),
|
|
4076
4098
|
children: [
|
|
4077
4099
|
/* @__PURE__ */ jsx("div", { className: "mb-1 text-[10px] uppercase tracking-wide text-muted-foreground/70", children: label }),
|
|
4078
|
-
/* @__PURE__ */ jsx(
|
|
4100
|
+
/* @__PURE__ */ jsx(MessageResponse, { className: "wrap-break-word text-foreground/90", children: content })
|
|
4079
4101
|
]
|
|
4080
4102
|
}
|
|
4081
4103
|
);
|
|
@@ -5331,7 +5353,7 @@ function extractToolDetail(tc) {
|
|
|
5331
5353
|
case "web_crawl":
|
|
5332
5354
|
case "web_extract": {
|
|
5333
5355
|
const url = stringArg("url");
|
|
5334
|
-
return url ?
|
|
5356
|
+
return url ? hostOf(url) : null;
|
|
5335
5357
|
}
|
|
5336
5358
|
case "kb_search_pages": {
|
|
5337
5359
|
const query = stringArg("query");
|
|
@@ -5383,7 +5405,7 @@ function extractToolDetail(tc) {
|
|
|
5383
5405
|
const title = stringArg("title");
|
|
5384
5406
|
if (title) return truncate3(title, 60);
|
|
5385
5407
|
const url = stringArg("url");
|
|
5386
|
-
return url ?
|
|
5408
|
+
return url ? hostOf(url) : null;
|
|
5387
5409
|
}
|
|
5388
5410
|
if (action === "retrieve") {
|
|
5389
5411
|
return stringArg("query");
|
|
@@ -5416,7 +5438,7 @@ function lastPathSegment(path) {
|
|
|
5416
5438
|
function truncate3(s, max) {
|
|
5417
5439
|
return s.length > max ? `${s.slice(0, max - 1)}\u2026` : s;
|
|
5418
5440
|
}
|
|
5419
|
-
function
|
|
5441
|
+
function hostOf(url) {
|
|
5420
5442
|
try {
|
|
5421
5443
|
return new URL(url).hostname.replace(/^www\./, "") || truncate3(url, 40);
|
|
5422
5444
|
} catch {
|