cdp-toolkit 1.9.7 → 1.11.0
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/CHANGELOG.md +36 -0
- package/README.md +29 -7
- package/dist/cli.js +1154 -255
- package/dist/mcp.js +601 -257
- package/package.json +2 -1
- package/src/bidi/driver.ts +190 -28
- package/src/bidi/marionette.ts +276 -0
- package/src/bidi/session-lease.ts +265 -0
- package/src/cli.ts +10 -0
- package/src/install/browser.ts +211 -0
- package/src/install/harness.ts +224 -0
- package/src/install/wizard.ts +412 -0
- package/src/manifest.ts +252 -242
- package/src/mcp.ts +16 -2
package/src/mcp.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { toolAvailability } from "./capabilities.ts";
|
|
|
26
26
|
import { FIREFOX_TOOLS } from "./firefox-tools.ts";
|
|
27
27
|
import { leaseFromArgs, markLongLivedProcess, withLeaseScope } from "./leases.ts";
|
|
28
28
|
|
|
29
|
-
const VERSION = "1.
|
|
29
|
+
const VERSION = "1.11.0";
|
|
30
30
|
|
|
31
31
|
// Backend + (Firefox only) attach endpoint are read once at startup (MCP has no per-call notion
|
|
32
32
|
// of backend): --browser flag / CDP_BROWSER env, else "chrome" (zero behavior change for existing
|
|
@@ -50,7 +50,21 @@ function auditCoverage(): void {
|
|
|
50
50
|
if (orphanSchema.length) console.error(`[cdp-toolkit] WARN: manifest schemas with no registered tool: ${orphanSchema.join(", ")}`);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
// Server `instructions` (MCP initialize result): the cross-cutting conventions that
|
|
54
|
+
// used to be re-stated inside every tool's schema — the target-selector grammar, the
|
|
55
|
+
// lease-token model, the MV3 worker/wake arm, the origin vocabulary. Stating them ONCE
|
|
56
|
+
// here (loaded a single time at init) is what let the per-tool descriptions and the
|
|
57
|
+
// 42-way-duplicated `lease` param collapse to short pointers, cutting the tools/list
|
|
58
|
+
// payload without losing a single behavior. Kept under Claude Code's 2KB instructions
|
|
59
|
+
// cap and front-loaded (grammar + leases before origin) so nothing critical is clipped.
|
|
60
|
+
const INSTRUCTIONS = [
|
|
61
|
+
"cdp-toolkit drives a real browser over Chrome DevTools Protocol (or Firefox WebDriver-BiDi): open and drive pages, click/fill/type, screenshot and accessibility-snapshot, read console + network, set cookies, emulate devices, run Lighthouse and performance traces, record screencasts. Conventions shared across its tools:",
|
|
62
|
+
"TARGET SELECTOR (the `target` param, unless a tool says otherwise): 'active' (default = first page) | 'index:N' (0-based) | 'url:<substr>' | 'title:<substr>' | 'label:<name>' (exact, from the origin ledger or a live lease) | a 32-hex '<targetId>'. Four Chrome-only tools (evaluate_script, list_network_requests, get_network_request, list_console_messages) also accept 'worker:<substr>' to reach a service/shared worker — e.g. an MV3 extension's background worker (worker:<extension-id> or worker:background.js); an idle-evicted worker is started first (see each tool's `wake`).",
|
|
63
|
+
"LEASES (the `lease` param): claim_page, and new_page{claim:true}, mint an opaque token. Omit it for a tab THIS process already holds. It is required for a tab held by ANOTHER process, or one claimed explicitly. Under CDP_REQUIRE_LEASE the gate auto-acquires a lease for any tab this process drives — no token is surfaced, so pass `target`, not `lease` — while an explicit claim:true still demands its token on every later call. Without CDP_REQUIRE_LEASE an unleased tab needs no token at all.",
|
|
64
|
+
"ORIGIN: list_pages and list_leases tag each tab's `origin` as 'agent' (this toolkit created it) or 'unknown' — never 'human', because the toolkit cannot prove a person opened a tab. An 'agent' tab stays findable after its creator releases the lease or dies.",
|
|
65
|
+
].join("\n\n");
|
|
66
|
+
|
|
67
|
+
const server = new Server({ name: "cdp-toolkit", version: VERSION }, { capabilities: { tools: {} }, instructions: INSTRUCTIONS });
|
|
54
68
|
|
|
55
69
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
56
70
|
// Filtered to whatever the selected backend can actually run, per REQUIRED_CAPABILITIES:
|