cdpm-mcp 0.1.8 → 0.1.12
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 +131 -89
- package/README.ko.md +326 -277
- package/README.md +249 -200
- package/dist/agent-setup.js +23 -23
- package/dist/cdp/client.js +13 -9
- package/dist/cdp/downloads.js +4 -1
- package/dist/cdp/sessions.js +45 -24
- package/dist/cdp/targets.js +12 -1
- package/dist/chrome/bubbles.js +14 -14
- package/dist/chrome/launcher.js +3 -0
- package/dist/claude-md-setup.js +22 -22
- package/dist/cli.js +6 -4
- package/dist/page/actions.js +248 -143
- package/dist/page/keys.js +1 -1
- package/dist/page/snapshot.js +11 -5
- package/dist/proxy-forwarder.js +17 -11
- package/dist/registry/lock.js +47 -4
- package/dist/registry/messages.js +28 -13
- package/dist/registry/store.js +19 -7
- package/dist/service.js +5 -5
- package/dist/taskbar/dock.js +31 -31
- package/dist/taskbar/icon-gdi.js +158 -158
- package/dist/taskbar/watcher.js +4 -0
- package/dist/tools/register.js +105 -73
- package/package.json +65 -64
package/dist/tools/register.js
CHANGED
|
@@ -4,7 +4,7 @@ import { z } from 'zod';
|
|
|
4
4
|
import { wildcard } from '../cdp/network.js';
|
|
5
5
|
import { browserConnection, forgetSlotVisibility, knownDialog, onAgentForgotten, pageSession, touchAgent } from '../cdp/sessions.js';
|
|
6
6
|
import { ensureDownloadTracking, waitDownload } from '../cdp/downloads.js';
|
|
7
|
-
import { probe } from '../cdp/targets.js';
|
|
7
|
+
import { listPrintPreviews, probe } from '../cdp/targets.js';
|
|
8
8
|
import { bubbleDetail, bubbleLine, hostsOf, permissionBubbles, pressBubble } from '../chrome/bubbles.js';
|
|
9
9
|
import { describeProxy, parseProxy } from '../chrome/proxy.js';
|
|
10
10
|
import { isClaudeCode } from '../client-info.js';
|
|
@@ -28,6 +28,8 @@ const recentSlots = new Map();
|
|
|
28
28
|
/**
|
|
29
29
|
* 한 에이전트는 한 슬롯만 맡는다 (병렬 처리 강제). 같은 에이전트가 60초 안에 다른 슬롯을 쓰려 하면 거절하고
|
|
30
30
|
* 서브에이전트로 나누라고 돌려보낸다. 정말 한 에이전트가 여러 슬롯을 함께 봐야 하면(비교 등) multiSlot: true.
|
|
31
|
+
* 여기서는 검사만 한다. 기록은 그 슬롯에서 실제로 조작을 시작할 때(markSlotUsed) 한다
|
|
32
|
+
* (꺼진 슬롯·잘못 친 번호·멈춘 슬롯에 대한 시도가 원래 맡은 슬롯을 60초 동안 막지 않게).
|
|
31
33
|
*/
|
|
32
34
|
function multiSlotRefusal(agent, slot, allowed) {
|
|
33
35
|
touchAgent(agent);
|
|
@@ -36,6 +38,7 @@ function multiSlotRefusal(agent, slot, allowed) {
|
|
|
36
38
|
for (const [k, at] of m)
|
|
37
39
|
if (now - at > 60_000)
|
|
38
40
|
m.delete(k);
|
|
41
|
+
recentSlots.set(agent, m);
|
|
39
42
|
const others = [...m.keys()].filter((k) => k !== slot).sort((x, y) => x - y);
|
|
40
43
|
if (others.length && !allowed) {
|
|
41
44
|
const how = isClaudeCode()
|
|
@@ -45,10 +48,13 @@ function multiSlotRefusal(agent, slot, allowed) {
|
|
|
45
48
|
return `Refused: ${agent} just used slot ${others.join(', ')}, so it won't take slot ${slot}. ` + how +
|
|
46
49
|
`If one agent must handle several slots together (e.g. comparing), call again with multiSlot: true.`;
|
|
47
50
|
}
|
|
48
|
-
m.set(slot, now);
|
|
49
|
-
recentSlots.set(agent, m);
|
|
50
51
|
return undefined;
|
|
51
52
|
}
|
|
53
|
+
function markSlotUsed(agent, slot) {
|
|
54
|
+
const m = recentSlots.get(agent) ?? new Map();
|
|
55
|
+
m.set(slot, Date.now());
|
|
56
|
+
recentSlots.set(agent, m);
|
|
57
|
+
}
|
|
52
58
|
export const DEFAULT_AGENT = `claude-${randomBytes(2).toString('hex')}`;
|
|
53
59
|
const SLOT_RANGE = `slot must be a number ${MIN_SLOT}-${MAX_SLOT}`;
|
|
54
60
|
const slotArg = z.number({ error: (iss) => (iss.input === undefined ? `slot is required (number ${MIN_SLOT}-${MAX_SLOT})` : SLOT_RANGE) }).int(SLOT_RANGE).min(MIN_SLOT, SLOT_RANGE).max(MAX_SLOT, SLOT_RANGE)
|
|
@@ -118,6 +124,12 @@ async function header(slot, agent, tabs, opts = {}) {
|
|
|
118
124
|
// Chrome 권한 요청 말풍선 (페이지 밖 브라우저 화면이라 스냅샷에 안 보인다)
|
|
119
125
|
for (const b of permissionBubbles(slot, hostsOf(tabs.map((t) => t.url))))
|
|
120
126
|
warnings.push(bubbleLine(b, await bubbleDetail(b)));
|
|
127
|
+
// 인쇄 미리보기 (탭 목록에는 안 넣는다). 어느 탭 것인지는 제목으로 맞춘다
|
|
128
|
+
for (const p of await listPrintPreviews(slot).catch(() => [])) {
|
|
129
|
+
const owners = tabs.filter((t) => t.title === p.title);
|
|
130
|
+
const where = owners.length === 1 ? `tab ${owners[0].no} [${owners[0].id}]` : `"${truncate(p.title, 40)}"`;
|
|
131
|
+
warnings.push(`Print dialog open on ${where}. ${act.PRINT_NOTE}`);
|
|
132
|
+
}
|
|
121
133
|
const dialogs = dialogsOf(slot, tabs);
|
|
122
134
|
// 탭 목록이 이 에이전트가 지난번에 본 것과 같고 경고·알림창·메시지도 없으면 한 줄로 (읽을 양을 줄여 다음 판단이 빨라지게)
|
|
123
135
|
const key = `${slot}:${agent}`;
|
|
@@ -172,8 +184,10 @@ async function onTab(args, kind, action, fn, opts = {}) {
|
|
|
172
184
|
const warnings = kind === 'action' ? ownershipWarnings(tab, agent) : [];
|
|
173
185
|
const before = new Set(tabs.map((t) => t.targetId));
|
|
174
186
|
const session = await pageSession(slot, tab.targetId);
|
|
175
|
-
if (kind === 'action')
|
|
187
|
+
if (kind === 'action') {
|
|
188
|
+
markSlotUsed(agent, slot);
|
|
176
189
|
session.actionStartedAt.set(agent, Date.now());
|
|
190
|
+
}
|
|
177
191
|
let out;
|
|
178
192
|
try {
|
|
179
193
|
const exec = async () => {
|
|
@@ -198,8 +212,8 @@ async function onTab(args, kind, action, fn, opts = {}) {
|
|
|
198
212
|
// 멈춤: 하던 조작을 그 자리에서 그만뒀다 → 어떻게 기다릴지 함께 알린다
|
|
199
213
|
if (e instanceof act.PausedInterrupt)
|
|
200
214
|
return textResult(`${e.message}\n${pausedRefusal(slot) ?? ''}`, true);
|
|
201
|
-
// 행동 도중
|
|
202
|
-
if (!(e instanceof act.DialogInterrupt))
|
|
215
|
+
// 행동 도중 알림창·인쇄 미리보기가 뜬 것은 실패가 아니다 (클릭은 이루어졌음).
|
|
216
|
+
if (!(e instanceof act.DialogInterrupt || e instanceof act.PrintInterrupt))
|
|
203
217
|
throw e;
|
|
204
218
|
out = { text: `Action done. Then: ${e.message}` };
|
|
205
219
|
}
|
|
@@ -294,8 +308,8 @@ export function registerTools(server) {
|
|
|
294
308
|
const target = slot ? live.filter(([s]) => s === slot) : live;
|
|
295
309
|
if (!target.length)
|
|
296
310
|
return textResult(slot ? `Slot ${slot} Chrome is not running.` : 'No slots running. Start one with browser_launch when the user asks.');
|
|
297
|
-
|
|
298
|
-
|
|
311
|
+
// 슬롯끼리는 서로 상관없으므로 동시에 확인한다 (출력 순서는 슬롯 번호 순 그대로)
|
|
312
|
+
const parts = await Promise.all(target.map(async ([s]) => {
|
|
299
313
|
const tabs = await syncTabs(s).catch(() => null);
|
|
300
314
|
const rec = readRegistry().slots[String(s)];
|
|
301
315
|
let part = formatSlotStatus(s, rec ?? { launchedAt: new Date().toISOString(), nextTabSeq: 1, tabs: {} }, tabs);
|
|
@@ -304,8 +318,8 @@ export function registerTools(server) {
|
|
|
304
318
|
if (d)
|
|
305
319
|
part += `\n [warning] dialog open (${d.type}) ([${t.id}]): "${truncate(d.message, 80)}"`;
|
|
306
320
|
}
|
|
307
|
-
|
|
308
|
-
}
|
|
321
|
+
return part;
|
|
322
|
+
}));
|
|
309
323
|
const me = agent ?? DEFAULT_AGENT;
|
|
310
324
|
return textResult(`${parts.join('\n\n')}\n\n(your name: ${me})`);
|
|
311
325
|
}));
|
|
@@ -601,6 +615,8 @@ export function registerTools(server) {
|
|
|
601
615
|
return textResult(refused, true);
|
|
602
616
|
}
|
|
603
617
|
await attachSlot(slot);
|
|
618
|
+
if (button)
|
|
619
|
+
markSlotUsed(me, slot);
|
|
604
620
|
const tabs = await syncTabs(slot);
|
|
605
621
|
const head = async () => header(slot, me, await syncTabs(slot).catch(() => tabs), { skipMessages: true });
|
|
606
622
|
if (process.platform !== 'win32')
|
|
@@ -778,6 +794,14 @@ export function registerTools(server) {
|
|
|
778
794
|
// 기다리는 동안 새로 뜬 권한 말풍선도 바로 알린다 (이미 떠 있던 것은 머리말로 이미 알렸으니 제외)
|
|
779
795
|
const hosts = hostsOf((await syncTabs(args.slot).catch(() => [])).map((t) => t.url));
|
|
780
796
|
const known = new Set(permissionBubbles(args.slot, hosts).map((b) => `${b.key}|${b.title}`));
|
|
797
|
+
// 새로 뜬 인쇄 미리보기 (stop은 동기라서 따로 살펴 둔다)
|
|
798
|
+
const printedBefore = new Set((await listPrintPreviews(args.slot).catch(() => [])).map((p) => p.id));
|
|
799
|
+
const printing = new Set();
|
|
800
|
+
const printWatch = setInterval(() => {
|
|
801
|
+
void listPrintPreviews(args.slot).then((l) => { for (const p of l)
|
|
802
|
+
if (!printedBefore.has(p.id))
|
|
803
|
+
printing.add(p.id); }, () => undefined);
|
|
804
|
+
}, 1000);
|
|
781
805
|
// 다른 에이전트가 메시지를 보내면 기다리기를 바로 멈춘다 (메시지는 결과 머리말로 전달됨)
|
|
782
806
|
const stop = () => {
|
|
783
807
|
if (pausedInfo(args.slot))
|
|
@@ -785,45 +809,52 @@ export function registerTools(server) {
|
|
|
785
809
|
if (hasUnread(args.slot, agent))
|
|
786
810
|
return 'Stopped waiting: a new message arrived (see it in the header above and continue).';
|
|
787
811
|
const fresh = permissionBubbles(args.slot, hosts).find((b) => !known.has(`${b.key}|${b.title}`));
|
|
788
|
-
|
|
812
|
+
if (fresh)
|
|
813
|
+
return `Stopped waiting: Chrome showed a permission bubble "${fresh.title}" (see the header above; answer it with browser_permission).`;
|
|
814
|
+
return printing.size ? 'Stopped waiting: the page opened a print dialog (see the header above).' : undefined;
|
|
789
815
|
};
|
|
790
|
-
|
|
791
|
-
if (
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
816
|
+
try {
|
|
817
|
+
if (args.response !== undefined) {
|
|
818
|
+
if (!args.response.trim())
|
|
819
|
+
throw new CdpmError('Put part of the URL to wait for in response (e.g. "/api/search").');
|
|
820
|
+
// 이 에이전트가 이 탭에서 마지막으로 조작한 뒤(2분 안)의 요청부터. 조작 기록이 없으면 지금부터.
|
|
821
|
+
const last = s.actionStartedAt.get(agent);
|
|
822
|
+
const since = last && Date.now() - last < 120_000 ? last : Date.now();
|
|
823
|
+
try {
|
|
824
|
+
const e = await act.waitForResponse(s, args.response, since, args.timeout ?? 30, stop);
|
|
825
|
+
if (e.failed)
|
|
826
|
+
return { text: `Response failed: ${netLine(e)}` };
|
|
827
|
+
return { text: `Response received: ${netLine(e)}\nURL: ${decodeUrl(e.url).slice(0, 300)}\n\n[Response body]\n${await responseBody(s, e)}` };
|
|
828
|
+
}
|
|
829
|
+
catch (err) {
|
|
830
|
+
if (err instanceof act.WaitStopped)
|
|
831
|
+
return { text: err.message };
|
|
832
|
+
throw err;
|
|
833
|
+
}
|
|
801
834
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
835
|
+
if (args.enabled)
|
|
836
|
+
return { text: await act.waitForEnabled(s, agent, args.enabled, args.timeout ?? 30, stop) };
|
|
837
|
+
if (args.network_idle)
|
|
838
|
+
return { text: await act.waitNetworkIdle(s, args.timeout ?? 15, 500, stop) };
|
|
839
|
+
if (args.text)
|
|
840
|
+
return { text: await act.waitForText(s, args.text, args.timeout ?? 30, stop) };
|
|
841
|
+
if (args.url !== undefined)
|
|
842
|
+
return { text: await act.waitForUrl(s, args.url || undefined, args.timeout ?? 30, stop) };
|
|
843
|
+
if (args.gone)
|
|
844
|
+
return { text: await act.waitForGone(s, args.gone, args.timeout ?? 30, stop) };
|
|
845
|
+
const sec = args.seconds ?? 1;
|
|
846
|
+
const until = Date.now() + sec * 1000;
|
|
847
|
+
while (Date.now() < until) {
|
|
848
|
+
const why = stop();
|
|
849
|
+
if (why)
|
|
850
|
+
return { text: why };
|
|
851
|
+
await sleep(Math.min(100, until - Date.now()));
|
|
806
852
|
}
|
|
853
|
+
return { text: `Waited ${sec}s.` };
|
|
854
|
+
}
|
|
855
|
+
finally {
|
|
856
|
+
clearInterval(printWatch);
|
|
807
857
|
}
|
|
808
|
-
if (args.enabled)
|
|
809
|
-
return { text: await act.waitForEnabled(s, agent, args.enabled, args.timeout ?? 30, stop) };
|
|
810
|
-
if (args.network_idle)
|
|
811
|
-
return { text: await act.waitNetworkIdle(s, args.timeout ?? 15, 500, stop) };
|
|
812
|
-
if (args.text)
|
|
813
|
-
return { text: await act.waitForText(s, args.text, args.timeout ?? 30, stop) };
|
|
814
|
-
if (args.url !== undefined)
|
|
815
|
-
return { text: await act.waitForUrl(s, args.url || undefined, args.timeout ?? 30, stop) };
|
|
816
|
-
if (args.gone)
|
|
817
|
-
return { text: await act.waitForGone(s, args.gone, args.timeout ?? 30, stop) };
|
|
818
|
-
const sec = args.seconds ?? 1;
|
|
819
|
-
const until = Date.now() + sec * 1000;
|
|
820
|
-
while (Date.now() < until) {
|
|
821
|
-
const why = stop();
|
|
822
|
-
if (why)
|
|
823
|
-
return { text: why };
|
|
824
|
-
await sleep(Math.min(100, until - Date.now()));
|
|
825
|
-
}
|
|
826
|
-
return { text: `Waited ${sec}s.` };
|
|
827
858
|
}));
|
|
828
859
|
server.registerTool('browser_eval', {
|
|
829
860
|
title: 'Run JS',
|
|
@@ -973,34 +1004,35 @@ export function registerTools(server) {
|
|
|
973
1004
|
return textResult(`[Slot ${slot}] No new messages${wait ? ` (waited ${wait}s)` : ''}.${tail}`);
|
|
974
1005
|
}));
|
|
975
1006
|
}
|
|
976
|
-
const INSTRUCTIONS_CLAUDE_CODE = `CDPM: controls Chrome slots 1-30 over CDP. Slot N's CDP port is ${PORT_BASE}+N (slot 1 = ${PORT_BASE + 1}).
|
|
977
|
-
- Always reply to the user in the language the user writes in (these instructions are in English only to save tokens).
|
|
978
|
-
- When telling the user about slot work, always name the tab too, not just the slot: e.g. "working in slot 1, tab 3 [t7]" (tab order from the header, plus its ID).
|
|
979
|
-
- "Look at 3" / "slot 3" means slot=3. Pass slot to every tool.
|
|
980
|
-
- Start Chrome with browser_launch only when the user asks. Other tools never start a closed slot. "Start one" with no number → omit slot (lowest free slot).
|
|
981
|
-
- The user decides windowed (visible) vs headless (hidden): headless: true only if they say "headless", "hidden" or "no window"; false for "visible window" or "headful". If unstated, don't guess; ask first (once for multiple slots).
|
|
982
|
-
- If the start page is known, pass url (same for all slots) or urls (per slot) to browser_launch so it opens right away (no separate navigation step for subagents).
|
|
983
|
-
- Different jobs on multiple slots (e.g. "open 3, one for Naver, one for Daum…", "log in on 1 and open another site on 2") run in parallel by default: main only calls browser_launch once (slots/count, start URLs url/urls), then immediately hands each slot to its own subagent. Subagents do everything from the first navigation (main doesn't pre-navigate slots). Call the Agent tool several times in one message, all with run_in_background: true (don't launch one at a time or wait for earlier ones). Keep subagent prompts to 1-3 lines: slot number, agent name (e.g. "naver-agent", passed as agent on every tool), and the task. cdpm-browser already knows CDPM usage and rules (login detection, signaling, minimal waiting), so don't re-explain (long prompts cost time). Use subagent_type "cdpm-browser" (CDPM-specific subagent, fast start) if available. At most 20 subagents run at once; with more than 20 slots, launch 20 first and the rest as they finish. Main never works through slots serially, unless the user asks for sequential order.
|
|
984
|
-
- Different jobs on tabs within one slot (e.g. "log in on slot 1's first tab, do X on another site in the second tab") are split per tab just like slots: one subagent per tab (main doesn't hop between tabs). Each uses only its tab number or opens its own with browser_tab_new, with a distinct agent name per tab (e.g. "slot1-tab1"). Same slot, so the one-agent-one-slot rule doesn't apply, and actions queue per tab and run concurrently. If a tab's job needs another to finish first (e.g. only works after login), its agent waits with slot_inbox(wait) and the other notifies with slot_send as soon as it's done (login carries over to other tabs: same profile).
|
|
985
|
-
- Roles of main agent and subagents (multi-slot/multi-tab work, any site, always):
|
|
986
|
-
- Main: talks with the user, starts/stops slots (one browser_launch / browser_close), assigns slots and tasks to subagents (all in one message), merges results and reports to the user. Main does not navigate, read or operate slot pages.
|
|
987
|
-
- Subagent: one slot only. Does everything: navigation, reading, typing, clicking, detecting completion of user login etc., writing its share of the output, and signaling other subagents if needed.
|
|
988
|
-
- Simple jobs that need just one slot can be done by main directly.
|
|
989
|
-
- One agent operates one slot. If the same agent operates another slot within 60s, CDPM refuses (viewing is fine; use multiSlot: true only for jobs that must operate several slots together).
|
|
990
|
-
- Outputs (reports, HTML, etc.) are written by each subagent for its share; main only merges (main writing everything alone is the slowest step).
|
|
991
|
-
- The header at the top of each result shows the slot's tabs, which tab ran, warnings and new messages. Check it every time to decide the next step.
|
|
992
|
-
- With multiple tabs, pass tab (number or ID "t7") to action tools. When several agents share a slot, open your own tab with browser_tab_new and use its ID. Background tabs can be read and operated as is.
|
|
993
|
-
- Action tools (navigate, click, type, key, back, select, scroll, fill) accept read, which appends the page after the action. If the next decision needs the page, use read instead of a separate read call: text for articles, snapshot when you need buttons/links to click, changes to see only what changed on the same page (shortest).
|
|
994
|
-
- Fill several inputs on one page (login, search filters, etc.) with one browser_fill. File attach: browser_upload (file input ref, or click the "attach" button first, then call without ref). Hover menus: browser_hover; drag/sliders: browser_drag; downloads: click the button, then browser_download_wait returns the saved file path.
|
|
995
|
-
- browser_snapshot returns only page 1 (top) of long pages. Don't page through: to find inputs/buttons use interactive=true or find="title|subject" (| for alternatives); for text content use browser_text. A summary you leave is visible to other agents in browser_status.
|
|
996
|
-
- Keep waits minimal. Never use fixed waits (seconds).
|
|
997
|
-
- Waits that may take minutes (bulk collection/processing, waiting for user login, etc.) are not done by main: hand them to a background subagent (run_in_background: true), then tell the user the status right away and keep the conversation going. While main waits in browser_wait or runs a long foreground shell command, it can't answer the user.
|
|
998
|
-
- When the user must do something (login, identity verification, CAPTCHA, payment approval, on any site), don't ask them to "tell me when done". Start subagents first; each, without touching the page (no reload or re-navigation: it wipes the user's input), detects completion with browser_wait and continues: URL change (url), login form text gone (gone), or text shown only after login (text). If the user provides an ID/password (e.g. headless), type it and log in.
|
|
999
|
-
- When working with other agents (e.g. emailing each other), signal in real time: as soon as your part is done, slot_send(slot=their slot, to=their name) something like "sent"; when waiting for them, don't reload the page repeatedly, use slot_inbox(slot=your slot, wait=120-600) (returns as soon as a message arrives). On a signal, check the page and act right away.
|
|
1000
|
-
- Other slots' pages can be viewed anytime with view tools (browser_snapshot, browser_text, browser_screenshot); only that slot's owner operates it.
|
|
1001
|
-
- Never change window size/position or viewport. Use browser_tab_select (changes the tab the user sees) only when the user wants it.
|
|
1002
|
-
- "Pause N" → slot_pause; "resume" → slot_resume. Actions on a paused slot are refused: its agent must not operate it and waits with slot_inbox(wait=600); on the resume message it re-reads with browser_snapshot and continues (never resumes on its own).
|
|
1003
|
-
- When a dialog (alert/confirm/prompt/beforeunload) appears, judge from its content and accept/dismiss it yourself with browser_dialog. Ask the user only when it confirms an irreversible action they didn't request (payment, deletion, etc.).
|
|
1007
|
+
const INSTRUCTIONS_CLAUDE_CODE = `CDPM: controls Chrome slots 1-30 over CDP. Slot N's CDP port is ${PORT_BASE}+N (slot 1 = ${PORT_BASE + 1}).
|
|
1008
|
+
- Always reply to the user in the language the user writes in (these instructions are in English only to save tokens).
|
|
1009
|
+
- When telling the user about slot work, always name the tab too, not just the slot: e.g. "working in slot 1, tab 3 [t7]" (tab order from the header, plus its ID).
|
|
1010
|
+
- "Look at 3" / "slot 3" means slot=3. Pass slot to every tool.
|
|
1011
|
+
- Start Chrome with browser_launch only when the user asks. Other tools never start a closed slot. "Start one" with no number → omit slot (lowest free slot).
|
|
1012
|
+
- The user decides windowed (visible) vs headless (hidden): headless: true only if they say "headless", "hidden" or "no window"; false for "visible window" or "headful". If unstated, don't guess; ask first (once for multiple slots).
|
|
1013
|
+
- If the start page is known, pass url (same for all slots) or urls (per slot) to browser_launch so it opens right away (no separate navigation step for subagents).
|
|
1014
|
+
- Different jobs on multiple slots (e.g. "open 3, one for Naver, one for Daum…", "log in on 1 and open another site on 2") run in parallel by default: main only calls browser_launch once (slots/count, start URLs url/urls), then immediately hands each slot to its own subagent. Subagents do everything from the first navigation (main doesn't pre-navigate slots). Call the Agent tool several times in one message, all with run_in_background: true (don't launch one at a time or wait for earlier ones). Keep subagent prompts to 1-3 lines: slot number, agent name (e.g. "naver-agent", passed as agent on every tool), and the task. cdpm-browser already knows CDPM usage and rules (login detection, signaling, minimal waiting), so don't re-explain (long prompts cost time). Use subagent_type "cdpm-browser" (CDPM-specific subagent, fast start) if available. At most 20 subagents run at once; with more than 20 slots, launch 20 first and the rest as they finish. Main never works through slots serially, unless the user asks for sequential order.
|
|
1015
|
+
- Different jobs on tabs within one slot (e.g. "log in on slot 1's first tab, do X on another site in the second tab") are split per tab just like slots: one subagent per tab (main doesn't hop between tabs). Each uses only its tab number or opens its own with browser_tab_new, with a distinct agent name per tab (e.g. "slot1-tab1"). Same slot, so the one-agent-one-slot rule doesn't apply, and actions queue per tab and run concurrently. If a tab's job needs another to finish first (e.g. only works after login), its agent waits with slot_inbox(wait) and the other notifies with slot_send as soon as it's done (login carries over to other tabs: same profile).
|
|
1016
|
+
- Roles of main agent and subagents (multi-slot/multi-tab work, any site, always):
|
|
1017
|
+
- Main: talks with the user, starts/stops slots (one browser_launch / browser_close), assigns slots and tasks to subagents (all in one message), merges results and reports to the user. Main does not navigate, read or operate slot pages.
|
|
1018
|
+
- Subagent: one slot only. Does everything: navigation, reading, typing, clicking, detecting completion of user login etc., writing its share of the output, and signaling other subagents if needed.
|
|
1019
|
+
- Simple jobs that need just one slot can be done by main directly.
|
|
1020
|
+
- One agent operates one slot. If the same agent operates another slot within 60s, CDPM refuses (viewing is fine; use multiSlot: true only for jobs that must operate several slots together).
|
|
1021
|
+
- Outputs (reports, HTML, etc.) are written by each subagent for its share; main only merges (main writing everything alone is the slowest step).
|
|
1022
|
+
- The header at the top of each result shows the slot's tabs, which tab ran, warnings and new messages. Check it every time to decide the next step.
|
|
1023
|
+
- With multiple tabs, pass tab (number or ID "t7") to action tools. When several agents share a slot, open your own tab with browser_tab_new and use its ID. Background tabs can be read and operated as is.
|
|
1024
|
+
- Action tools (navigate, click, type, key, back, select, scroll, fill) accept read, which appends the page after the action. If the next decision needs the page, use read instead of a separate read call: text for articles, snapshot when you need buttons/links to click, changes to see only what changed on the same page (shortest).
|
|
1025
|
+
- Fill several inputs on one page (login, search filters, etc.) with one browser_fill. File attach: browser_upload (file input ref, or click the "attach" button first, then call without ref). Hover menus: browser_hover; drag/sliders: browser_drag; downloads: click the button, then browser_download_wait returns the saved file path.
|
|
1026
|
+
- browser_snapshot returns only page 1 (top) of long pages. Don't page through: to find inputs/buttons use interactive=true or find="title|subject" (| for alternatives); for text content use browser_text. A summary you leave is visible to other agents in browser_status.
|
|
1027
|
+
- Keep waits minimal. Never use fixed waits (seconds).
|
|
1028
|
+
- Waits that may take minutes (bulk collection/processing, waiting for user login, etc.) are not done by main: hand them to a background subagent (run_in_background: true), then tell the user the status right away and keep the conversation going. While main waits in browser_wait or runs a long foreground shell command, it can't answer the user.
|
|
1029
|
+
- When the user must do something (login, identity verification, CAPTCHA, payment approval, on any site), don't ask them to "tell me when done". Start subagents first; each, without touching the page (no reload or re-navigation: it wipes the user's input), detects completion with browser_wait and continues: URL change (url), login form text gone (gone), or text shown only after login (text). If the user provides an ID/password (e.g. headless), type it and log in.
|
|
1030
|
+
- When working with other agents (e.g. emailing each other), signal in real time: as soon as your part is done, slot_send(slot=their slot, to=their name) something like "sent"; when waiting for them, don't reload the page repeatedly, use slot_inbox(slot=your slot, wait=120-600) (returns as soon as a message arrives). On a signal, check the page and act right away.
|
|
1031
|
+
- Other slots' pages can be viewed anytime with view tools (browser_snapshot, browser_text, browser_screenshot); only that slot's owner operates it.
|
|
1032
|
+
- Never change window size/position or viewport. Use browser_tab_select (changes the tab the user sees) only when the user wants it.
|
|
1033
|
+
- "Pause N" → slot_pause; "resume" → slot_resume. Actions on a paused slot are refused: its agent must not operate it and waits with slot_inbox(wait=600); on the resume message it re-reads with browser_snapshot and continues (never resumes on its own).
|
|
1034
|
+
- When a dialog (alert/confirm/prompt/beforeunload) appears, judge from its content and accept/dismiss it yourself with browser_dialog. Ask the user only when it confirms an irreversible action they didn't request (payment, deletion, etc.).
|
|
1035
|
+
- If a page opens Chrome's print dialog, the header warns; CDPM does not close it (that tab is frozen until a person does). Tell the user it is open and on which slot and tab, and wait. For a PDF use browser_pdf.
|
|
1004
1036
|
- Chrome permission bubbles ("site wants to access other apps and services on this device", notifications, location, camera, mic…) are browser UI the page can wait on; the header warns when one is open (Windows). Answer it yourself with browser_permission when the task needs it (e.g. a work site asking to reach a local app). Ask the user before allowing camera, microphone or location they didn't ask for.`;
|
|
1005
1037
|
/** Claude Code가 아닌 클라이언트(Cursor, Claude Desktop 등)용: Agent 도구·run_in_background·cdpm-browser처럼 Claude Code에만 있는 말을 뺀다. */
|
|
1006
1038
|
const GENERIC_PARALLEL = '- Different jobs on multiple slots (e.g. "open 3, one for Naver, one for Daum…", "log in on 1 and open another site on 2"): if the client supports subagents, hand each slot to one and run them in parallel (main only launches them with one browser_launch). ' +
|
package/package.json
CHANGED
|
@@ -1,64 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cdpm-mcp",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"README.
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"test": "
|
|
22
|
-
"test
|
|
23
|
-
"test:
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cdpm-mcp",
|
|
3
|
+
"version": "0.1.12",
|
|
4
|
+
"mcpName": "io.github.IGELHARINE/cdpm",
|
|
5
|
+
"description": "CDP Manager - an MCP server that runs Chrome slots 1-30 over CDP so multiple Claude agents can share and drive them by number",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"cdpm": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md",
|
|
14
|
+
"README.ko.md",
|
|
15
|
+
"CHANGELOG.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json && node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
|
|
20
|
+
"prepare": "tsc -p tsconfig.json && node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
|
|
21
|
+
"build:test": "tsc -p tsconfig.json && tsc -p tsconfig.test.json",
|
|
22
|
+
"test": "npm run build:test && node --test --test-concurrency=1 \"dist-test/test/unit/*.test.js\"",
|
|
23
|
+
"test:integration": "npm run build:test && node --test --test-concurrency=1 \"dist-test/test/integration/*.test.js\"",
|
|
24
|
+
"test:long": "npm run build:test && node --test --test-concurrency=1 \"dist-test/test/long/*.test.js\"",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"mcp",
|
|
29
|
+
"cdp",
|
|
30
|
+
"chrome",
|
|
31
|
+
"devtools-protocol",
|
|
32
|
+
"claude",
|
|
33
|
+
"multi-agent",
|
|
34
|
+
"browser-automation"
|
|
35
|
+
],
|
|
36
|
+
"author": "IGELHARINE",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22"
|
|
40
|
+
},
|
|
41
|
+
"os": [
|
|
42
|
+
"win32",
|
|
43
|
+
"darwin",
|
|
44
|
+
"linux"
|
|
45
|
+
],
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@modelcontextprotocol/sdk": "1.32.1",
|
|
48
|
+
"zod": "4.6.5"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "26.6.4",
|
|
52
|
+
"typescript": "6.0.3"
|
|
53
|
+
},
|
|
54
|
+
"optionalDependencies": {
|
|
55
|
+
"koffi": "3.3.2"
|
|
56
|
+
},
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/IGELHARINE/CDPM.git"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/IGELHARINE/CDPM#readme",
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/IGELHARINE/CDPM/issues"
|
|
64
|
+
}
|
|
65
|
+
}
|