cdpm-mcp 0.1.4 → 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.
@@ -22,7 +22,7 @@ export class CdpConnection {
22
22
  const ws = new WebSocket(url);
23
23
  const timer = setTimeout(() => {
24
24
  ws.close();
25
- reject(new CdpmError(`CDP 연결 시간 초과: ${url}`));
25
+ reject(new CdpmError(`CDP connect timed out: ${url}`));
26
26
  }, timeoutMs);
27
27
  ws.addEventListener('open', () => {
28
28
  clearTimeout(timer);
@@ -30,19 +30,19 @@ export class CdpConnection {
30
30
  }, { once: true });
31
31
  ws.addEventListener('error', () => {
32
32
  clearTimeout(timer);
33
- reject(new CdpmError(`CDP 연결 실패: ${url}`));
33
+ reject(new CdpmError(`CDP connect failed: ${url}`));
34
34
  }, { once: true });
35
35
  });
36
36
  }
37
37
  send(method, params = {}, timeoutMs = 30_000, sessionId) {
38
38
  if (this.closed)
39
- return Promise.reject(new CdpmError(`CDP 연결이 끊어졌습니다 (${method}).`));
39
+ return Promise.reject(new CdpmError(`CDP connection closed (${method}).`));
40
40
  const id = this.nextId++;
41
41
  return new Promise((resolve, reject) => {
42
42
  const timer = setTimeout(() => {
43
43
  this.pending.delete(id);
44
- reject(new CdpTimeoutError(`Chrome이 ${Math.round(timeoutMs / 1000)}초 동안 응답하지 않았어요 (${method}). ` +
45
- '페이지가 무겁거나, 네트워크가 느리거나, 알림창이 떠 있을 수 있어요. 잠시 뒤 다시 시도하거나 browser_tabs로 상태를 확인하세요.'));
44
+ reject(new CdpTimeoutError(`Chrome did not respond for ${Math.round(timeoutMs / 1000)}s (${method}). ` +
45
+ 'The page may be heavy, the network slow, or a dialog open. Retry shortly or check with browser_tabs.'));
46
46
  }, timeoutMs);
47
47
  this.pending.set(id, { resolve, reject, timer, method });
48
48
  this.ws.send(JSON.stringify({ id, method, params, ...(sessionId ? { sessionId } : {}) }));
@@ -106,7 +106,7 @@ export class CdpConnection {
106
106
  this.pending.delete(msg.id);
107
107
  clearTimeout(p.timer);
108
108
  if (msg.error)
109
- p.reject(new CdpmError(`${p.method} 실패: ${msg.error.message}`));
109
+ p.reject(new CdpmError(`${p.method} failed: ${msg.error.message}`));
110
110
  else
111
111
  p.resolve(msg.result);
112
112
  return;
@@ -139,7 +139,7 @@ export class CdpConnection {
139
139
  this.closed = true;
140
140
  for (const [, p] of this.pending) {
141
141
  clearTimeout(p.timer);
142
- p.reject(new CdpmError(`CDP 연결이 끊어졌습니다 (${p.method}). 탭이 닫혔거나 Chrome이 종료됐을 수 있어요.`));
142
+ p.reject(new CdpmError(`CDP connection closed (${p.method}). The tab or Chrome may have closed.`));
143
143
  }
144
144
  this.pending.clear();
145
145
  for (const h of this.closedHandlers)
@@ -52,17 +52,17 @@ export async function waitDownload(slot, timeoutSec, stop) {
52
52
  if (d && d.state !== 'inProgress') {
53
53
  d.reported = true;
54
54
  if (d.state === 'canceled')
55
- return `다운로드가 취소됐어요: ${d.file}`;
55
+ return `Download canceled: ${d.file}`;
56
56
  const size = d.totalBytes || d.receivedBytes;
57
- return `다운로드가 끝났어요: ${d.filePath ?? d.file}${size ? ` (${(size / 1024).toFixed(1)}KB)` : ''}`;
57
+ return `Download finished: ${d.filePath ?? d.file}${size ? ` (${(size / 1024).toFixed(1)}KB)` : ''}`;
58
58
  }
59
59
  const why = stop?.();
60
60
  if (why)
61
61
  return why;
62
62
  if (Date.now() > until) {
63
63
  if (d)
64
- return `${timeoutSec}초 안에 다운로드가 끝나지 않았어요: ${d.file} (${d.receivedBytes}/${d.totalBytes || '?'}바이트). 더 기다리려면 다시 부르세요.`;
65
- throw new Error('진행 중이거나 최근에 시작된 다운로드가 없어요. 다운로드 버튼을 누른 뒤에 부르세요.');
64
+ return `Download not finished after ${timeoutSec}s: ${d.file} (${d.receivedBytes}/${d.totalBytes || '?'} bytes). Call again to keep waiting.`;
65
+ throw new Error('No download in progress or recently started. Call this after clicking the download button.');
66
66
  }
67
67
  await new Promise((r) => setTimeout(r, 100));
68
68
  }
@@ -78,7 +78,7 @@ export class PageSession {
78
78
  * 잠금을 잡은 프로세스가 죽으면 바로 풀린다. 다른 세션의 조작이 2분 넘게 끝나지 않으면 기다리지 않고 알린다.
79
79
  */
80
80
  exclusive(fn) {
81
- const locked = () => withFileLock(paths.tabLock(this.slot, this.targetId), fn, TAB_LOCK_WAIT_MS, '다른 Claude 세션이 이 탭을 2분 넘게 조작하고 있어요. 그 세션에 slot_send로 물어보거나 자기 탭(browser_tab_new)에서 하세요.');
81
+ const locked = () => withFileLock(paths.tabLock(this.slot, this.targetId), fn, TAB_LOCK_WAIT_MS, 'Another Claude session has been using this tab for over 2 min. Ask it via slot_send or use your own tab (browser_tab_new).');
82
82
  const run = this.chain.then(locked, locked);
83
83
  this.chain = run.then(() => undefined, () => undefined);
84
84
  return run;
@@ -288,11 +288,11 @@ export class PageSession {
288
288
  /** 붙을 때 탭이 아직 답하지 않음 (알림창이 떠 있거나 무거운 작업 중). 응답이 오면 자동으로 풀린다. */
289
289
  markUnresponsive() {
290
290
  this.pendingEnable = true;
291
- this.dialog ??= { type: '응답 대기', message: '탭이 아직 응답하지 않아요 (알림창이 떠 있거나 무거운 작업 중)', at: new Date().toISOString() };
291
+ this.dialog ??= { type: 'unresponsive', message: 'Tab not responding yet (dialog open or busy)', at: new Date().toISOString() };
292
292
  }
293
293
  /** 붙을 때 보낸 Page.enable이 나중에라도 끝나면: 탭이 다시 움직인다는 신호 */
294
294
  enabledLater() {
295
- if (this.dialog?.type === '응답 대기')
295
+ if (this.dialog?.type === 'unresponsive')
296
296
  this.dialog = undefined;
297
297
  if (this.pendingEnable) {
298
298
  this.pendingEnable = false;
@@ -301,8 +301,8 @@ export class PageSession {
301
301
  }
302
302
  assertNoDialog() {
303
303
  if (this.dialog) {
304
- throw new CdpmError(`이 탭에 ${this.dialog.type} 알림창이 떠 있어요: "${this.dialog.message}"\n` +
305
- '내용을 보고 판단해서 browser_dialog로 직접 처리하세요 (확인 accept: true, 취소 false). 사용자가 시키지 않은 되돌릴 수 없는 일(결제·삭제 등)을 확정하는 창일 때만 사용자에게 물어보세요.');
304
+ throw new CdpmError(`A ${this.dialog.type} dialog is open on this tab: "${this.dialog.message}"\n` +
305
+ 'Read it and handle it yourself with browser_dialog (accept: true = OK, false = cancel). Ask the user only if it confirms something irreversible they did not request (payment, deletion, etc.).');
306
306
  }
307
307
  }
308
308
  }
@@ -385,7 +385,7 @@ export async function browserConnection(slot) {
385
385
  return cached;
386
386
  const p = await probe(slot);
387
387
  if (p.state !== 'chrome')
388
- throw new CdpmError(`${slot}번 Chrome이 떠 있지 않습니다 (포트 ${portOf(slot)}).`);
388
+ throw new CdpmError(`Chrome is not running on slot ${slot} (port ${portOf(slot)}).`);
389
389
  const conn = await CdpConnection.connect(p.version.webSocketDebuggerUrl);
390
390
  conn.onClosed(() => browserConns.delete(slot));
391
391
  browserConns.set(slot, conn);
@@ -409,7 +409,7 @@ export async function pageSession(slot, targetId, wsUrl) {
409
409
  url = t?.webSocketDebuggerUrl;
410
410
  }
411
411
  if (!url)
412
- throw new CdpmError('탭을 찾을 수 없습니다 (닫혔을 수 있어요).');
412
+ throw new CdpmError('Tab not found (it may have been closed).');
413
413
  const conn = await CdpConnection.connect(url);
414
414
  const session = new PageSession(slot, targetId, conn);
415
415
  conn.onClosed(() => pageSessions.delete(key));
@@ -21,7 +21,7 @@ export async function probe(slot, timeoutMs = 1500) {
21
21
  return { state: 'other', detail: `HTTP ${res.status}` };
22
22
  }
23
23
  catch {
24
- return { state: 'other', detail: `HTTP ${res.status} (JSON 아님)` };
24
+ return { state: 'other', detail: `HTTP ${res.status} (not JSON)` };
25
25
  }
26
26
  }
27
27
  /** 탭(page) 목록. Chrome이 돌려주는 순서 그대로 (첫 번째가 가장 최근 활성 탭). */
@@ -0,0 +1,108 @@
1
+ // Windows 전용: Chrome이 띄운 권한 요청 말풍선("○○에서 다음 권한을 요청합니다" 등)을 찾고 버튼을 누른다.
2
+ // 말풍선은 페이지가 아니라 브라우저 화면이라 CDP(스냅샷·스크린샷·클릭)로는 보이지도 눌리지도 않고,
3
+ // 이미 뜬 말풍선은 CDP로 권한을 줘도 닫히지 않는다 (실측). 그래서
4
+ // - 찾기: Chrome 본 창에 딸린 작은 창 중 제목에 탭의 사이트 주소가 들어간 것 (EnumWindows, 1ms 미만).
5
+ // 번역·비밀번호 저장 말풍선은 제목에 주소가 없어서 걸러지고, Chrome 표시 언어와도 상관없다.
6
+ // - 버튼 읽기·누르기: Windows UI Automation (PowerShell, 말풍선이 있을 때만 부른다).
7
+ // 창이 최소화돼 있거나 다른 창에 가려져 있어도 읽고 누를 수 있다 (실측).
8
+ import { execFile } from 'node:child_process';
9
+ import { readRegistry } from '../registry/store.js';
10
+ import { win32 } from '../taskbar/win32.js';
11
+ /** 탭 주소들에서 말풍선 제목과 맞춰 볼 호스트 이름을 뽑는다. */
12
+ export function hostsOf(urls) {
13
+ const hosts = new Set();
14
+ for (const u of urls) {
15
+ try {
16
+ const h = new URL(u).hostname;
17
+ if (h)
18
+ hosts.add(h);
19
+ }
20
+ catch {
21
+ // about:blank 등
22
+ }
23
+ }
24
+ return [...hosts];
25
+ }
26
+ /** 슬롯 Chrome에 떠 있는 권한 요청 말풍선. Windows가 아니거나 창 모드가 아니면 늘 빈 목록. */
27
+ export function permissionBubbles(slot, hosts) {
28
+ const w = win32();
29
+ if (!w || !hosts.length)
30
+ return [];
31
+ const pid = readRegistry().slots[String(slot)]?.pid;
32
+ if (!pid)
33
+ return [];
34
+ try {
35
+ return w.ownedWindowsOf(pid)
36
+ .filter((x) => (x.visible || x.ownerMinimized) && hosts.some((h) => x.title.includes(h)))
37
+ .map((x) => ({ key: x.key, title: x.title, hwnd: x.hwnd }));
38
+ }
39
+ catch {
40
+ return [];
41
+ }
42
+ }
43
+ const UIA_SCRIPT = `
44
+ $OutputEncoding = [Console]::OutputEncoding = [Text.Encoding]::UTF8
45
+ Add-Type -AssemblyName UIAutomationClient, UIAutomationTypes
46
+ $A = [Windows.Automation.AutomationElement]
47
+ $e = $A::FromHandle([IntPtr][long]$env:CDPM_BUBBLE_HWND)
48
+ $type = { param($t) New-Object Windows.Automation.PropertyCondition($A::ControlTypeProperty, $t) }
49
+ $btns = @($e.FindAll('Descendants', (& $type ([Windows.Automation.ControlType]::Button))))
50
+ $texts = @($e.FindAll('Descendants', (& $type ([Windows.Automation.ControlType]::Text))) | ForEach-Object { $_.Current.Name } | Where-Object { $_ })
51
+ $pressed = $null
52
+ if ($env:CDPM_BUBBLE_PRESS) {
53
+ $b = $btns | Where-Object { $_.Current.Name -eq $env:CDPM_BUBBLE_PRESS } | Select-Object -First 1
54
+ if ($b) { $b.GetCurrentPattern([Windows.Automation.InvokePattern]::Pattern).Invoke(); $pressed = $true } else { $pressed = $false }
55
+ }
56
+ @{ texts = @($texts); buttons = @($btns | ForEach-Object { $_.Current.Name } | Where-Object { $_ }); pressed = $pressed } | ConvertTo-Json -Compress
57
+ `;
58
+ const ENCODED = Buffer.from(UIA_SCRIPT, 'utf16le').toString('base64');
59
+ function runUia(b, press) {
60
+ return new Promise((resolve, reject) => {
61
+ execFile('powershell.exe', ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', ENCODED], {
62
+ env: { ...process.env, CDPM_BUBBLE_HWND: b.key, CDPM_BUBBLE_PRESS: press ?? '' },
63
+ timeout: 15_000, windowsHide: true, encoding: 'utf8',
64
+ }, (err, stdout) => {
65
+ if (err)
66
+ return reject(err);
67
+ try {
68
+ const j = JSON.parse(stdout.trim().split('\n').pop() ?? '');
69
+ const arr = (v) => (Array.isArray(v) ? v : v ? [v] : []).map(String);
70
+ resolve({ texts: arr(j.texts), buttons: arr(j.buttons), pressed: typeof j.pressed === 'boolean' ? j.pressed : null });
71
+ }
72
+ catch (e) {
73
+ reject(e);
74
+ }
75
+ });
76
+ });
77
+ }
78
+ /** 같은 말풍선을 매번 다시 읽지 않게 (말풍선 하나에 PowerShell 한 번, 약 0.6초). */
79
+ const details = new Map();
80
+ export async function bubbleDetail(b) {
81
+ const k = `${b.key}|${b.title}`;
82
+ const hit = details.get(k);
83
+ if (hit)
84
+ return hit;
85
+ try {
86
+ const d = await runUia(b);
87
+ if (details.size > 50)
88
+ details.clear();
89
+ details.set(k, { texts: d.texts, buttons: d.buttons });
90
+ return details.get(k);
91
+ }
92
+ catch {
93
+ return undefined;
94
+ }
95
+ }
96
+ /** 말풍선의 버튼을 이름 그대로 누른다. 없는 이름이면 false. */
97
+ export async function pressBubble(b, button) {
98
+ const r = await runUia(b, button);
99
+ details.delete(`${b.key}|${b.title}`);
100
+ return r.pressed === true;
101
+ }
102
+ /** 머리말·기다리기에 쓰는 한 줄 안내. */
103
+ export function bubbleLine(b, d) {
104
+ const what = d?.texts.filter((t) => t !== b.title).join(' / ');
105
+ const buttons = d?.buttons.length ? ` Buttons: ${d.buttons.join(', ')}.` : '';
106
+ return `Chrome permission bubble open: "${b.title}"${what ? ` (${what})` : ''}.${buttons} ` +
107
+ 'It is browser UI (not in snapshot/screenshot; page tools can\'t click it) and the page may be stuck until it is answered. Press a button with browser_permission.';
108
+ }
@@ -41,9 +41,9 @@ export function findChromeWith(deps) {
41
41
  const found = candidates.find((p) => deps.exists(p));
42
42
  if (found)
43
43
  return found;
44
- throw new CdpmError('Chrome을 찾지 못했습니다. 찾아본 경로:\n' +
44
+ throw new CdpmError('Chrome not found. Searched:\n' +
45
45
  candidates.map((c) => ` - ${c}`).join('\n') +
46
- `\n${paths.config()} 파일에 {"chromePath": "Chrome 실행 파일 전체 경로"}를 넣어 직접 지정할 수 있어요.`);
46
+ `\nSet it manually in ${paths.config()}: {"chromePath": "<full path to Chrome executable>"}`);
47
47
  }
48
48
  function regQuery(key) {
49
49
  try {
@@ -32,7 +32,7 @@ export async function launchChrome(slot, opts = {}) {
32
32
  ({ pid } = await spawnOrphan(chrome, [...chromeArgs(slot, opts), ...extra, opts.url || 'about:blank'], { hide: false }));
33
33
  }
34
34
  catch (e) {
35
- throw new CdpmError(`Chrome 실행 실패: ${e.message}`);
35
+ throw new CdpmError(`Failed to launch Chrome: ${e.message}`);
36
36
  }
37
37
  const deadline = Date.now() + READY_TIMEOUT_MS;
38
38
  while (Date.now() < deadline) {
@@ -40,11 +40,11 @@ export async function launchChrome(slot, opts = {}) {
40
40
  if (p.state === 'chrome')
41
41
  return { pid, version: p.version };
42
42
  if (!pidAlive(pid)) {
43
- throw new CdpmError(`${slot}번 Chrome이 켜지자마자 종료됐어요. ` +
44
- `같은 프로필(${paths.profile(slot)})을 쓰는 Chrome이 디버깅 포트 없이 이미 떠 있으면, 새 Chrome은 그쪽에 창만 넘기고 끝나요. 그 창을 닫고 다시 켜 주세요.`);
43
+ throw new CdpmError(`Slot ${slot} Chrome exited right after launch. ` +
44
+ `If a Chrome using the same profile (${paths.profile(slot)}) is already running without a debugging port, the new one hands its window over and exits. Close that window and launch again.`);
45
45
  }
46
46
  await sleep(100);
47
47
  }
48
- throw new CdpmError(`${slot}번 Chrome을 실행했지만 ${READY_TIMEOUT_MS / 1000}초 안에 CDP 포트(${portOf(slot)})가 열리지 않았습니다. ` +
49
- `같은 프로필(${paths.profile(slot)})을 쓰는 Chrome이 디버깅 포트 없이 이미 떠 있을 수 있어요. 그 창을 닫고 다시 시도해 주세요.`);
48
+ throw new CdpmError(`Slot ${slot} Chrome started, but CDP port ${portOf(slot)} did not open within ${READY_TIMEOUT_MS / 1000}s. ` +
49
+ `A Chrome using the same profile (${paths.profile(slot)}) may already be running without a debugging port. Close it and try again.`);
50
50
  }
@@ -12,13 +12,13 @@ const SCHEMES = { http: 'http', https: 'https', socks: 'socks5', socks5: 'socks5
12
12
  */
13
13
  export function parseProxy(input) {
14
14
  let s = input.trim();
15
- const bad = () => new CdpmError(`프록시 주소를 알아보지 못했어요: "${maskProxyText(input)}". 예: 1.2.3.4:8080, http://아이디:비번@1.2.3.4:8080, socks5://1.2.3.4:1080, 1.2.3.4:8080:아이디:비번`);
15
+ const bad = () => new CdpmError(`Unrecognized proxy: "${maskProxyText(input)}". Examples: 1.2.3.4:8080, http://user:pass@1.2.3.4:8080, socks5://1.2.3.4:1080, 1.2.3.4:8080:user:pass`);
16
16
  let scheme = 'http';
17
17
  const m = /^([a-z0-9]+):\/\//i.exec(s);
18
18
  if (m) {
19
19
  const sc = SCHEMES[m[1].toLowerCase()];
20
20
  if (!sc)
21
- throw new CdpmError(`지원하지 않는 프록시 종류예요: ${m[1]} (http, https, socks5, socks4만 돼요)`);
21
+ throw new CdpmError(`Unsupported proxy scheme: ${m[1]} (use http, https, socks5 or socks4)`);
22
22
  scheme = sc;
23
23
  s = s.slice(m[0].length);
24
24
  }
@@ -60,7 +60,7 @@ export function parseProxy(input) {
60
60
  user = dec(user);
61
61
  pass = dec(pass);
62
62
  if (user && scheme === 'socks4')
63
- throw new CdpmError('socks4 프록시는 아이디·비밀번호를 쓸 수 없어요. socks5나 http로 주세요.');
63
+ throw new CdpmError('socks4 proxies do not support username/password. Use socks5 or http.');
64
64
  return { scheme, host: hp[1], port, ...(user ? { user, pass: pass ?? '' } : {}) };
65
65
  }
66
66
  /** 결과에 보여 줄 때: 비밀번호는 가린다. */
@@ -92,6 +92,6 @@ async function startForwarder(slot, p) {
92
92
  return Number(/LISTEN (\d+)/.exec(line ?? '')?.[1]);
93
93
  }
94
94
  catch (e) {
95
- throw new CdpmError(`프록시 중계 프로그램을 띄우지 못했어요: ${e.message}`);
95
+ throw new CdpmError(`Failed to start proxy forwarder: ${e.message}`);
96
96
  }
97
97
  }
@@ -7,23 +7,27 @@ import path from 'node:path';
7
7
  const START = '<!-- CDPM:START (cdpm setup이 관리하는 부분) -->';
8
8
  const END = '<!-- CDPM:END -->';
9
9
  export const CDPM_RULES = `${START}
10
- ## CDPM (Chrome 슬롯 MCP) 사용 규칙
10
+ ## CDPM (Chrome slot MCP) rules
11
11
 
12
- - 역할 구분 (여러 슬롯을 쓰는 작업은 사이트와 상관없이 항상):
13
- - 메인: 사용자와 대화, 슬롯 켜기·끄기, 서브에이전트에게 일 나눠 주기, 결과 합쳐서 보고. 슬롯 화면을 직접 이동·읽기·조작하지 않는다.
14
- - 서브에이전트(cdpm-browser): 맡은 슬롯 하나의 주소 이동·읽기·입력·클릭, 로그인 등 완료 감지, 자기 몫 결과물, 필요하면 다른 서브에이전트와 신호까지 전부.
15
- - 슬롯 하나로 끝나는 간단한 일은 메인이 직접 해도 된다.
16
- - 여러 CDPM 슬롯에 각각 다른 일을 시키면(예: "5개 띄워서 하나는 네이버, 하나는 유튜브…") 메인이 직접 처리하지 않는다.
17
- 1. browser_launch 한 번으로 슬롯을 모두 켠다 (slots 또는 count). 시작 페이지를 알면 url/urls로 켜면서 바로 연다. 메인은 여기까지만 하고, 주소 이동·읽기·조작은 처음부터 서브에이전트가 한다.
18
- 2. 한 메시지 안에서 Agent 도구를 슬롯 수만큼 함께 불러 서브에이전트를 한꺼번에 띄운다. 모두 run_in_background: true로 (앞 서브에이전트가 끝나길 기다리지 않게). subagent_type은 "cdpm-browser"(CDPM 전용, 빨리 시작)를 쓴다.
19
- - 지시는 1~3줄로 짧게: 슬롯 번호, agent 이름(예: "네이버담당"), 할 일만. cdpm-browser는 CDPM 사용법·규칙을 이미 알고 있으니 다시 설명하지 않는다 (긴 지시를 쓰는 시간만큼 늦어진다).
20
- - 서브에이전트는 동시에 20개까지만 뜬다. 슬롯이 20개를 넘으면 20개를 먼저 띄우고 끝나는 대로 나머지를 띄운다 (늘리려면 환경변수 CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS).
21
- 3. 결과물(보고서·HTML 조각·표 등)도 각 서브에이전트가 자기 몫을 써서 돌려주고, 메인은 합치기만 한다.
22
- - 한 에이전트는 한 슬롯만 조작한다 (CDPM이 다른 슬롯 조작을 거절한다. 다른 슬롯 화면 보기는 괜찮다).
23
- - 어느 사이트든 사용자가 로그인·본인 인증·보안문자 등을 해야 해도 "됐다고 알려 달라"고 하지 않는다. 서브에이전트를 먼저 띄워 두고 각자 화면을 건드리지 않고(새로고침 금지) browser_wait url/gone/text로 완료를 감지해 이어서 진행하게 한다.
24
- - 기다림은 최소한으로. 서브에이전트끼리 협업하면(서로 메일 주고받기 등) 일을 끝내는 즉시 slot_send로 상대에게 알리고, 상대를 기다릴 때는 slot_inbox wait로 기다리게 한다 (화면을 반복해서 새로고침하지 않는다). 서브에이전트에게 긴 고정 대기를 지시하지 않는다.
25
- - 화면이 필요하면 조작 도구에 read를 붙여 한 번에 받는다 (글은 text, 누를 게 필요하면 snapshot, 바뀐 것만 보려면 changes).
26
- - When several CDPM slots get different jobs, start one cdpm-browser subagent per slot in a single message (at most 20 at once), let each write its own part of the output, and only merge in the main agent.
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]".
14
+ - Roles (always, for any job using multiple slots or tabs, on any site):
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.
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.
17
+ - A simple job on a single slot can be done by the main agent directly.
18
+ - Windowed (visible) vs headless is the user's call: headless: true only if the user says "headless", "hidden", "no window"; false for "show the window", "headful" (in any language). If unspecified, don't guess; ask first (once for multiple slots).
19
+ - When several CDPM slots get different jobs (e.g. "open 5, one for Naver, one for YouTube...", "log in on slot 1 and open another site on slot 2"), the main agent does not do them itself.
20
+ 1. Launch all slots with one browser_launch (slots or count). If start pages are known, open them at launch with url/urls. The main agent stops there; subagents do all navigation, reading and actions from the start.
21
+ 2. In one message, call the Agent tool once per slot to start all subagents together, each with run_in_background: true (don't wait for one to finish). Use subagent_type "cdpm-browser" (CDPM-only, starts fast).
22
+ - Keep instructions to 1-3 lines: slot number, agent name (e.g. "naver"), task. cdpm-browser already knows CDPM usage and rules; don't repeat them (long instructions only add delay).
23
+ - At most 20 subagents run at once. With more than 20 slots, start 20 first and the rest as they finish (raise via env CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS).
24
+ 3. Each subagent writes and returns its own part of the output (report, HTML fragment, table, etc.); the main agent only merges.
25
+ - If tabs within one slot get different jobs (e.g. "slot 1 first tab logs in, second tab does X on another site"), assign one subagent per tab just like slots (the main agent doesn't switch tabs doing them in turn). Each uses only its assigned 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; actions queue per tab and run concurrently. If a tab's job depends on another finishing first (e.g. needs login), the dependent owner waits with slot_inbox(wait) and the other notifies with slot_send as soon as done (login carries over to other tabs since they share the profile).
26
+ - One agent acts on one slot only (CDPM rejects actions on another slot; viewing other slots is fine).
27
+ - When the user must log in, verify identity, solve a CAPTCHA, etc. on any site, never ask them to say when done. Start the subagents first and have each detect completion with browser_wait url/gone/text without touching the screen (no reload), then continue.
28
+ - Waits that may take minutes (bulk collection/processing, waiting for user login, etc.) are not done by the main agent: hand them to a background subagent (run_in_background: true), tell the user the current status right away and keep talking. While the main agent blocks on browser_wait or a long foreground shell command, it can't answer the user.
29
+ - Keep waiting minimal. When subagents collaborate (e.g. exchanging emails), each notifies the other with slot_send as soon as its part is done and waits with slot_inbox wait (no repeated screen refreshes). Never instruct subagents to use long fixed waits.
30
+ - When you need the screen, add read to the action tool to get it in one call (text for content, snapshot when you need things to click, changes to see only what changed).
27
31
  ${END}`;
28
32
  export function claudeMdPath() {
29
33
  const dir = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
package/dist/cli.js CHANGED
@@ -16,7 +16,7 @@ const lazy = {
16
16
  format: () => import('./tools/format.js'),
17
17
  registry: () => import('./registry/store.js'),
18
18
  };
19
- const CLI_AGENT = '사람(CLI)';
19
+ const CLI_AGENT = 'user (CLI)';
20
20
  const HELP = `cdpm ${VERSION} - CDP Manager
21
21
 
22
22
  사용법:
package/dist/orphan.js CHANGED
@@ -36,14 +36,14 @@ export function spawnOrphan(cmd, args, opts = {}) {
36
36
  });
37
37
  let out = '';
38
38
  bridge.stdout.on('data', (d) => (out += String(d)));
39
- bridge.on('error', (e) => reject(new CdpmError(`실행하지 못했어요: ${e.message}`)));
39
+ bridge.on('error', (e) => reject(new CdpmError(`Failed to start: ${e.message}`)));
40
40
  bridge.on('exit', () => {
41
41
  const pid = Number(/PID (\d+)/.exec(out)?.[1]);
42
42
  const line = /LINE (.*)/.exec(out)?.[1];
43
43
  if (pid && (!opts.waitLine || line))
44
44
  return resolve({ pid, line });
45
- const why = /ERR (.*)/.exec(out)?.[1] ?? (/EXIT (.*)/.exec(out) ? `바로 끝났어요 (종료 코드 ${/EXIT (.*)/.exec(out)[1]})` : /TIMEOUT/.test(out) ? '준비 신호가 오지 않았어요' : out.trim());
46
- reject(new CdpmError(`실행하지 못했어요: ${why}`));
45
+ const why = /ERR (.*)/.exec(out)?.[1] ?? (/EXIT (.*)/.exec(out) ? `exited immediately (code ${/EXIT (.*)/.exec(out)[1]})` : /TIMEOUT/.test(out) ? 'no ready signal' : out.trim());
46
+ reject(new CdpmError(`Failed to start: ${why}`));
47
47
  });
48
48
  });
49
49
  }