cdpm-mcp 0.1.5 → 0.1.6

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.
@@ -10,6 +10,7 @@ export const CDPM_RULES = `${START}
10
10
  ## CDPM (Chrome slot MCP) rules
11
11
 
12
12
  - Reply to the user in the user's language.
13
+ - 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]".
13
14
  - Roles (always, for any job using multiple slots or tabs, on any site):
14
15
  - Main: talks to the user, launches/closes slots, hands work to subagents, merges and reports results. Never navigates, reads or acts on slot screens itself.
15
16
  - Subagent (cdpm-browser): everything on its one slot: navigation, reading, typing, clicking, detecting login completion, its own part of the output, and signaling other subagents when needed.
@@ -7,32 +7,48 @@ const paint = (slot, text) => {
7
7
  const [r, g, b] = hexToRgb(colorOf(slot));
8
8
  return `\x1b[1;38;2;${r};${g};${b}m${text}\x1b[0m`;
9
9
  };
10
+ /** 맨 앞 "CDPM" 글자: 조금 어두운 흰색, 굵게 안 함 (색을 쓸 때) */
11
+ const LABEL = (color) => (color ? 'CDPM ' : 'CDPM ');
10
12
  /** 폭을 모를 때 가정하는 터미널 폭 */
11
13
  export const DEFAULT_WIDTH = 120;
12
14
  /** 제목 길이를 이 순서로 줄여 가며 한 줄에 맞춘다 */
13
15
  const TITLE_STEPS = [20, 16, 12, 8, 5];
14
16
  /**
15
17
  * "CDPM 1 NAVER 2 Daum 3": 슬롯 번호(슬롯 색), 번호 순서. 슬롯마다 마지막으로 조작한 탭의 페이지 제목.
16
- * 터미널 폭(width)에 맞춘다: 넘치면 제목을 점점 짧게 → 그래도 넘치면 번호만 → 그래도 넘치면 앞에서부터 들어가는 만큼 + "+N".
17
- * 하나도 없으면 흐린 "CDPM -".
18
+ * 터미널 폭(width)에 맞춘다: 넘치면 제목을 점점 짧게 → 모두에게 붙일 수 없으면 들어가는 만큼 앞 슬롯부터 짧은 제목
19
+ * (남는 칸을 비워 두지 않게) → 번호만으로도 넘치면 앞에서부터 들어가는 만큼 + "+N".
20
+ * 하나도 없으면 "CDPM -" (CDPM은 흰색, -는 흐린 회색).
18
21
  */
19
22
  export function formatStatusline(entries, color = true, width = DEFAULT_WIDTH) {
20
23
  // 켜진 슬롯이 없으면 줄이 비어 보이지 않게 흐린 회색으로 "CDPM -"
21
24
  if (!entries.length)
22
- return color ? 'CDPM -' : 'CDPM -';
25
+ return color ? `${LABEL(true)}-` : 'CDPM -';
23
26
  const sorted = [...entries].sort(([a], [b]) => a - b);
24
27
  const room = Math.max(20, width - 2); // 끝에 여유 2칸
25
28
  // 멈춘 슬롯은 번호를 슬롯 색 대신 흐린 회색으로 (글자는 늘리지 않아 폭이 그대로)
26
29
  const mark = (slot, rec) => (!color ? String(slot) : rec?.paused ? '' + slot + '' : paint(slot, String(slot)));
27
30
  // 폭은 색 코드를 뺀 실제 글자로 잰다
28
31
  const num = (slot, _rec) => String(slot);
29
- const plain = (titleMax) => 'CDPM ' + sorted.map(([slot, rec]) => (titleMax && rec.title ? `${num(slot, rec)} ${truncate(rec.title, titleMax)}` : num(slot, rec))).join(' ');
30
- const build = (titleMax) => 'CDPM ' + sorted.map(([slot, rec]) => (titleMax && rec.title ? `${mark(slot, rec)} ${truncate(rec.title, titleMax)}` : mark(slot, rec))).join(' ');
32
+ // titles[i]: i번째 슬롯 제목 길이 (null = 번호만)
33
+ const plain = (titles) => 'CDPM ' + sorted.map(([slot, rec], i) => (titles[i] && rec.title ? `${num(slot, rec)} ${truncate(rec.title, titles[i])}` : num(slot, rec))).join(' ');
34
+ const build = (titles) => LABEL(color) + sorted.map(([slot, rec], i) => (titles[i] && rec.title ? `${mark(slot, rec)} ${truncate(rec.title, titles[i])}` : mark(slot, rec))).join(' ');
35
+ const all = (t) => sorted.map(() => t);
31
36
  for (const t of TITLE_STEPS)
32
- if (displayWidth(plain(t)) <= room)
33
- return build(t);
34
- if (displayWidth(plain(null)) <= room)
35
- return build(null);
37
+ if (displayWidth(plain(all(t))) <= room)
38
+ return build(all(t));
39
+ if (displayWidth(plain(all(null))) <= room) {
40
+ // 모두에게는 못 붙여도, 남는 칸만큼 앞 슬롯부터 가장 짧은 제목을 붙인다
41
+ const titles = all(null);
42
+ const min = TITLE_STEPS[TITLE_STEPS.length - 1];
43
+ for (let i = 0; i < sorted.length; i++) {
44
+ if (!sorted[i][1].title)
45
+ continue;
46
+ titles[i] = min;
47
+ if (displayWidth(plain(titles)) > room)
48
+ titles[i] = null;
49
+ }
50
+ return build(titles);
51
+ }
36
52
  // 번호만으로도 넘치면 앞에서부터 들어가는 만큼만 + 나머지 개수
37
53
  const shown = [];
38
54
  let used = displayWidth('CDPM ');
@@ -41,11 +57,11 @@ export function formatStatusline(entries, color = true, width = DEFAULT_WIDTH) {
41
57
  const left = sorted.length - i - 1; // 이걸 넣고 나서 남는 개수
42
58
  const tail = left ? displayWidth(` +${left}`) : 0;
43
59
  if (used + add + tail > room)
44
- return 'CDPM ' + shown.join(' ') + ` +${sorted.length - i}`;
60
+ return LABEL(color) + shown.join(' ') + ` +${sorted.length - i}`;
45
61
  shown.push(mark(sorted[i][0], sorted[i][1]));
46
62
  used += add;
47
63
  }
48
- return 'CDPM ' + shown.join(' ');
64
+ return LABEL(color) + shown.join(' ');
49
65
  }
50
66
  /**
51
67
  * 상태줄 한 줄. 기록부에 있고 프로세스가 살아 있는 슬롯 중에서, 실제로 탭(창)이 있는 슬롯만 보여준다.
@@ -32,6 +32,8 @@ function load() {
32
32
  const IsWindowVisible = user32.func('bool __stdcall IsWindowVisible(void *hwnd)');
33
33
  const GetWindow = user32.func('void * __stdcall GetWindow(void *hwnd, uint32 cmd)');
34
34
  const GetClassNameW = user32.func('int __stdcall GetClassNameW(void *hwnd, _Out_ uint8_t *buf, int max)');
35
+ const GetWindowTextW = user32.func('int __stdcall GetWindowTextW(void *hwnd, _Out_ uint8_t *buf, int max)');
36
+ const IsIconic = user32.func('bool __stdcall IsIconic(void *hwnd)');
35
37
  const LoadImageW = user32.func('void * __stdcall LoadImageW(void *inst, str16 name, uint32 type, int cx, int cy, uint32 flags)');
36
38
  const SendMessageTimeoutW = user32.func('intptr __stdcall SendMessageTimeoutW(void *hwnd, uint32 msg, uintptr w, void *l, uint32 flags, uint32 timeout, void *result)');
37
39
  const GetSystemMetrics = user32.func('int __stdcall GetSystemMetrics(int index)');
@@ -85,6 +87,33 @@ function load() {
85
87
  }
86
88
  return found;
87
89
  },
90
+ ownedWindowsOf(pid) {
91
+ const found = [];
92
+ const cb = koffi.register((hwnd) => {
93
+ const p = [0];
94
+ GetWindowThreadProcessId(hwnd, p);
95
+ const owner = p[0] === pid ? GetWindow(hwnd, 4 /* GW_OWNER */) : null;
96
+ if (owner) {
97
+ const cls = Buffer.alloc(512);
98
+ const n = GetClassNameW(hwnd, cls, 256);
99
+ if (cls.toString('utf16le', 0, n * 2) === 'Chrome_WidgetWin_1') {
100
+ const buf = Buffer.alloc(1024);
101
+ const m = GetWindowTextW(hwnd, buf, 512);
102
+ const title = buf.toString('utf16le', 0, m * 2);
103
+ if (title)
104
+ found.push({ hwnd, key: String(koffi.address(hwnd)), title, visible: IsWindowVisible(hwnd), ownerMinimized: IsIconic(owner) });
105
+ }
106
+ }
107
+ return true;
108
+ }, koffi.pointer(EnumProc));
109
+ try {
110
+ EnumWindows(cb, 0);
111
+ }
112
+ finally {
113
+ koffi.unregister(cb);
114
+ }
115
+ return found;
116
+ },
88
117
  windowKey(hwnd) {
89
118
  return String(koffi.address(hwnd));
90
119
  },
@@ -5,6 +5,7 @@ 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
7
  import { probe } from '../cdp/targets.js';
8
+ import { bubbleDetail, bubbleLine, hostsOf, permissionBubbles, pressBubble } from '../chrome/bubbles.js';
8
9
  import { describeProxy, parseProxy } from '../chrome/proxy.js';
9
10
  import { isClaudeCode } from '../client-info.js';
10
11
  import { CdpmError } from '../errors.js';
@@ -101,6 +102,9 @@ async function header(slot, agent, tabs, opts = {}) {
101
102
  if (blocks.length)
102
103
  warnings.push(`[${t.id}] blocking requests: ${blocks.map((b) => `${b.pattern} (${b.agent})`).join(', ')}`);
103
104
  }
105
+ // Chrome 권한 요청 말풍선 (페이지 밖 브라우저 화면이라 스냅샷에 안 보인다)
106
+ for (const b of permissionBubbles(slot, hostsOf(tabs.map((t) => t.url))))
107
+ warnings.push(bubbleLine(b, await bubbleDetail(b)));
104
108
  const dialogs = dialogsOf(slot, tabs);
105
109
  // 탭 목록이 이 에이전트가 지난번에 본 것과 같고 경고·알림창·메시지도 없으면 한 줄로 (읽을 양을 줄여 다음 판단이 빨라지게)
106
110
  const key = `${slot}:${agent}`;
@@ -566,6 +570,55 @@ export function registerTools(server) {
566
570
  'beforeunload: accept = leave page (input lost), dismiss = stay. For prompt, text is the input.',
567
571
  inputSchema: { slot: slotArg, agent: agentArg, tab: tabArg, multiSlot: multiSlotArg, accept: z.boolean().describe('true = OK, false = cancel'), text: z.string().optional().describe('Text for a prompt dialog (used only when accepting)'), read: readArg, summary: summaryArg },
568
572
  }, async (args) => onTab(args, 'action', 'dialog', async (s) => ({ text: await act.handleDialog(s, args.accept, args.text) }), { render: false }));
573
+ server.registerTool('browser_permission', {
574
+ title: 'Answer permission bubble',
575
+ description: 'Lists or answers Chrome permission bubbles ("site wants to: access other apps and services on this device / show notifications / know your location…"). ' +
576
+ 'They are browser UI: not in snapshot/screenshot, page tools can\'t click them, and the page often waits until they are answered. The header warns when one is open. ' +
577
+ 'Without button: shows the open bubbles with their exact button names. With button: presses that button (exact name as listed, e.g. "허용", "Allow", "Block", "Allow while visiting the site"). Windows, windowed slots only.',
578
+ inputSchema: {
579
+ slot: slotArg, agent: agentArg, multiSlot: multiSlotArg,
580
+ button: z.string().optional().describe('Exact button name to press, as listed in the header or by calling without button'),
581
+ site: z.string().optional().describe('Only when several bubbles are open: part of the bubble title (e.g. the site host) to pick one'),
582
+ },
583
+ }, async ({ slot, agent, multiSlot, button, site }) => guard(async () => {
584
+ const me = agent ?? DEFAULT_AGENT;
585
+ if (button) {
586
+ const refused = multiSlotRefusal(me, slot, multiSlot) ?? pausedRefusal(slot);
587
+ if (refused)
588
+ return textResult(refused, true);
589
+ }
590
+ await attachSlot(slot);
591
+ const tabs = await syncTabs(slot);
592
+ const head = async () => header(slot, me, await syncTabs(slot).catch(() => tabs), { skipMessages: true });
593
+ if (process.platform !== 'win32')
594
+ return textResult(`${await head()}\n---\nPermission bubbles can only be detected and answered on Windows.`, true);
595
+ const hosts = hostsOf(tabs.map((t) => t.url));
596
+ const all = permissionBubbles(slot, hosts);
597
+ const list = site ? all.filter((b) => b.title.includes(site)) : all;
598
+ if (!list.length)
599
+ return textResult(`${await head()}\n---\nNo Chrome permission bubble is open on slot ${slot}${site ? ` matching "${site}"` : ''}.`);
600
+ if (!button) {
601
+ const lines = await Promise.all(list.map(async (b) => `- ${bubbleLine(b, await bubbleDetail(b))}`));
602
+ return textResult(`${await head()}\n---\n${lines.join('\n')}`);
603
+ }
604
+ if (list.length > 1)
605
+ return textResult(`${await head()}\n---\n${list.length} bubbles are open; pass site to pick one: ${list.map((b) => `"${b.title}"`).join(', ')}`, true);
606
+ const b = list[0];
607
+ if (!(await pressBubble(b, button))) {
608
+ const d = await bubbleDetail(b);
609
+ return textResult(`${await head()}\n---\nNo button named "${button}" in "${b.title}".${d?.buttons.length ? ` Buttons: ${d.buttons.join(', ')}.` : ''}`, true);
610
+ }
611
+ // 눌린 뒤 말풍선이 닫혔는지 확인 (보통 바로 닫힌다)
612
+ let gone = false;
613
+ for (let i = 0; i < 10 && !gone; i++) {
614
+ await sleep(100);
615
+ gone = !permissionBubbles(slot, hosts).some((x) => x.key === b.key && x.title === b.title);
616
+ }
617
+ const target = tabs.find((t) => hostsOf([t.url]).some((h) => b.title.includes(h)));
618
+ if (target)
619
+ await recordAction(slot, target.targetId, me, `permission: ${button}`, undefined, !agent).catch(() => false);
620
+ return textResult(`${await head()}\n---\nPressed "${button}" on "${b.title}"${target ? ` (tab ${target.no} [${target.id}])` : ''}${gone ? '; the bubble closed.' : '; the bubble is still open (check again).'}`);
621
+ }));
569
622
  server.registerTool('browser_hover', {
570
623
  title: 'Hover',
571
624
  description: 'Moves the real mouse over a ref element (no click). For hover menus and tooltips. Use read=changes to see the opened menu.',
@@ -709,11 +762,17 @@ export function registerTools(server) {
709
762
  response: z.string().optional().describe('Until a network response whose URL contains this completes (e.g. "/api/search"). * ? wildcards work (matched against the full URL, e.g. "*api.example.com/v1/items*"). Returns the response body'),
710
763
  },
711
764
  }, async (args) => onTab(args, 'view', null, async (s, _tab, agent) => {
765
+ // 기다리는 동안 새로 뜬 권한 말풍선도 바로 알린다 (이미 떠 있던 것은 머리말로 이미 알렸으니 제외)
766
+ const hosts = hostsOf((await syncTabs(args.slot).catch(() => [])).map((t) => t.url));
767
+ const known = new Set(permissionBubbles(args.slot, hosts).map((b) => `${b.key}|${b.title}`));
712
768
  // 다른 에이전트가 메시지를 보내면 기다리기를 바로 멈춘다 (메시지는 결과 머리말로 전달됨)
713
769
  const stop = () => {
714
770
  if (pausedInfo(args.slot))
715
771
  return pausedRefusal(args.slot);
716
- return hasUnread(args.slot, agent) ? 'Stopped waiting: a new message arrived (see it in the header above and continue).' : undefined;
772
+ if (hasUnread(args.slot, agent))
773
+ return 'Stopped waiting: a new message arrived (see it in the header above and continue).';
774
+ const fresh = permissionBubbles(args.slot, hosts).find((b) => !known.has(`${b.key}|${b.title}`));
775
+ return fresh ? `Stopped waiting: Chrome showed a permission bubble "${fresh.title}" (see the header above; answer it with browser_permission).` : undefined;
717
776
  };
718
777
  if (args.response !== undefined) {
719
778
  if (!args.response.trim())
@@ -901,33 +960,35 @@ export function registerTools(server) {
901
960
  return textResult(`[Slot ${slot}] No new messages${wait ? ` (waited ${wait}s)` : ''}.${tail}`);
902
961
  }));
903
962
  }
904
- 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}).
905
- - Always reply to the user in the language the user writes in (these instructions are in English only to save tokens).
906
- - "Look at 3" / "slot 3" means slot=3. Pass slot to every tool.
907
- - 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).
908
- - 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).
909
- - 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).
910
- - 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.
911
- - 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).
912
- - Roles of main agent and subagents (multi-slot/multi-tab work, any site, always):
913
- - 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.
914
- - 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.
915
- - Simple jobs that need just one slot can be done by main directly.
916
- - 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).
917
- - Outputs (reports, HTML, etc.) are written by each subagent for its share; main only merges (main writing everything alone is the slowest step).
918
- - 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.
919
- - 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.
920
- - 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).
921
- - 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.
922
- - 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.
923
- - Keep waits minimal. Never use fixed waits (seconds).
924
- - 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.
925
- - 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.
926
- - 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.
927
- - Other slots' pages can be viewed anytime with view tools (browser_snapshot, browser_text, browser_screenshot); only that slot's owner operates it.
928
- - Never change window size/position or viewport. Use browser_tab_select (changes the tab the user sees) only when the user wants it.
929
- - "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).
930
- - 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.).`;
963
+ 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}).
964
+ - Always reply to the user in the language the user writes in (these instructions are in English only to save tokens).
965
+ - 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).
966
+ - "Look at 3" / "slot 3" means slot=3. Pass slot to every tool.
967
+ - 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).
968
+ - 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).
969
+ - 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).
970
+ - 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.
971
+ - 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).
972
+ - Roles of main agent and subagents (multi-slot/multi-tab work, any site, always):
973
+ - 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.
974
+ - 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.
975
+ - Simple jobs that need just one slot can be done by main directly.
976
+ - 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).
977
+ - Outputs (reports, HTML, etc.) are written by each subagent for its share; main only merges (main writing everything alone is the slowest step).
978
+ - 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.
979
+ - 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.
980
+ - 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).
981
+ - 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.
982
+ - 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.
983
+ - Keep waits minimal. Never use fixed waits (seconds).
984
+ - 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.
985
+ - 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.
986
+ - 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.
987
+ - Other slots' pages can be viewed anytime with view tools (browser_snapshot, browser_text, browser_screenshot); only that slot's owner operates it.
988
+ - Never change window size/position or viewport. Use browser_tab_select (changes the tab the user sees) only when the user wants it.
989
+ - "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).
990
+ - 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.).
991
+ - 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.`;
931
992
  /** Claude Code가 아닌 클라이언트(Cursor, Claude Desktop 등)용: Agent 도구·run_in_background·cdpm-browser처럼 Claude Code에만 있는 말을 뺀다. */
932
993
  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). ' +
933
994
  'Without subagents, process slots in turn with a distinct agent name per slot (e.g. "slot1-agent", "slot2-agent"); the same agent name operating another slot within 60s is refused.';
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
- {
2
- "name": "cdpm-mcp",
3
- "version": "0.1.5",
4
- "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",
5
- "type": "module",
6
- "bin": {
7
- "cdpm": "dist/cli.js"
8
- },
9
- "main": "dist/index.js",
10
- "files": [
11
- "dist",
12
- "README.md",
13
- "README.ko.md",
14
- "CHANGELOG.md",
15
- "LICENSE"
16
- ],
17
- "scripts": {
18
- "build": "tsc -p tsconfig.json && node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
19
- "prepare": "tsc -p tsconfig.json && node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
20
- "build:test": "tsc -p tsconfig.json && tsc -p tsconfig.test.json",
21
- "test": "npm run build:test && node --test --test-concurrency=1 \"dist-test/test/unit/*.test.js\"",
22
- "test:integration": "npm run build:test && node --test --test-concurrency=1 \"dist-test/test/integration/*.test.js\"",
23
- "test:long": "npm run build:test && node --test --test-concurrency=1 \"dist-test/test/long/*.test.js\"",
24
- "prepublishOnly": "npm run build"
25
- },
26
- "keywords": [
27
- "mcp",
28
- "cdp",
29
- "chrome",
30
- "devtools-protocol",
31
- "claude",
32
- "multi-agent",
33
- "browser-automation"
34
- ],
35
- "author": "IGELHARINE",
36
- "license": "MIT",
37
- "engines": {
38
- "node": ">=22"
39
- },
40
- "os": [
41
- "win32",
42
- "darwin",
43
- "linux"
44
- ],
45
- "dependencies": {
46
- "@modelcontextprotocol/sdk": "1.32.1",
47
- "zod": "4.6.5"
48
- },
49
- "devDependencies": {
50
- "@types/node": "26.6.4",
51
- "typescript": "6.0.3"
52
- },
53
- "optionalDependencies": {
54
- "koffi": "3.3.2"
55
- },
56
- "repository": {
57
- "type": "git",
58
- "url": "git+https://github.com/IGELHARINE/CDPM.git"
59
- },
60
- "homepage": "https://github.com/IGELHARINE/CDPM#readme",
61
- "bugs": {
62
- "url": "https://github.com/IGELHARINE/CDPM/issues"
63
- }
64
- }
1
+ {
2
+ "name": "cdpm-mcp",
3
+ "version": "0.1.6",
4
+ "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",
5
+ "type": "module",
6
+ "bin": {
7
+ "cdpm": "dist/cli.js"
8
+ },
9
+ "main": "dist/index.js",
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "README.ko.md",
14
+ "CHANGELOG.md",
15
+ "LICENSE"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -p tsconfig.json && node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
19
+ "prepare": "tsc -p tsconfig.json && node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
20
+ "build:test": "tsc -p tsconfig.json && tsc -p tsconfig.test.json",
21
+ "test": "npm run build:test && node --test --test-concurrency=1 \"dist-test/test/unit/*.test.js\"",
22
+ "test:integration": "npm run build:test && node --test --test-concurrency=1 \"dist-test/test/integration/*.test.js\"",
23
+ "test:long": "npm run build:test && node --test --test-concurrency=1 \"dist-test/test/long/*.test.js\"",
24
+ "prepublishOnly": "npm run build"
25
+ },
26
+ "keywords": [
27
+ "mcp",
28
+ "cdp",
29
+ "chrome",
30
+ "devtools-protocol",
31
+ "claude",
32
+ "multi-agent",
33
+ "browser-automation"
34
+ ],
35
+ "author": "IGELHARINE",
36
+ "license": "MIT",
37
+ "engines": {
38
+ "node": ">=22"
39
+ },
40
+ "os": [
41
+ "win32",
42
+ "darwin",
43
+ "linux"
44
+ ],
45
+ "dependencies": {
46
+ "@modelcontextprotocol/sdk": "1.32.1",
47
+ "zod": "4.6.5"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "26.6.4",
51
+ "typescript": "6.0.3"
52
+ },
53
+ "optionalDependencies": {
54
+ "koffi": "3.3.2"
55
+ },
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/IGELHARINE/CDPM.git"
59
+ },
60
+ "homepage": "https://github.com/IGELHARINE/CDPM#readme",
61
+ "bugs": {
62
+ "url": "https://github.com/IGELHARINE/CDPM/issues"
63
+ }
64
+ }