cdpm-mcp 0.1.4 → 0.1.5
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 +7 -0
- package/README.ko.md +1 -0
- package/README.md +1 -0
- package/dist/agent-setup.js +16 -14
- package/dist/auto-setup.js +1 -1
- package/dist/cdp/client.js +7 -7
- package/dist/cdp/downloads.js +4 -4
- package/dist/cdp/sessions.js +7 -7
- package/dist/cdp/targets.js +1 -1
- package/dist/chrome/finder.js +2 -2
- package/dist/chrome/launcher.js +5 -5
- package/dist/chrome/proxy.js +4 -4
- package/dist/claude-md-setup.js +19 -16
- package/dist/cli.js +1 -1
- package/dist/orphan.js +3 -3
- package/dist/page/actions.js +105 -105
- package/dist/page/snapshot.js +1 -1
- package/dist/pause.js +10 -11
- package/dist/proxy-forwarder.js +8 -8
- package/dist/registry/lock.js +2 -2
- package/dist/service.js +13 -13
- package/dist/slots.js +1 -1
- package/dist/tools/format.js +12 -12
- package/dist/tools/read.js +10 -10
- package/dist/tools/register.js +301 -298
- package/dist/util.js +5 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
버전 번호는 `package.json`에서 관리해요. 확인: `cdpm --version` (직접 받았으면 `node dist/cli.js --version`).
|
|
4
4
|
업데이트 방법은 README의 "업데이트" 항목을 보세요.
|
|
5
5
|
|
|
6
|
+
## 0.1.5 (2026-10-12)
|
|
7
|
+
|
|
8
|
+
- AI가 읽는 글을 모두 영어로 바꿨어요 (토큰 절약): 서버 안내, 도구·인자 설명, 도구 결과·오류·경고, 탭 머리말, 시간 표시(`just now`, `5s ago`), `cdpm-browser` 지침, CLAUDE.md 규칙 블록. 서버 안내와 지침에 "사용자에게는 사용자가 쓰는 언어로 답한다"를 넣었어요. CLI 출력과 설치·설정 안내, 작업표시줄 창 이름("3번")은 한국어 그대로예요.
|
|
9
|
+
- 헤드리스는 사용자가 "헤드리스·안 보이게"라고 말했을 때만 켜고, 말하지 않았으면 먼저 물어보도록 안내를 분명히 했어요.
|
|
10
|
+
- 몇 분씩 걸리는 기다림(대량 수집 완료, 로그인 등)은 메인이 직접 하지 않고 백그라운드 서브에이전트에 맡긴 뒤 사용자와 대화를 이어 가도록 안내해요.
|
|
11
|
+
- 한 슬롯 안에서 탭마다 할 일이 다르면(예: "1번의 첫 탭은 로그인, 둘째 탭은 다른 사이트") 탭마다 서브에이전트를 맡기고, 순서가 있으면 `slot_send`/`slot_inbox` 신호로 잇도록 안내해요.
|
|
12
|
+
|
|
6
13
|
## 0.1.4 (2026-10-12)
|
|
7
14
|
|
|
8
15
|
- VS Code 등을 닫으면 슬롯 Chrome이 같이 꺼지던 문제를 고쳤어요. VS Code는 닫힐 때 자기가 띄운 프로세스를 자식의 자식까지 줄기째 강제 종료하는데, 슬롯 Chrome이 CDPM의 자식으로 남아 있었어요. 이제 중간 다리 프로세스로 띄워 부모 없는 프로세스로 만들어서, CDPM·Claude Code·VS Code가 꺼져도 슬롯은 살아 있어요. 프록시 중계 프로그램도 같아요.
|
package/README.ko.md
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
- **여러 에이전트용 설계**: 모든 도구에 `slot`을 명시해요. 탭마다 누가 열었고 누가 마지막으로 건드렸는지 기록하고, 남이 최근에 쓴 탭을 조작하면 막지 않고 알려줘요. 같은 탭에 동시에 온 명령은 줄 세워 하나씩 실행해요.
|
|
19
19
|
- **에이전트끼리 대화**: `slot_send` / `slot_inbox`. 안 읽은 메시지는 모든 도구 결과 맨 위에도 붙어요.
|
|
20
20
|
- **상태줄**: `cdpm statusline`이 떠 있는 슬롯을 슬롯 색 번호와 마지막으로 조작한 탭의 제목으로 출력해요 (`CDPM 1 NAVER 2 Daum`). 에이전트 이름은 넣지 않아요.
|
|
21
|
+
- **AI용 글은 영어**: 서버 안내, 도구 설명, 도구 결과는 토큰을 아끼려고 영어로 되어 있어요. Claude는 사용자가 쓰는 언어(한국어 등)로 답하도록 안내받아요. CLI 출력은 한국어예요.
|
|
21
22
|
- **사용자 PC를 건드리지 않아요**: 창 크기·위치·뷰포트·확대 비율을 바꾸지 않고, OS 창(파일 선택·메일 앱 등)을 띄우는 동작은 거부해요. 아래 "하지 않는 것"을 보세요.
|
|
22
23
|
|
|
23
24
|
> Windows 11과 macOS에서 쓸 수 있어요. 슬롯별 아이콘은 Windows는 작업표시줄, macOS는 Dock에 들어가요 (아래 "macOS" 참고).
|
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ An MCP server that runs **Chrome slots 1–30** over the Chrome DevTools Protoco
|
|
|
18
18
|
- **Built for many agents.** Every tool takes `slot` explicitly, records who opened each tab and who touched it last, warns (without blocking) when you act on a tab someone else just used, and serializes concurrent commands on the same tab.
|
|
19
19
|
- **Agents can talk** with `slot_send` / `slot_inbox`; unread messages are also delivered at the top of every result.
|
|
20
20
|
- **Status line.** `cdpm statusline` prints live slots as slot-colored numbers; each slot shows the title of the tab last acted on (no agent names; only blank/new tabs left shows just the number): `CDPM 1 NAVER 2 Daum`. It fits the terminal width (from ccstatusline): titles shrink first, then only numbers, then `+N` for the rest. A paused slot (`slot_pause` / `cdpm pause`) shows its number in dim gray instead of its slot color. A dim `CDPM -` when none are running. Ending a slot's Chrome yourself (closing its last window on Windows, Cmd+Q on macOS) removes it right away, and titles are read live.
|
|
21
|
+
- **English for the AI.** Server instructions, tool descriptions and tool results are in English to save tokens; Claude is told to answer in the user's language. CLI output is in Korean.
|
|
21
22
|
- **Leaves the user's PC alone.** No window, viewport or zoom changes, and actions that would pop up OS windows are refused (see below).
|
|
22
23
|
|
|
23
24
|
> Works on Windows 11 and macOS. Per-slot icons: taskbar on Windows, Dock on macOS (see "macOS" below).
|
package/dist/agent-setup.js
CHANGED
|
@@ -43,24 +43,26 @@ export function agentFile(names) {
|
|
|
43
43
|
const tools = [...names.flatMap((n) => AGENT_TOOLS.map((t) => `mcp__${n}__${t}`)), 'Write'];
|
|
44
44
|
return `---
|
|
45
45
|
name: cdpm-browser
|
|
46
|
-
description: CDPM
|
|
46
|
+
description: Subagent that owns one CDPM browser slot and navigates, reads, clicks and types in it. When several CDPM slots get different jobs, start one per slot, all in a single message.
|
|
47
47
|
tools: ${tools.join(', ')}
|
|
48
48
|
omitClaudeMd: true
|
|
49
49
|
---
|
|
50
50
|
${MARK}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
51
|
+
You own one CDPM browser slot. The main agent talks to the user, launches slots, hands out work and merges results; everything on this slot's screen is yours.
|
|
52
|
+
Instructions from the main agent are short (slot number, your agent name, the task). Work out the rest from these rules and act right away.
|
|
53
|
+
- Report back in the language the main agent/user uses.
|
|
54
|
+
- Pass your slot number and agent name to every CDPM tool. Never touch other slots.
|
|
55
|
+
- If assigned a specific tab, pass that tab to every tool and leave other tabs alone. If told to use a new tab, open one with browser_tab_new and use its ID. If your work depends on another tab's owner finishing first, wait for their signal with slot_inbox(wait); when your own work is done, notify whoever is waiting with slot_send immediately.
|
|
56
|
+
- 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).
|
|
57
|
+
- Fill multiple fields on the same page with a single browser_fill.
|
|
58
|
+
- Do your own navigation (the main agent only launches the slot). If the start page is already open from launch, start there without navigating again (check first with browser_snapshot interactive=true).
|
|
59
|
+
- Keep waiting to a minimum; never use fixed-time sleeps. For jobs that take minutes (e.g. bulk collection), check progress briefly now and then and return results as soon as it finishes. To wait for a button to enable, use browser_wait enabled. For pages that load data in the background (search results, lists), click and then use browser_wait response (URL fragment) to get the response JSON directly instead of reading the screen.
|
|
60
|
+
- When the user must log in, verify identity, solve a CAPTCHA, etc. on any site, never ask them to tell you when done. Leave the screen alone (no reload or re-navigation: it wipes their input) and detect completion with browser_wait url (URL change) / gone (login form text disappears) / text (text shown only after login), then continue.
|
|
61
|
+
- When working with other agents, signal in real time: as soon as your part is done, notify them with slot_send(slot=their slot, to=their name); when waiting on them, don't keep refreshing the screen, use slot_inbox(slot=your slot, wait=120-600) (returns as soon as a message arrives). Act on signals immediately.
|
|
62
|
+
- If the user pauses the slot, actions are rejected with a pause notice. Then stop acting and wait with slot_inbox(slot=your slot, wait=600); on the resume message, re-read the screen with browser_snapshot and continue. Never resume on your own.
|
|
63
|
+
- To see another slot's screen, use read-only tools (browser_snapshot, browser_text) on it directly (no actions).
|
|
64
|
+
- When a dialog appears, normally read it and accept/dismiss it yourself with browser_dialog. Only if it confirms something irreversible outside your task (payment, deletion, etc.), leave it and report to the main agent.
|
|
65
|
+
- Return only your own requested part of the output (report, HTML fragment, table, etc.), briefly. If asked for a file, write it to that path.
|
|
64
66
|
`;
|
|
65
67
|
}
|
|
66
68
|
/** 설치(또는 최신으로 갱신). 사용자가 직접 만든 같은 이름의 파일은 건드리지 않는다. */
|
package/dist/auto-setup.js
CHANGED
|
@@ -12,7 +12,7 @@ import { claudeMdPath, hasCdpmRules, setupClaudeMd } from './claude-md-setup.js'
|
|
|
12
12
|
import { cdpmHome } from './paths.js';
|
|
13
13
|
import { isStatuslineConfigured, setupStatusline } from './statusline-setup.js';
|
|
14
14
|
/** 자동 설정 내용이 바뀌면 올린다 (그때 한 번 더 적용). */
|
|
15
|
-
export const AUTO_SETUP_VERSION =
|
|
15
|
+
export const AUTO_SETUP_VERSION = 14; // 2: cdpm-browser 서브에이전트, 3: 권한 허용 목록, 4: 실시간 협업 규칙, 5: 메인은 켜기만·로그인 자동 감지, 6: 역할 구분, 7: 백그라운드로 한꺼번에·짧은 지시, 8: 켜면서 시작 주소 열기, 9: 서브에이전트 도구 추가(업로드·마우스 올리기 등), 10: 알림창 처리(browser_dialog), 11: 알림창은 웬만하면 직접 처리, 12: browser_wait enabled·response, 13: 멈춤·다시 시작, 14: 헤드리스는 말했을 때만·긴 기다림은 백그라운드·슬롯별 다른 일 예시·한 슬롯 안 탭마다 다른 일도 서브에이전트
|
|
16
16
|
export function setupItems() {
|
|
17
17
|
return [
|
|
18
18
|
{ name: 'statusline', present: () => isStatuslineConfigured(), apply: () => setupStatusline().message },
|
package/dist/cdp/client.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
45
|
-
'
|
|
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}
|
|
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
|
|
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)
|
package/dist/cdp/downloads.js
CHANGED
|
@@ -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
|
|
55
|
+
return `Download canceled: ${d.file}`;
|
|
56
56
|
const size = d.totalBytes || d.receivedBytes;
|
|
57
|
-
return
|
|
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
|
|
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
|
}
|
package/dist/cdp/sessions.js
CHANGED
|
@@ -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, '
|
|
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: '
|
|
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(
|
|
305
|
-
'
|
|
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(
|
|
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));
|
package/dist/cdp/targets.js
CHANGED
|
@@ -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이 돌려주는 순서 그대로 (첫 번째가 가장 최근 활성 탭). */
|
package/dist/chrome/finder.js
CHANGED
|
@@ -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
|
|
44
|
+
throw new CdpmError('Chrome not found. Searched:\n' +
|
|
45
45
|
candidates.map((c) => ` - ${c}`).join('\n') +
|
|
46
|
-
`\
|
|
46
|
+
`\nSet it manually in ${paths.config()}: {"chromePath": "<full path to Chrome executable>"}`);
|
|
47
47
|
}
|
|
48
48
|
function regQuery(key) {
|
|
49
49
|
try {
|
package/dist/chrome/launcher.js
CHANGED
|
@@ -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(`
|
|
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(
|
|
44
|
-
|
|
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(
|
|
49
|
-
|
|
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
|
}
|
package/dist/chrome/proxy.js
CHANGED
|
@@ -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(
|
|
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(
|
|
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
|
|
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(
|
|
95
|
+
throw new CdpmError(`Failed to start proxy forwarder: ${e.message}`);
|
|
96
96
|
}
|
|
97
97
|
}
|
package/dist/claude-md-setup.js
CHANGED
|
@@ -7,23 +7,26 @@ 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
|
|
10
|
+
## CDPM (Chrome slot MCP) rules
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
- When
|
|
12
|
+
- Reply to the user in the user's language.
|
|
13
|
+
- Roles (always, for any job using multiple slots or tabs, on any site):
|
|
14
|
+
- 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
|
+
- 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.
|
|
16
|
+
- A simple job on a single slot can be done by the main agent directly.
|
|
17
|
+
- 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).
|
|
18
|
+
- 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.
|
|
19
|
+
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.
|
|
20
|
+
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).
|
|
21
|
+
- 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).
|
|
22
|
+
- 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).
|
|
23
|
+
3. Each subagent writes and returns its own part of the output (report, HTML fragment, table, etc.); the main agent only merges.
|
|
24
|
+
- 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).
|
|
25
|
+
- One agent acts on one slot only (CDPM rejects actions on another slot; viewing other slots is fine).
|
|
26
|
+
- 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.
|
|
27
|
+
- 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.
|
|
28
|
+
- 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.
|
|
29
|
+
- 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
30
|
${END}`;
|
|
28
31
|
export function claudeMdPath() {
|
|
29
32
|
const dir = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
|
package/dist/cli.js
CHANGED
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(
|
|
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) ?
|
|
46
|
-
reject(new CdpmError(
|
|
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
|
}
|