agentic-browser 1.4.0 → 1.4.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/dist/cli/index.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as createMockAgenticBrowserCore, n as createAgenticBrowserCore, t as AgenticBrowserCore } from "./runtime-
|
|
2
|
+
import { i as createMockAgenticBrowserCore, n as createAgenticBrowserCore, t as AgenticBrowserCore } from "./runtime-C32ai0TQ.mjs";
|
|
3
3
|
|
|
4
4
|
export { AgenticBrowserCore, createAgenticBrowserCore, createMockAgenticBrowserCore };
|
package/dist/mcp/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as createAgenticBrowserCore } from "../runtime-
|
|
2
|
+
import { n as createAgenticBrowserCore } from "../runtime-C32ai0TQ.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -150,25 +150,19 @@ async function createTarget(cdpUrl, url = "about:blank") {
|
|
|
150
150
|
} catch {}
|
|
151
151
|
return await ensurePageWebSocketUrl(cdpUrl);
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
/** Verify the page is ready and optionally set a custom user-agent, using a single connection. */
|
|
154
|
+
async function initTarget(targetWsUrl, userAgent) {
|
|
154
155
|
const conn = await CdpConnection.connect(targetWsUrl);
|
|
155
156
|
try {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
conn.
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
async function evaluateExpression(targetWsUrl, expression) {
|
|
163
|
-
const conn = await CdpConnection.connect(targetWsUrl);
|
|
164
|
-
try {
|
|
165
|
-
await conn.send("Page.enable");
|
|
166
|
-
await conn.send("Runtime.enable");
|
|
167
|
-
return (await conn.send("Runtime.evaluate", {
|
|
168
|
-
expression,
|
|
157
|
+
const enables = [conn.send("Page.enable"), conn.send("Runtime.enable")];
|
|
158
|
+
if (userAgent) enables.push(conn.send("Network.enable"));
|
|
159
|
+
await Promise.all(enables);
|
|
160
|
+
await conn.send("Runtime.evaluate", {
|
|
161
|
+
expression: "window.location.href",
|
|
169
162
|
returnByValue: true,
|
|
170
163
|
awaitPromise: true
|
|
171
|
-
})
|
|
164
|
+
});
|
|
165
|
+
if (userAgent) await conn.send("Network.setUserAgentOverride", { userAgent });
|
|
172
166
|
} finally {
|
|
173
167
|
conn.close();
|
|
174
168
|
}
|
|
@@ -236,8 +230,7 @@ var ChromeCdpBrowserController = class {
|
|
|
236
230
|
if (!port) throw new Error(`Invalid CDP URL: could not extract port from ${cdpUrl}`);
|
|
237
231
|
await waitForDebugger(port);
|
|
238
232
|
const targetWsUrl = await createTarget(cdpUrl);
|
|
239
|
-
await
|
|
240
|
-
if (options?.userAgent) await applyUserAgent(targetWsUrl, options.userAgent);
|
|
233
|
+
await initTarget(targetWsUrl, options?.userAgent);
|
|
241
234
|
return {
|
|
242
235
|
pid: 0,
|
|
243
236
|
cdpUrl,
|
|
@@ -247,14 +240,14 @@ var ChromeCdpBrowserController = class {
|
|
|
247
240
|
async ensureEnabled(targetWsUrl) {
|
|
248
241
|
const cached = this.connections.get(targetWsUrl);
|
|
249
242
|
if (!cached) return;
|
|
250
|
-
|
|
251
|
-
|
|
243
|
+
const promises = [];
|
|
244
|
+
if (!cached.enabled.page) promises.push(cached.conn.send("Page.enable").then(() => {
|
|
252
245
|
cached.enabled.page = true;
|
|
253
|
-
}
|
|
254
|
-
if (!cached.enabled.runtime) {
|
|
255
|
-
await cached.conn.send("Runtime.enable");
|
|
246
|
+
}));
|
|
247
|
+
if (!cached.enabled.runtime) promises.push(cached.conn.send("Runtime.enable").then(() => {
|
|
256
248
|
cached.enabled.runtime = true;
|
|
257
|
-
}
|
|
249
|
+
}));
|
|
250
|
+
if (promises.length) await Promise.all(promises);
|
|
258
251
|
}
|
|
259
252
|
async launch(sessionId, options) {
|
|
260
253
|
const { executablePath: explicitPath, userProfileDir, headless, userAgent } = options ?? {};
|
|
@@ -305,9 +298,8 @@ var ChromeCdpBrowserController = class {
|
|
|
305
298
|
await waitForDebugger(port);
|
|
306
299
|
const cdpUrl = `http://127.0.0.1:${port}`;
|
|
307
300
|
const targetWsUrl = await createTarget(cdpUrl, "about:blank");
|
|
308
|
-
await evaluateExpression(targetWsUrl, "window.location.href");
|
|
309
301
|
if (!child.pid) throw new Error("Failed to launch Chrome process");
|
|
310
|
-
|
|
302
|
+
await initTarget(targetWsUrl, userAgent);
|
|
311
303
|
return {
|
|
312
304
|
pid: child.pid,
|
|
313
305
|
cdpUrl,
|
|
@@ -1401,7 +1393,7 @@ var EventStore = class {
|
|
|
1401
1393
|
const existing = this.events.get(event.sessionId) ?? [];
|
|
1402
1394
|
existing.push(event);
|
|
1403
1395
|
this.events.set(event.sessionId, existing);
|
|
1404
|
-
fs.
|
|
1396
|
+
fs.appendFile(this.filePath, `${JSON.stringify(event)}\n`, "utf8", () => {});
|
|
1405
1397
|
}
|
|
1406
1398
|
list(sessionId, limit = 100) {
|
|
1407
1399
|
const entries = this.events.get(sessionId) ?? [];
|
|
@@ -1904,7 +1896,13 @@ var MemoryService = class {
|
|
|
1904
1896
|
return failed;
|
|
1905
1897
|
}
|
|
1906
1898
|
findBestExactMatch(insights, taskIntent, siteDomain) {
|
|
1907
|
-
|
|
1899
|
+
const intentLower = taskIntent.toLowerCase();
|
|
1900
|
+
const domainLower = siteDomain.toLowerCase();
|
|
1901
|
+
let best;
|
|
1902
|
+
for (const insight of insights) if (insight.taskIntent.toLowerCase() === intentLower && insight.siteDomain.toLowerCase() === domainLower) {
|
|
1903
|
+
if (!best || insight.updatedAt > best.updatedAt) best = insight;
|
|
1904
|
+
}
|
|
1905
|
+
return best;
|
|
1908
1906
|
}
|
|
1909
1907
|
createEvidence(input, result, reason) {
|
|
1910
1908
|
return {
|