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.
@@ -22,12 +22,12 @@ export function externalScheme(url) {
22
22
  /** 사용자 클립보드를 쓰거나 읽는 키. 클립보드는 사람과 같이 쓰므로 보내지 않는다. */
23
23
  const CLIPBOARD_COMBOS = [/^(control|ctrl|meta|cmd)\+(c|x|v)$/i, /^(control|ctrl)\+insert$/i, /^shift\+(insert|delete)$/i];
24
24
  const IS_MAC = process.platform === 'darwin';
25
- export const DIALOG_NOTE = '내용을 보고 판단해서 browser_dialog로 직접 처리하세요 (확인 accept: true, 취소 false). 사용자가 시키지 않은 되돌릴 수 없는 일(결제·삭제 등)을 확정하는 창일 때만 사용자에게 물어보세요.';
25
+ export const DIALOG_NOTE = '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.).';
26
26
  /** 행동 도중 페이지가 알림창을 띄움. 행동 자체는 이루어진 것이므로 오류가 아니라 결과로 알린다. */
27
27
  export class DialogInterrupt extends CdpmError {
28
28
  }
29
29
  /** 입력한 뒤 실제 값이 넣으려던 글자와 다를 때 결과에 붙는 표시 (이때는 제출하지 않는다) */
30
- export const VALUE_MISMATCH = '[주의] 입력한 뒤 값이 예상과 달라요';
30
+ export const VALUE_MISMATCH = '[warning] Value differs from what was typed';
31
31
  // ---------- 에이전트 조작 동안에만: OS 창·인쇄 창 막기 ----------
32
32
  // 사람이 직접 누른 것은 평소처럼 떠야 하므로, CDPM이 조작하는 그 순간에만 켜고 끝나면 바로 푼다.
33
33
  // - 파일 선택 창: 클릭뿐 아니라 키(파일 칸에서 Enter·Space)나 폼 제출 등 어떤 경로로 열려도 OS 창 대신 가로챈다.
@@ -71,10 +71,10 @@ export async function guardAction(s, fn) {
71
71
  // 클릭이 이미 안내했으면(같은 창) 다시 붙이지 않는다
72
72
  if (chooser && !(s.fileChooser && s.fileChooser.at >= started)) {
73
73
  s.fileChooser = { fs: s, backendNodeId: chooser.backendNodeId, multiple: chooser.mode === 'selectMultiple', at: Date.now() };
74
- note += `\n파일 선택 창이 열리려 해서 사용자 화면에 띄우지 않았어요. browser_upload(files=[파일 경로${s.fileChooser.multiple ? ', 여러 개 가능' : ''}])로 바로 넣으세요.`;
74
+ note += `\nA file chooser tried to open; it was not shown to the user. Use browser_upload(files=[path${s.fileChooser.multiple ? ', ...' : ''}]).`;
75
75
  }
76
76
  if (printed)
77
- note += '\n페이지가 인쇄 창을 열려고 해서 막았어요 (탭이 멈추지 않게). PDF로 저장하려면 browser_pdf를 쓰세요.';
77
+ note += '\nBlocked the page from opening a print dialog (would freeze the tab). Use browser_pdf to save as PDF.';
78
78
  return { value, note };
79
79
  }
80
80
  /** 사용자가 슬롯을 멈춤: 하던 조작을 다음 입력을 보내기 직전에 그만둔다. */
@@ -84,7 +84,7 @@ export class PausedInterrupt extends CdpmError {
84
84
  const CHANGES_PAGE = /^(Input\.(dispatch|insertText)|Page\.(navigate|reload|navigateToHistoryEntry)$|DOM\.(setFileInputFiles|scrollIntoViewIfNeeded)$)/;
85
85
  function stopIfPaused(s) {
86
86
  if (isPaused(s.slot))
87
- throw new PausedInterrupt('사용자가 슬롯을 멈춰서 하던 조작을 그 자리에서 멈췄어요 (이미 보낸 입력까지만 반영됐어요).');
87
+ throw new PausedInterrupt('The user paused this slot, so the action stopped midway (only input already sent was applied).');
88
88
  }
89
89
  async function send(s, method, params = {}, timeoutMs) {
90
90
  if (CHANGES_PAGE.test(method))
@@ -92,7 +92,7 @@ async function send(s, method, params = {}, timeoutMs) {
92
92
  const r = await s.sendUnlessDialog(method, params, timeoutMs);
93
93
  if (r === 'dialog') {
94
94
  const d = s.dialog;
95
- throw new DialogInterrupt(`${d ? `${d.type} 알림창이 떴어요: "${d.message}"\n` : '알림창이 떴어요.\n'}${DIALOG_NOTE}`);
95
+ throw new DialogInterrupt(`${d ? `A ${d.type} dialog opened: "${d.message}"\n` : 'A dialog opened.\n'}${DIALOG_NOTE}`);
96
96
  }
97
97
  return r;
98
98
  }
@@ -105,18 +105,18 @@ export async function handleDialog(s, accept, text) {
105
105
  }
106
106
  catch (e) {
107
107
  if (/no dialog/i.test(String(e?.message)))
108
- throw new CdpmError('이 탭에는 떠 있는 알림창이 없어요.');
108
+ throw new CdpmError('No dialog is open on this tab.');
109
109
  throw e;
110
110
  }
111
111
  await closed;
112
- const kind = d && d.type !== '응답 대기' ? `${d.type} 알림창` : '알림창';
113
- const what = accept ? (d?.type === 'beforeunload' ? '확인(페이지 떠나기)' : '확인') : (d?.type === 'beforeunload' ? '취소(페이지에 머물기)' : '취소');
114
- return `${kind}을 ${what}했어요${d?.message ? `: "${d.message.slice(0, 120)}"` : ''}${accept && text !== undefined ? ` (입력: "${text.slice(0, 60)}")` : ''}.`;
112
+ const kind = d && d.type !== 'unresponsive' ? `${d.type} dialog` : 'dialog';
113
+ const what = accept ? (d?.type === 'beforeunload' ? 'Accepted (left page)' : 'Accepted') : (d?.type === 'beforeunload' ? 'Dismissed (stayed on page)' : 'Dismissed');
114
+ return `${what} ${kind}${d?.message ? `: "${d.message.slice(0, 120)}"` : ''}${accept && text !== undefined ? ` (input: "${text.slice(0, 60)}")` : ''}.`;
115
115
  }
116
116
  function targetOf(s, agent, ref) {
117
117
  const t = s.refsFor(agent).get(ref.trim());
118
118
  if (!t) {
119
- throw new CdpmError(`모르는 ref예요: "${ref}". 페이지가 바뀌었거나, 다른 탭의 ref이거나, 이 에이전트(${agent})가 이 탭에서 찍은 스냅샷이 없어요. browser_snapshot을 다시 찍으세요.`);
119
+ throw new CdpmError(`Unknown ref: "${ref}". The page changed, the ref is from another tab, or this agent (${agent}) has no snapshot of this tab. Take a new browser_snapshot.`);
120
120
  }
121
121
  return t;
122
122
  }
@@ -137,7 +137,7 @@ async function locate(s, t) {
137
137
  catch (e) {
138
138
  if (e instanceof DialogInterrupt)
139
139
  throw e;
140
- throw new CdpmError('iframe의 위치를 구할 수 없어요 (iframe이 숨겨졌거나 사라졌을 수 있어요). browser_snapshot을 다시 찍으세요.');
140
+ throw new CdpmError('Cannot locate the iframe (it may be hidden or gone). Take a new browser_snapshot.');
141
141
  }
142
142
  const fs = await pageSession(s.slot, t.targetId);
143
143
  return { fs, dx: parent.dx + content[0], dy: parent.dy + content[1] };
@@ -153,7 +153,7 @@ async function objectOf(s, t) {
153
153
  catch (e) {
154
154
  if (e instanceof DialogInterrupt)
155
155
  throw e;
156
- throw new CdpmError('요소가 페이지에서 사라졌어요. browser_snapshot을 다시 찍으세요.');
156
+ throw new CdpmError('Element is gone from the page. Take a new browser_snapshot.');
157
157
  }
158
158
  }
159
159
  async function callOn(s, objectId, fn, args = []) {
@@ -161,7 +161,7 @@ async function callOn(s, objectId, fn, args = []) {
161
161
  objectId, functionDeclaration: fn, arguments: args, returnByValue: true,
162
162
  });
163
163
  if (r.exceptionDetails)
164
- throw new CdpmError(`페이지 함수 실행 오류: ${r.exceptionDetails.exception?.description ?? r.exceptionDetails.text}`);
164
+ throw new CdpmError(`Page function error: ${r.exceptionDetails.exception?.description ?? r.exceptionDetails.text}`);
165
165
  return r.result.value;
166
166
  }
167
167
  /** 함수 결과를 값이 아니라 객체로 받는다 (예: 섀도 DOM의 호스트 요소). */
@@ -179,12 +179,12 @@ const release = async (s) => {
179
179
  /** 누르면 선택 창(달력·시계·색)이 뜨는 입력칸. 클릭하지 않고 browser_type으로 값을 넣는다 */
180
180
  const DATE_LIKE = ['date', 'time', 'datetime-local', 'month', 'week', 'color'];
181
181
  const DATE_FORMAT = {
182
- date: 'YYYY-MM-DD (예: 2026-10-08)',
183
- time: 'HH:MM 24시간 (예: 19:30)',
184
- 'datetime-local': 'YYYY-MM-DDTHH:MM (예: 2026-10-08T19:30)',
185
- month: 'YYYY-MM (예: 2026-10)',
186
- week: 'YYYY-Www (예: 2026-W41)',
187
- color: '#RRGGBB (예: #ff0000)',
182
+ date: 'YYYY-MM-DD (e.g. 2026-10-08)',
183
+ time: 'HH:MM 24h (e.g. 19:30)',
184
+ 'datetime-local': 'YYYY-MM-DDTHH:MM (e.g. 2026-10-08T19:30)',
185
+ month: 'YYYY-MM (e.g. 2026-10)',
186
+ week: 'YYYY-Www (e.g. 2026-W41)',
187
+ color: '#RRGGBB (e.g. #ff0000)',
188
188
  };
189
189
  const DESCRIBE = `function () {
190
190
  const el = this.nodeType === 1 ? this : this.parentElement;
@@ -206,7 +206,7 @@ const DESCRIBE = `function () {
206
206
  async function describe(s, objectId, ref) {
207
207
  const info = await callOn(s, objectId, DESCRIBE);
208
208
  if (!info.connected) {
209
- throw new CdpmError(`오래된 ref예요${ref ? `: "${ref}"` : ''}. 그 요소는 페이지가 바뀌면서 사라졌어요 (새 요소로 교체됨). browser_snapshot을 다시 찍으세요.`);
209
+ throw new CdpmError(`Stale ref${ref ? `: "${ref}"` : ''}. The element was replaced when the page changed. Take a new browser_snapshot.`);
210
210
  }
211
211
  return info;
212
212
  }
@@ -223,11 +223,11 @@ async function clickPoint(s, backendNodeId) {
223
223
  catch (e) {
224
224
  if (e instanceof DialogInterrupt)
225
225
  throw e;
226
- throw new CdpmError('요소의 위치를 구할 수 없어요 (화면에 그려지지 않는 요소일 수 있어요). browser_snapshot을 다시 찍어 보세요.');
226
+ throw new CdpmError('Cannot locate the element (it may not be rendered). Try a new browser_snapshot.');
227
227
  }
228
228
  const q = quads.find((quad) => area(quad) > 1);
229
229
  if (!q)
230
- throw new CdpmError('요소가 화면에서 크기가 0이에요 (숨겨져 있을 수 있어요).');
230
+ throw new CdpmError('Element has zero size on screen (it may be hidden).');
231
231
  return { x: (q[0] + q[2] + q[4] + q[6]) / 4, y: (q[1] + q[3] + q[5] + q[7]) / 4 };
232
232
  }
233
233
  function area(q) {
@@ -275,7 +275,7 @@ async function coveringElement(s, t, targetObj, x, y) {
275
275
  while (real && real.shadowRoot) { const inner = real.shadowRoot.elementFromPoint(x, y); if (!inner || inner === real) break; real = inner; }
276
276
  if (real && inside(real)) return null;
277
277
  const el = hit.nodeType === 1 ? hit : hit.parentElement;
278
- if (!el) return { blocked: '알 수 없는 요소' };
278
+ if (!el) return { blocked: 'unknown element' };
279
279
  const label = (el.getAttribute('aria-label') || el.innerText || el.getAttribute('alt') || '').trim().slice(0, 40);
280
280
  const id = el.id ? '#' + el.id : '';
281
281
  const cls = typeof el.className === 'string' && el.className.trim() ? '.' + el.className.trim().split(/\\s+/).slice(0, 2).join('.') : '';
@@ -304,10 +304,10 @@ async function mouseClick(s, x, y, clickCount, visible) {
304
304
  }
305
305
  }
306
306
  const LOAD_NOTE = {
307
- complete: '로딩 완료',
308
- interactive: '본문 로딩 완료, 네트워크도 조용해짐 (load 이벤트 전)',
309
- timeout: '아직 로딩 중이에요 (네트워크가 느릴 수 있어요). 필요하면 browser_wait로 더 기다리세요',
310
- download: '파일 다운로드로 바뀌어서 페이지는 그대로예요',
307
+ complete: 'loaded',
308
+ interactive: 'DOM loaded, network idle (before load event)',
309
+ timeout: 'still loading (slow network?). Use browser_wait to wait more if needed',
310
+ download: 'became a file download; page unchanged',
311
311
  };
312
312
  /** 행동 뒤 페이지 이동이 시작되면 로딩을 기다린다. 이동이 없으면 거의 바로 돌아온다. */
313
313
  async function settleAfter(s, action) {
@@ -350,7 +350,7 @@ async function settleAfter(s, action) {
350
350
  if (!started)
351
351
  return '';
352
352
  const state = await waitLoad(s, !committed);
353
- return `\n(페이지 이동: ${LOAD_NOTE[state]})`;
353
+ return `\n(navigated: ${LOAD_NOTE[state]})`;
354
354
  }
355
355
  /**
356
356
  * 새 문서가 들어오고(needCommit) 로딩이 끝날 때까지. 시간이 아니라 신호로 판단한다.
@@ -423,25 +423,25 @@ export async function click(s, agent, ref, double = false) {
423
423
  const obj = await objectOf(fs, t);
424
424
  const info = await describe(fs, obj, ref);
425
425
  if (info.select) {
426
- throw new CdpmError(`클릭하지 않았어요: [${ref}]는 드롭다운(<select>)이라 누르면 사용자 화면에 목록 창이 떠요. browser_select로 항목을 고르세요.`);
426
+ throw new CdpmError(`Not clicked: [${ref}] is a dropdown (<select>); clicking opens a popup on the user's screen. Use browser_select.`);
427
427
  }
428
428
  if (info.dateType) {
429
- throw new CdpmError(`클릭하지 않았어요: [${ref}]는 ${info.dateType} 입력칸이라 누르면 사용자 화면에 선택 창(달력·시계·색)이 떠요. browser_type으로 값을 넣으세요 (형식: ${DATE_FORMAT[info.dateType] ?? info.dateType}).`);
429
+ throw new CdpmError(`Not clicked: [${ref}] is a ${info.dateType} input; clicking opens a picker on the user's screen. Use browser_type (format: ${DATE_FORMAT[info.dateType] ?? info.dateType}).`);
430
430
  }
431
431
  const href = await callOn(fs, obj, 'function () { const a = this.closest && this.closest("a[href]"); return a ? a.href : ""; }');
432
432
  const ext = href ? externalScheme(href) : undefined;
433
433
  if (ext) {
434
- throw new CdpmError(`클릭하지 않았어요: [${ref}]는 ${ext} 주소(${href.slice(0, 80)})라 누르면 사용자 PC의 다른 프로그램(메일·전화·앱 등)이 실행돼요.`);
434
+ throw new CdpmError(`Not clicked: [${ref}] is a ${ext} link (${href.slice(0, 80)}); clicking would launch another program on the user's PC (mail, phone, app, etc.).`);
435
435
  }
436
436
  const visible = (await s.visibility()) === 'visible';
437
437
  const local = await clickPoint(fs, t.backendNodeId);
438
438
  const x = local.x + dx, y = local.y + dy;
439
439
  const cover = await coveringElement(fs, t, obj, local.x, local.y);
440
440
  if (cover && 'blocked' in cover)
441
- throw new CdpmError(`클릭하지 않았어요: ${cover.blocked}이(가) [${ref}]를 가리고 있어요. 팝업을 닫거나 스크롤한 뒤 다시 시도하세요.`);
441
+ throw new CdpmError(`Not clicked: ${cover.blocked} is covering [${ref}]. Close the popup or scroll, then retry.`);
442
442
  const overlayExt = cover && cover.href ? externalScheme(cover.href) : undefined;
443
443
  if (overlayExt) {
444
- throw new CdpmError(`클릭하지 않았어요: [${ref}]를 덮은 링크가 ${overlayExt} 주소(${cover.href.slice(0, 80)})라 누르면 사용자 PC의 다른 프로그램이 실행돼요.`);
444
+ throw new CdpmError(`Not clicked: the link covering [${ref}] is a ${overlayExt} link (${cover.href.slice(0, 80)}); clicking would launch another program on the user's PC.`);
445
445
  }
446
446
  // 이 클릭이 파일 선택 창을 열면(파일 칸·"첨부" 버튼 등) OS 창을 띄우지 않고 가로챈다 (CDPM이 누르는 동안만. 사람이 누르면 평소대로 뜸)
447
447
  let chooser;
@@ -462,7 +462,7 @@ export async function click(s, agent, ref, double = false) {
462
462
  if (chooser) {
463
463
  s.fileChooser = { fs, backendNodeId: chooser.backendNodeId, multiple: chooser.mode === 'selectMultiple', at: Date.now() };
464
464
  note += `
465
- 파일 선택 창이 열리려 해서 사용자 화면에 띄우지 않고 대기 중이에요. browser_upload(files=[파일 경로${s.fileChooser.multiple ? ', 여러 개 가능' : ''}])로 바로 넣으세요.`;
465
+ A file chooser tried to open; it was held back from the user's screen. Use browser_upload(files=[path${s.fileChooser.multiple ? ', ...' : ''}]).`;
466
466
  }
467
467
  let extra = '';
468
468
  if (!note && !s.dialog) {
@@ -477,9 +477,9 @@ export async function click(s, agent, ref, double = false) {
477
477
  return label + ': ' + bad.validationMessage;
478
478
  }`).catch(() => '');
479
479
  if (invalid)
480
- extra = `\n[주의] 폼이 제출되지 않았어요 (페이지 검증에 걸림) — ${invalid}`;
480
+ extra = `\n[warning] Form not submitted (failed page validation) — ${invalid}`;
481
481
  }
482
- return `${double ? '더블클릭' : '클릭'}했어요: [${ref}]${note}${extra}${downloadNote(s)}`;
482
+ return `${double ? 'Double-clicked' : 'Clicked'} [${ref}]${note}${extra}${downloadNote(s)}`;
483
483
  }
484
484
  finally {
485
485
  await release(fs);
@@ -507,25 +507,25 @@ async function humanFocusNote(s) {
507
507
  if (s.isEmulating)
508
508
  return ''; // 숨은 탭을 그리는 중이면 hasFocus가 가짜로 true
509
509
  const r = await s.evaluate('document.hasFocus()', { timeoutMs: 800 }).catch(() => undefined);
510
- return r?.value ? '\n[주의] 이 탭은 지금 사람이 쓰고 있는 창일 수 있어요 (Chrome 창이 맨 앞이고 이 탭이 열려 있음). 사람이 입력 중이면 글자가 섞일 수 있어요.' : '';
510
+ return r?.value ? '\n[warning] A person may be using this tab now (Chrome window is in front with this tab open). Their typing could mix with yours.' : '';
511
511
  }
512
512
  export async function pressKey(s, key) {
513
513
  await s.ensureNoDialog();
514
514
  if (CLIPBOARD_COMBOS.some((re) => re.test(key.replace(/\s+/g, '')))) {
515
- throw new CdpmError(`"${key}"는 보내지 않았어요: 복사·붙여넣기는 사용자 PC의 클립보드를 덮어쓰거나 읽어요. 글자는 browser_type, 내용 확인은 browser_text를 쓰세요.`);
515
+ throw new CdpmError(`Did not send "${key}": copy/paste reads or overwrites the user's clipboard. Use browser_type to enter text and browser_text to read it.`);
516
516
  }
517
517
  const combo = parseCombo(key);
518
518
  if (!combo)
519
- throw new CdpmError(`알 수 없는 키: "${key}". 예: Enter, Tab, Escape, ArrowDown, Control+A. 지원 키: ${KNOWN_KEYS.join(', ')}, 글자 한 개`);
519
+ throw new CdpmError(`Unknown key: "${key}". E.g. Enter, Tab, Escape, ArrowDown, Control+A. Supported: ${KNOWN_KEYS.join(', ')}, or a single character`);
520
520
  const human = await humanFocusNote(s);
521
521
  const note = await settleAfter(s, () => pressCombo(s, combo));
522
- return `키를 눌렀어요: ${key}${note}${human}`;
522
+ return `Pressed ${key}${note}${human}`;
523
523
  }
524
524
  /** 날짜·시간 입력칸: 칸별 키 입력은 로케일마다 달라 불안정하므로 값을 직접 넣고 input/change 이벤트를 낸다. */
525
525
  async function setDateLike(s, obj, info, text, ref) {
526
526
  const target = info.inDateHost ? await callOnObject(s, obj, 'function () { return this.getRootNode().host; }') : obj;
527
527
  if (!target)
528
- throw new CdpmError(`[${ref}] 날짜·시간·색 입력칸을 찾지 못했어요.`);
528
+ throw new CdpmError(`[${ref}]: date/time/color input not found.`);
529
529
  // 형식이 틀리면 브라우저가 값을 비워 버리므로, 먼저 넣어 보고 틀리면 원래 값으로 되돌린다. 이벤트는 맞을 때만 낸다.
530
530
  const r = await callOn(s, target, `function (v) {
531
531
  const set = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set;
@@ -537,9 +537,9 @@ async function setDateLike(s, obj, info, text, ref) {
537
537
  return { ok: true, prev };
538
538
  }`, [{ value: text }]);
539
539
  if (!r.ok) {
540
- throw new CdpmError(`[${ref}]는 ${info.dateType} 입력칸이에요. 형식이 맞지 않아 넣지 않았어요 (원래 값 ${JSON.stringify(r.prev)} 유지). 형식: ${DATE_FORMAT[info.dateType] ?? info.dateType}`);
540
+ throw new CdpmError(`[${ref}] is a ${info.dateType} input. Wrong format, not set (kept ${JSON.stringify(r.prev)}). Format: ${DATE_FORMAT[info.dateType] ?? info.dateType}`);
541
541
  }
542
- return `입력했어요: [${ref}] ${JSON.stringify(text)} (${info.dateType} 입력칸에 값을 직접 넣음)`;
542
+ return `Typed [${ref}] ${JSON.stringify(text)} (value set directly on ${info.dateType} input)`;
543
543
  }
544
544
  /** 글자마다 진짜 키 이벤트(keydown → keypress → input → keyup)를 보낸다. 사람이 친 것과 같은 이벤트 순서. */
545
545
  async function typeChars(s, text) {
@@ -565,9 +565,9 @@ export async function type(s, agent, ref, text, clear, submit, fast = false) {
565
565
  return submit ? msg + (await settleAfter(s, () => pressCombo(s, parseCombo('Enter')))) : msg;
566
566
  }
567
567
  if (info.select)
568
- throw new CdpmError(`[${ref}]는 드롭다운(<select>)이에요. browser_select로 항목을 고르세요.`);
568
+ throw new CdpmError(`[${ref}] is a dropdown (<select>). Use browser_select.`);
569
569
  if (info.fileInput)
570
- throw new CdpmError(`[${ref}]는 파일 선택 칸이에요. 파일은 browser_upload(ref="${ref}", files=[파일 경로])로 넣으세요.`);
570
+ throw new CdpmError(`[${ref}] is a file input. Use browser_upload(ref="${ref}", files=[path]).`);
571
571
  await send(fs, 'DOM.scrollIntoViewIfNeeded', { backendNodeId: t.backendNodeId }).catch((e) => {
572
572
  if (e instanceof DialogInterrupt)
573
573
  throw e;
@@ -601,21 +601,21 @@ export async function type(s, agent, ref, text, clear, submit, fast = false) {
601
601
  if (info.editable !== 'none' && text) {
602
602
  const now = await callOn(fs, obj, `function () { return ('value' in this && typeof this.value === 'string') ? this.value : (this.innerText || ''); }`);
603
603
  if (!now.includes(text))
604
- warn = `\n${VALUE_MISMATCH} (현재 값: ${JSON.stringify(now.slice(0, 100))}). 사이트가 입력을 막거나 형식을 바꿨을 수 있어요.`;
604
+ warn = `\n${VALUE_MISMATCH} (now: ${JSON.stringify(now.slice(0, 100))}). The site may block or reformat input.`;
605
605
  }
606
606
  else if (info.editable === 'none') {
607
- warn = `\n[주의] [${ref}]는 입력칸이 아니라서(${info.tag}) 포커스된 곳에 글자를 보냈어요. 결과를 스냅샷으로 확인하세요.`;
607
+ warn = `\n[warning] [${ref}] is not an input (${info.tag}); text was sent to the focused element. Check with a snapshot.`;
608
608
  }
609
609
  let note = '';
610
610
  const human = await humanFocusNote(s);
611
611
  // 값이 다르면 잘못된 내용이 제출될 수 있으므로 Enter를 누르지 않는다
612
612
  const mismatch = warn.includes(VALUE_MISMATCH);
613
613
  if (submit && mismatch)
614
- note = '\n값이 달라서 제출(Enter)은 하지 않았어요. 값을 확인한 뒤 다시 입력하거나 browser_press_key로 제출하세요.';
614
+ note = '\nNot submitted (Enter) because the value differs. Check it, then retype or submit with browser_press_key.';
615
615
  else if (submit)
616
616
  note = await settleAfter(s, () => pressCombo(s, parseCombo('Enter')));
617
617
  warn += human;
618
- return `입력했어요: [${ref}] ${JSON.stringify(text)}${clear ? ' (기존 내용 지움)' : ''}${fast ? ' (빠른 입력: 키 이벤트 없이 한 번에)' : ''}${submit && !mismatch ? ' + Enter' : ''}${warn}${note}`;
618
+ return `Typed [${ref}] ${JSON.stringify(text)}${clear ? ' (cleared first)' : ''}${fast ? ' (fast: inserted at once, no key events)' : ''}${submit && !mismatch ? ' + Enter' : ''}${warn}${note}`;
619
619
  }
620
620
  finally {
621
621
  await release(fs);
@@ -638,16 +638,16 @@ export async function select(s, agent, ref, option) {
638
638
  const norm = (x) => x.replace(/\\s+/g, ' ').trim();
639
639
  const o = opts.find((o) => o.value === want) || opts.find((o) => norm(o.text) === norm(want)) ||
640
640
  opts.find((o) => norm(o.text).includes(norm(want)));
641
- if (!o) return { ok: false, options: opts.slice(0, 40).map((o) => norm(o.text) + (o.value !== norm(o.text) ? ' (값: ' + o.value + ')' : '')) };
641
+ if (!o) return { ok: false, options: opts.slice(0, 40).map((o) => norm(o.text) + (o.value !== norm(o.text) ? ' (value: ' + o.value + ')' : '')) };
642
642
  if (o.disabled) return { ok: false, error: 'disabled', label: norm(o.text) };
643
643
  return { ok: true, index: o.index, label: norm(o.text), value: o.value, multiple: sel.multiple };
644
644
  }`, [{ value: option }]);
645
645
  if (!find.ok) {
646
646
  if (find.error === 'notselect')
647
- throw new CdpmError(`[${ref}]는 <select> 드롭다운이 아니에요. 사이트가 직접 만든 목록이면 browser_click으로 열고 항목을 클릭하세요.`);
647
+ throw new CdpmError(`[${ref}] is not a <select>. For a custom list, open it with browser_click and click the item.`);
648
648
  if (find.error === 'disabled')
649
- throw new CdpmError(`"${find.label}" 항목은 비활성이라 고를 수 없어요.`);
650
- throw new CdpmError(`"${option}"에 맞는 항목이 없어요. 고를 수 있는 항목:\n${(find.options ?? []).map((o) => ` - ${o}`).join('\n')}`);
649
+ throw new CdpmError(`Option "${find.label}" is disabled.`);
650
+ throw new CdpmError(`No option matches "${option}". Available:\n${(find.options ?? []).map((o) => ` - ${o}`).join('\n')}`);
651
651
  }
652
652
  await send(fs, 'DOM.focus', { backendNodeId: t.backendNodeId });
653
653
  const current = () => callOn(fs, obj, `function () { const sel = this.tagName === 'SELECT' ? this : this.closest('select'); return sel.selectedIndex; }`);
@@ -671,7 +671,7 @@ export async function select(s, agent, ref, option) {
671
671
  idx = next;
672
672
  }
673
673
  if (idx === find.index)
674
- return `골랐어요: [${ref}] "${find.label}" (값: ${find.value})`;
674
+ return `Selected [${ref}] "${find.label}" (value: ${find.value})`;
675
675
  // 키로 고르지 못한 경우(맥에서 앞글자가 같은 항목이 먼저 있을 때 등): 값을 직접 넣고 input/change 이벤트를 낸다 (이 이벤트는 isTrusted=false).
676
676
  const forced = await callOn(fs, obj, `function (i) {
677
677
  const sel = this.tagName === 'SELECT' ? this : this.closest('select');
@@ -681,8 +681,8 @@ export async function select(s, agent, ref, option) {
681
681
  return sel.selectedIndex;
682
682
  }`, [{ value: find.index }]);
683
683
  if (forced !== find.index)
684
- throw new CdpmError(`"${find.label}" 항목으로 옮기지 못했어요. 페이지가 선택을 막고 있을 수 있어요.`);
685
- return `골랐어요: [${ref}] "${find.label}" (값: ${find.value}) — 키로 고르지 못해 값을 직접 넣었어요 (change 이벤트 isTrusted=false)`;
684
+ throw new CdpmError(`Could not select "${find.label}". The page may be blocking it.`);
685
+ return `Selected [${ref}] "${find.label}" (value: ${find.value}) — keys failed, value set directly (change event isTrusted=false)`;
686
686
  }
687
687
  finally {
688
688
  await release(fs);
@@ -707,21 +707,21 @@ export async function scroll(s, agent, ref, dy) {
707
707
  const t = targetOf(s, agent, ref);
708
708
  const { fs } = await locate(s, t);
709
709
  await send(fs, 'DOM.scrollIntoViewIfNeeded', { backendNodeId: t.backendNodeId });
710
- return `[${ref}]가 보이도록 스크롤했어요.`;
710
+ return `Scrolled [${ref}] into view.`;
711
711
  }
712
712
  const amount = dy ?? 600;
713
713
  // 휠 이벤트는 비동기로 늦게 적용돼 결과를 추측해야 한다 → 스크립트로 정확한 양을 즉시 움직이고 위치를 바로 확정한다.
714
714
  const info = async (move) => (await s.evaluate(SCROLL_FN(move), { timeoutMs: 10_000 })).value;
715
715
  const before = await info(null);
716
716
  const after = await info(amount);
717
- const where = `${after.inner ? '안쪽 스크롤 영역 ' : ''}위치 ${before.top} → ${after.top} / 최대 ${after.max}`;
717
+ const where = `${after.inner ? 'inner scroller ' : ''}pos ${before.top} → ${after.top} / max ${after.max}`;
718
718
  const moved = Math.abs(after.top - before.top);
719
719
  if (!moved) {
720
- const edge = amount > 0 ? '이미 맨 아래' : '이미 맨 위';
721
- return `더 스크롤할 수 없어요 (${edge}, ${where}).`;
720
+ const edge = amount > 0 ? 'at bottom' : 'at top';
721
+ return `Can't scroll further (${edge}, ${where}).`;
722
722
  }
723
- const partial = moved < Math.abs(amount) - 1 ? ` (요청 ${Math.abs(amount)}px 중 끝에 닿아 ${moved}px만)` : '';
724
- return `${amount > 0 ? '아래로' : '위로'} ${moved}px 스크롤했어요${partial} (${where}).`;
723
+ const partial = moved < Math.abs(amount) - 1 ? ` (hit the end: ${moved} of ${Math.abs(amount)}px)` : '';
724
+ return `Scrolled ${amount > 0 ? 'down' : 'up'} ${moved}px${partial} (${where}).`;
725
725
  }
726
726
  export async function navigate(s, rawUrl) {
727
727
  await s.ensureNoDialog();
@@ -731,7 +731,7 @@ export async function navigate(s, rawUrl) {
731
731
  url = url.replace(/^data:text\/html,/i, 'data:text/html;charset=utf-8,');
732
732
  const ext = externalScheme(url);
733
733
  if (ext)
734
- throw new CdpmError(`이동하지 않았어요: ${ext} 주소는 브라우저가 아니라 사용자 PC의 다른 프로그램을 실행해요.`);
734
+ throw new CdpmError(`Not navigated: ${ext} URLs launch another program on the user's PC, not the browser.`);
735
735
  // 이전 문서의 'complete'를 새 문서로 착각하지 않도록, 새 문서가 들어오는 이벤트를 먼저 기다린다.
736
736
  const committed = s.conn.waitFor('Page.frameNavigated', (p) => !p.frame.parentId, 30_000);
737
737
  let r;
@@ -741,21 +741,21 @@ export async function navigate(s, rawUrl) {
741
741
  }
742
742
  catch (e) {
743
743
  if (e instanceof CdpTimeoutError)
744
- return `이동을 시작했지만 60초 동안 서버 응답이 없어요: ${decodeUrl(url)}\n(네트워크가 느리거나 서버가 응답하지 않는 중이에요. browser_wait나 browser_snapshot으로 나중에 확인하세요)`;
744
+ return `Navigation started but no server response for 60s: ${decodeUrl(url)}\n(slow network or unresponsive server. Check later with browser_wait or browser_snapshot)`;
745
745
  throw e;
746
746
  }
747
747
  if (r.errorText) {
748
748
  await new Promise((res) => setImmediate(res));
749
749
  const dl = downloadNote(s);
750
750
  if (dl)
751
- return `이동 대신 파일 내려받기가 시작됐어요 (페이지가 아니라 파일 응답이에요).${dl}`;
752
- throw new CdpmError(`이동 실패 (${decodeUrl(url)}): ${r.errorText}${/TIMED_OUT|INTERNET_DISCONNECTED|NAME_NOT_RESOLVED|CONNECTION/.test(r.errorText) ? ' — 인터넷 연결이나 주소를 확인하세요' : ''}`);
751
+ return `A file download started instead of navigation (response was a file).${dl}`;
752
+ throw new CdpmError(`Navigation failed (${decodeUrl(url)}): ${r.errorText}${/TIMED_OUT|INTERNET_DISCONNECTED|NAME_NOT_RESOLVED|CONNECTION/.test(r.errorText) ? ' — check the connection or URL' : ''}`);
753
753
  }
754
754
  // loaderId가 없으면 같은 문서 안 이동(#해시)이라 새로 로딩하지 않는다.
755
755
  if (!r.loaderId)
756
- return `이동했어요: ${decodeUrl(url)} (같은 페이지 안 이동)`;
756
+ return `Navigated to ${decodeUrl(url)} (same-document)`;
757
757
  const state = (await committed) ? await waitLoad(s, false) : 'timeout';
758
- return `이동했어요: ${decodeUrl(url)}${state === 'complete' ? '' : `\n(${LOAD_NOTE[state]})`}`;
758
+ return `Navigated to ${decodeUrl(url)}${state === 'complete' ? '' : `\n(${LOAD_NOTE[state]})`}`;
759
759
  }
760
760
  export async function back(s) {
761
761
  return history(s, -1);
@@ -765,23 +765,23 @@ export async function forward(s) {
765
765
  }
766
766
  async function history(s, delta) {
767
767
  await s.ensureNoDialog();
768
- const word = delta < 0 ? '뒤로' : '앞으로';
768
+ const word = delta < 0 ? 'back' : 'forward';
769
769
  const h = await send(s, 'Page.getNavigationHistory');
770
770
  const entry = h.entries[h.currentIndex + delta];
771
771
  if (!entry)
772
- throw new CdpmError(`${word} 갈 페이지가 없어요.`);
772
+ throw new CdpmError(`No page to go ${word} to.`);
773
773
  const cur = h.entries[h.currentIndex];
774
774
  const sameDoc = cur.url.split('#')[0] === entry.url.split('#')[0];
775
775
  if (sameDoc) {
776
776
  await send(s, 'Page.navigateToHistoryEntry', { entryId: entry.id });
777
777
  await sleep(100);
778
- return `${word} 갔어요: ${decodeUrl(entry.url)} (같은 페이지 안 이동)`;
778
+ return `Went ${word}: ${decodeUrl(entry.url)} (same-document)`;
779
779
  }
780
780
  const committed = s.conn.waitFor('Page.frameNavigated', (p) => !p.frame.parentId, 30_000);
781
781
  await send(s, 'Page.navigateToHistoryEntry', { entryId: entry.id });
782
782
  const nav = await committed;
783
783
  const state = nav ? await waitLoad(s, false) : 'timeout';
784
- return `${word} 갔어요: ${decodeUrl(entry.url)}${state === 'complete' ? '' : `
784
+ return `Went ${word}: ${decodeUrl(entry.url)}${state === 'complete' ? '' : `
785
785
  (${LOAD_NOTE[state]})`}`;
786
786
  }
787
787
  /** 지금 페이지를 다시 불러온다 (진짜 새로고침, 주소로 다시 이동하는 것과 달리 Chrome의 새로고침 그대로). */
@@ -791,7 +791,7 @@ export async function reload(s, ignoreCache = false) {
791
791
  await send(s, 'Page.reload', { ignoreCache });
792
792
  const nav = await committed;
793
793
  const state = nav ? await waitLoad(s, false) : 'timeout';
794
- return `새로고침했어요${ignoreCache ? ' (캐시 무시)' : ''}${state === 'complete' ? '' : `
794
+ return `Reloaded${ignoreCache ? ' (cache bypassed)' : ''}${state === 'complete' ? '' : `
795
795
  (${LOAD_NOTE[state]})`}${downloadNote(s)}`;
796
796
  }
797
797
  /** 요소 위에 진짜 마우스를 올린다 (마우스를 올려야 열리는 메뉴 등). */
@@ -803,7 +803,7 @@ export async function hover(s, agent, ref) {
803
803
  await send(s, 'Input.dispatchMouseEvent', { type: 'mouseMoved', x: p.x + dx, y: p.y + dy, button: 'none' });
804
804
  // 메뉴가 그려질 시간: 다음 프레임 두 번
805
805
  await fs.evaluate('new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r(1))))', { awaitPromise: true, timeoutMs: 3000 }).catch(() => undefined);
806
- return `마우스를 올렸어요: [${ref}]`;
806
+ return `Hovered [${ref}]`;
807
807
  }
808
808
  /**
809
809
  * 끌어 놓기 (진짜 마우스: 누르고 → 조금씩 움직이고 → 놓기). 슬라이더·순서 바꾸기·드래그형 보안문자 등.
@@ -813,7 +813,7 @@ export async function hover(s, agent, ref) {
813
813
  export async function drag(s, agent, fromRef, toRef, dx, dy, toText) {
814
814
  await s.ensureNoDialog();
815
815
  if (!toRef && !toText && dx === undefined && dy === undefined)
816
- throw new CdpmError('놓을 곳을 주세요: to(요소 ref), to_text(놓을 곳의 글자), 또는 dx·dy(픽셀).');
816
+ throw new CdpmError('Give a drop target: to (ref), to_text (text at target), or dx/dy (pixels).');
817
817
  const from = targetOf(s, agent, fromRef);
818
818
  const a = await locate(s, from);
819
819
  const startPoint = async () => { const p = await clickPoint(a.fs, from.backendNodeId); return { x: p.x + a.dx, y: p.y + a.dy }; };
@@ -846,7 +846,7 @@ export async function drag(s, agent, fromRef, toRef, dx, dy, toText) {
846
846
  return best && { x: best.left + best.width / 2, y: best.top + best.height / 2 };
847
847
  })()`, { timeoutMs: 5000 });
848
848
  if (!r.value)
849
- throw new CdpmError(`"${toText}"이(가) 들어간 놓을 곳을 화면에서 찾지 못했어요 (화면 밖이면 browser_scroll로 둘 다 보이게 한 뒤 다시).`);
849
+ throw new CdpmError(`No drop target containing "${toText}" found on screen (if off-screen, browser_scroll so both are visible, then retry).`);
850
850
  return r.value;
851
851
  }
852
852
  return { x: start.x + (dx ?? 0), y: start.y + (dy ?? 0) };
@@ -874,7 +874,7 @@ export async function drag(s, agent, fromRef, toRef, dx, dy, toText) {
874
874
  await s.send('Input.setInterceptDrags', { enabled: false }, 3000).catch(() => undefined);
875
875
  }
876
876
  await s.evaluate('0', { timeoutMs: 5000 }).catch(() => undefined);
877
- return `끌어 놓았어요: [${fromRef}] → ${toRef ? `[${toRef}]` : toText ? `"${toText}"` : `${dx ?? 0}, ${dy ?? 0}픽셀`}${dragData ? ' (HTML 드래그)' : ''}`;
877
+ return `Dragged [${fromRef}] → ${toRef ? `[${toRef}]` : toText ? `"${toText}"` : `${dx ?? 0}, ${dy ?? 0}px`}${dragData ? ' (HTML drag)' : ''}`;
878
878
  }
879
879
  /** 지금 페이지를 PDF로 저장한다. 경로를 안 주면 사용자 다운로드 폴더에 제목으로 저장. */
880
880
  export async function pdf(s, outPath, title) {
@@ -884,7 +884,7 @@ export async function pdf(s, outPath, title) {
884
884
  const file = outPath ? path.resolve(outPath) : path.join(os.homedir(), 'Downloads', `${safe}.pdf`);
885
885
  fs.mkdirSync(path.dirname(file), { recursive: true });
886
886
  fs.writeFileSync(file, Buffer.from(data, 'base64'));
887
- return `PDF로 저장했어요: ${file} (${(fs.statSync(file).size / 1024).toFixed(1)}KB)`;
887
+ return `Saved PDF: ${file} (${(fs.statSync(file).size / 1024).toFixed(1)}KB)`;
888
888
  }
889
889
  export async function waitForText(s, text, timeoutSec, stop) {
890
890
  const until = Date.now() + timeoutSec * 1000;
@@ -897,7 +897,7 @@ export async function waitForText(s, text, timeoutSec, stop) {
897
897
  try {
898
898
  const r = await s.evaluate(expression, { timeoutMs: 3000 });
899
899
  if (r.value)
900
- return `글자가 나타났어요: ${JSON.stringify(text)}`;
900
+ return `Text appeared: ${JSON.stringify(text)}`;
901
901
  }
902
902
  catch (e) {
903
903
  if (e instanceof CdpTimeoutError)
@@ -905,7 +905,7 @@ export async function waitForText(s, text, timeoutSec, stop) {
905
905
  }
906
906
  await sleep(200);
907
907
  }
908
- throw new CdpmError(`${timeoutSec}초 동안 ${JSON.stringify(text)}이(가) 나타나지 않았어요.`);
908
+ throw new CdpmError(`${JSON.stringify(text)} did not appear within ${timeoutSec}s.`);
909
909
  }
910
910
  /**
911
911
  * 주소가 바뀔 때까지 기다린다 (로그인 완료 감지 등). contains를 주면 그 글자가 들어간 주소가 될 때까지,
@@ -922,10 +922,10 @@ export async function waitForGone(s, text, timeoutSec, stop) {
922
922
  return why;
923
923
  const r = await s.evaluate(expression, { timeoutMs: 3000 }).catch(() => undefined);
924
924
  if (r?.value)
925
- return `글자가 사라졌어요: ${JSON.stringify(text)}`;
925
+ return `Text gone: ${JSON.stringify(text)}`;
926
926
  await sleep(100);
927
927
  }
928
- throw new CdpmError(`${timeoutSec}초 동안 ${JSON.stringify(text)}이(가) 사라지지 않았어요.`);
928
+ throw new CdpmError(`${JSON.stringify(text)} did not disappear within ${timeoutSec}s.`);
929
929
  }
930
930
  /** ref 요소가 눌릴 수 있게 될 때까지 (disabled·aria-disabled·감싸는 fieldset[disabled]가 모두 풀림). 화면은 건드리지 않는다. */
931
931
  export async function waitForEnabled(s, agent, ref, timeoutSec, stop) {
@@ -948,7 +948,7 @@ export async function waitForEnabled(s, agent, ref, timeoutSec, stop) {
948
948
  obj ??= await objectOf(fs, t);
949
949
  const st = await callOn(fs, obj, check).catch(() => 'gone');
950
950
  if (st === 'on')
951
- return `눌릴 수 있게 됐어요: [${ref}]`;
951
+ return `Now enabled: [${ref}]`;
952
952
  if (st === 'gone') {
953
953
  // 화면이 다시 그려지며 요소가 바뀌었을 수 있다 → 같은 ref로 한 번 더 찾아보고, 없으면 오류
954
954
  obj = undefined;
@@ -961,7 +961,7 @@ export async function waitForEnabled(s, agent, ref, timeoutSec, stop) {
961
961
  // Chrome이 붙잡고 있는 요소 손잡이를 놓는다 (놓지 않으면 사라진 요소도 Chrome 메모리에 남음)
962
962
  await release(fs);
963
963
  }
964
- throw new CdpmError(`${timeoutSec}초 동안 [${ref}]이(가) 눌릴 수 있게 되지 않았어요 (아직 비활성).`);
964
+ throw new CdpmError(`[${ref}] did not become enabled within ${timeoutSec}s (still disabled).`);
965
965
  }
966
966
  /**
967
967
  * 주소가 패턴에 맞는 네트워크 응답이 다 올 때까지 기다리고 그 요청을 돌려준다.
@@ -982,7 +982,7 @@ export async function waitForResponse(s, pattern, since, timeoutSec, stop) {
982
982
  return hit;
983
983
  await sleep(50);
984
984
  }
985
- throw new CdpmError(`${timeoutSec}초 동안 주소에 ${JSON.stringify(pattern)}이(가) 들어간 응답이 오지 않았어요. browser_network로 실제 요청 주소를 확인하세요.`);
985
+ throw new CdpmError(`No response with URL containing ${JSON.stringify(pattern)} within ${timeoutSec}s. Check actual request URLs with browser_network.`);
986
986
  }
987
987
  /** 기다리는 도중 다른 에이전트의 메시지 등으로 멈춤 (오류가 아니라 결과로 알린다) */
988
988
  export class WaitStopped extends Error {
@@ -998,11 +998,11 @@ export async function waitForUrl(s, contains, timeoutSec, stop) {
998
998
  return why;
999
999
  const now = await href();
1000
1000
  if (now && (contains ? decodeUrl(now).includes(contains) || now.includes(contains) : now !== start)) {
1001
- return `주소가 바뀌었어요: ${decodeUrl(now).slice(0, 200)}`;
1001
+ return `URL changed: ${decodeUrl(now).slice(0, 200)}`;
1002
1002
  }
1003
1003
  await sleep(100);
1004
1004
  }
1005
- throw new CdpmError(`${timeoutSec}초 동안 주소가 ${contains ? `"${contains}"이(가) 들어간 주소로` : ''} 바뀌지 않았어요 (지금: ${decodeUrl(start ?? '').slice(0, 120)}).`);
1005
+ throw new CdpmError(`URL did not change${contains ? ` to one containing "${contains}"` : ''} within ${timeoutSec}s (now: ${decodeUrl(start ?? '').slice(0, 120)}).`);
1006
1006
  }
1007
1007
  /**
1008
1008
  * 파일 칸에 파일을 넣는다 (OS 파일 선택 창 없이). ref가 있으면 그 파일 칸(또는 그 칸의 label)에,
@@ -1013,18 +1013,18 @@ export async function upload(s, agent, ref, files) {
1013
1013
  const paths = files.map((f) => path.resolve(f));
1014
1014
  const missing = paths.filter((p) => !fs.existsSync(p) || !fs.statSync(p).isFile());
1015
1015
  if (missing.length)
1016
- throw new CdpmError(`파일을 찾지 못했어요: ${missing.join(', ')}`);
1016
+ throw new CdpmError(`File not found: ${missing.join(', ')}`);
1017
1017
  const names = paths.map((p) => path.basename(p)).join(', ');
1018
1018
  if (!ref) {
1019
1019
  const c = s.fileChooser;
1020
1020
  if (!c || Date.now() - c.at > 10 * 60_000) {
1021
- throw new CdpmError('넣을 곳이 없어요. 파일 칸의 ref를 주거나, 먼저 "파일 첨부" 버튼을 browser_click으로 누르세요 (파일 선택 창을 가로채 둠).');
1021
+ throw new CdpmError('No target. Give the file input ref, or first browser_click the attach button (the file chooser will be intercepted).');
1022
1022
  }
1023
1023
  if (!c.multiple && paths.length > 1)
1024
- throw new CdpmError('이 파일 칸은 파일을 하나만 받아요.');
1024
+ throw new CdpmError('This file input accepts only one file.');
1025
1025
  await send(c.fs, 'DOM.setFileInputFiles', { files: paths, backendNodeId: c.backendNodeId });
1026
1026
  s.fileChooser = undefined;
1027
- return `파일을 넣었어요 (${paths.length}개): ${names}`;
1027
+ return `Uploaded ${paths.length} file(s): ${names}`;
1028
1028
  }
1029
1029
  const t = targetOf(s, agent, ref);
1030
1030
  const { fs: fsess } = await locate(s, t);
@@ -1032,16 +1032,16 @@ export async function upload(s, agent, ref, files) {
1032
1032
  const obj = await objectOf(fsess, t);
1033
1033
  const info = await describe(fsess, obj, ref);
1034
1034
  if (!info.fileInput)
1035
- throw new CdpmError(`[${ref}]는 파일 칸이 아니에요. 사이트가 만든 "첨부" 버튼이면 browser_click으로 누른 뒤 ref 없이 browser_upload를 부르세요.`);
1035
+ throw new CdpmError(`[${ref}] is not a file input. For a custom attach button, browser_click it, then call browser_upload without ref.`);
1036
1036
  const input = await callOnObject(fsess, obj, 'function () { return this.tagName === "LABEL" ? this.control : this; }');
1037
1037
  if (!input)
1038
- throw new CdpmError(`[${ref}]의 파일 칸을 찾지 못했어요.`);
1038
+ throw new CdpmError(`File input for [${ref}] not found.`);
1039
1039
  const multiple = await callOn(fsess, input, 'function () { return !!this.multiple; }');
1040
1040
  if (!multiple && paths.length > 1)
1041
- throw new CdpmError(`[${ref}]는 파일을 하나만 받아요.`);
1041
+ throw new CdpmError(`[${ref}] accepts only one file.`);
1042
1042
  await send(fsess, 'DOM.setFileInputFiles', { files: paths, objectId: input });
1043
1043
  const count = await callOn(fsess, input, 'function () { return this.files ? this.files.length : 0; }');
1044
- return `파일을 넣었어요: [${ref}] ${count}개 (${names})`;
1044
+ return `Uploaded to [${ref}]: ${count} file(s) (${names})`;
1045
1045
  }
1046
1046
  finally {
1047
1047
  await release(fsess);
@@ -1051,14 +1051,14 @@ export async function evaluate(s, expression) {
1051
1051
  await s.ensureNoDialog();
1052
1052
  const r = await s.evaluate(expression, { awaitPromise: true, timeoutMs: 30_000 });
1053
1053
  if (r.exception)
1054
- throw new CdpmError(`JS 오류: ${r.exception}`);
1054
+ throw new CdpmError(`JS error: ${r.exception}`);
1055
1055
  if (r.type === 'undefined')
1056
1056
  return 'undefined';
1057
1057
  if (r.unserializableValue)
1058
1058
  return r.unserializableValue;
1059
1059
  if ('value' in r) {
1060
1060
  const json = JSON.stringify(r.value, null, 2) ?? String(r.value);
1061
- return json.length > 20_000 ? json.slice(0, 20_000) + '\n… (잘렸음)' : json;
1061
+ return json.length > 20_000 ? json.slice(0, 20_000) + '\n… (truncated)' : json;
1062
1062
  }
1063
1063
  return r.description ?? String(r.type);
1064
1064
  }
@@ -1087,9 +1087,9 @@ export async function extractText(s, agent, ref, page) {
1087
1087
  }
1088
1088
  text = text.replace(/\n{3,}/g, '\n\n');
1089
1089
  if (!text)
1090
- return '(글자가 없어요)';
1090
+ return '(no text)';
1091
1091
  const p = paginate(text, page);
1092
- return `${p.body}\n\n— ${p.page}/${p.pages}쪽 (전체 ${text.length.toLocaleString()}자)${p.page < p.pages ? ` · 다음: page=${p.page + 1}` : ' · 끝'}`;
1092
+ return `${p.body}\n\n— page ${p.page}/${p.pages} (${text.length.toLocaleString()} chars)${p.page < p.pages ? ` · next: page=${p.page + 1}` : ' · end'}`;
1093
1093
  }
1094
1094
  /**
1095
1095
  * 화면 캡처. 탭을 앞으로 가져오거나 뷰포트를 바꾸지 않는다.
@@ -1124,14 +1124,14 @@ export async function screenshot(s, browser) {
1124
1124
  const { windowId } = await browser.send('Browser.getWindowForTarget', { targetId: s.targetId }, 3000);
1125
1125
  const { bounds } = await browser.send('Browser.getWindowBounds', { windowId }, 3000);
1126
1126
  if (bounds.windowState === 'minimized') {
1127
- throw new CdpmError('Chrome 창이 최소화돼 있어서 캡처할 수 없어요. CDPM은 창 상태를 바꾸지 않습니다. 필요하면 사용자에게 창을 띄워 달라고 하세요. (텍스트 스냅샷과 본문 읽기는 됩니다)');
1127
+ throw new CdpmError('Cannot capture: the Chrome window is minimized. CDPM does not change window state; ask the user to restore it if needed. (Text snapshot and browser_text still work.)');
1128
1128
  }
1129
1129
  }
1130
1130
  catch (e) {
1131
1131
  if (e instanceof CdpmError)
1132
1132
  throw e;
1133
1133
  }
1134
- throw new CdpmError('캡처하지 못했어요 (5초 동안 화면 프레임이 오지 않았어요). 페이지가 무겁거나 멈춰 있을 수 있어요. 텍스트 스냅샷이나 browser_text로 확인해 보세요.');
1134
+ throw new CdpmError('Capture failed (no frame within 5s). The page may be heavy or frozen. Try a text snapshot or browser_text.');
1135
1135
  }
1136
1136
  /** 진행 중인 네트워크 요청이 quietMs 동안 없고 문서 로딩도 끝났을 때까지 기다린다 (스크린샷·읽기 전에). */
1137
1137
  export async function waitNetworkIdle(s, timeoutSec, quietMs = 500, stop) {
@@ -1148,11 +1148,11 @@ export async function waitNetworkIdle(s, timeoutSec, quietMs = 500, stop) {
1148
1148
  else if (!quietSince)
1149
1149
  quietSince = Date.now();
1150
1150
  else if (Date.now() - quietSince >= quietMs)
1151
- return `네트워크가 잠잠해졌어요 (문서 로딩 완료, ${quietMs}ms 동안 진행 중인 요청 없음).`;
1151
+ return `Network idle (document loaded, no requests for ${quietMs}ms).`;
1152
1152
  await sleep(100);
1153
1153
  }
1154
1154
  const pending = s.network.list().filter((e) => s.network.inflight.has(e.requestId)).slice(-3).map((e) => ` - ${e.type} ${decodeUrl(e.url).slice(0, 100)}`);
1155
- return `${timeoutSec}초 안에 네트워크가 잠잠해지지 않았어요 (진행 중 ${s.network.inflight.size}개). 계속 요청을 보내는 페이지일 수 있어요.${pending.length ? `\n진행 중인 요청 예:\n${pending.join('\n')}` : ''}`;
1155
+ return `Network not idle within ${timeoutSec}s (${s.network.inflight.size} in flight). The page may poll continuously.${pending.length ? `\nPending examples:\n${pending.join('\n')}` : ''}`;
1156
1156
  }
1157
1157
  /** 방금(10초 안) 이 탭에서 다운로드가 시작됐으면 알림 문구 */
1158
1158
  export function downloadNote(s) {
@@ -1160,5 +1160,5 @@ export function downloadNote(s) {
1160
1160
  if (!d || Date.now() - d.at > 10_000)
1161
1161
  return '';
1162
1162
  s.lastDownload = undefined;
1163
- return `\n[주의] 파일 내려받기가 시작됐어요: ${d.file} (${decodeUrl(d.url).slice(0, 80)}) — 사용자 PC의 다운로드 폴더에 저장돼요. 끝나면 저장 경로를 받으려면 browser_download_wait.`;
1163
+ return `\n[warning] Download started: ${d.file} (${decodeUrl(d.url).slice(0, 80)}) — saved to the user's Downloads folder. Use browser_download_wait to get the path when done.`;
1164
1164
  }