cdpm-mcp 0.1.3 → 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.
@@ -44,7 +44,7 @@ export function formatAxTree(nodes, opts = {}) {
44
44
  const sub = node.backendDOMNodeId !== undefined ? ctx.frames?.get(node.backendDOMNodeId) : undefined;
45
45
  const head = `${pad(depth)}- iframe${name ? ` ${quote(name)}` : ''}`;
46
46
  if (sub === 'unsupported')
47
- return [`${head} (읽지 못함)`];
47
+ return [`${head} (unreadable)`];
48
48
  if (!sub)
49
49
  return [head];
50
50
  // 같은 프로세스 iframe은 요소 ID 공간이 같고, 다른 사이트 iframe은 자기 공간을 쓴다
package/dist/pause.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // 다시 시작하면 그 슬롯의 모든 에이전트에게 메시지를 보내 slot_inbox로 기다리던 에이전트를 바로 깨운다.
5
5
  import { sendMessage } from './registry/messages.js';
6
6
  import { readRegistry, updateRegistry } from './registry/store.js';
7
- import { ago, josa, nowIso } from './util.js';
7
+ import { ago, nowIso } from './util.js';
8
8
  export function pausedInfo(slot) {
9
9
  return readRegistry().slots[String(slot)]?.paused;
10
10
  }
@@ -23,10 +23,9 @@ export function pausedRefusal(slot) {
23
23
  const p = pausedInfo(slot);
24
24
  if (!p)
25
25
  return undefined;
26
- const when = ago(p.at);
27
- return `[멈춤] ${josa(p.agent, '이', '가')} ${when === '방금' ? when : `${when}에`} ${slot}번을 멈췄어요. 사용자가 직접 조작하는 중일 수 있으니 이 슬롯은 조작하지 마세요. ` +
28
- `slot_inbox(slot=${slot}, wait=600)로 기다리면 다시 시작될 때 메시지가 와요. 메시지를 받으면 화면이 바뀌었을 수 있으니 browser_snapshot으로 다시 읽고 이어 가세요. ` +
29
- '스스로 다시 시작(slot_resume)하지 마세요: 사용자가 정해요.';
26
+ return `[paused] ${p.agent} paused slot ${slot} (${ago(p.at)}). The user may be operating it, so don't act on this slot. ` +
27
+ `Wait with slot_inbox(slot=${slot}, wait=600); a message arrives on resume. The page may have changed, so re-read with browser_snapshot and continue. ` +
28
+ "Don't resume it yourself (slot_resume): the user decides.";
30
29
  }
31
30
  /** 슬롯들을 멈춘다. 꺼진 슬롯은 건너뛴다. 결과 안내 줄들을 돌려준다. */
32
31
  export async function pauseSlots(slots, by) {
@@ -41,11 +40,11 @@ export async function pauseSlots(slots, by) {
41
40
  const out = [];
42
41
  for (const slot of slots) {
43
42
  if (!done.includes(slot)) {
44
- out.push(`${slot}번은 켜져 있지 않아요.`);
43
+ out.push(`Slot ${slot} is not running.`);
45
44
  continue;
46
45
  }
47
- await sendMessage(slot, by, `[멈춤] 사용자가 ${slot}번을 멈췄어요. 조작하지 말고 slot_inbox(slot=${slot}, wait=600)로 기다리세요.`, null);
48
- out.push(`${slot}번을 멈췄어요. 이제 이 슬롯의 조작은 모두 거절되고, 기다리는 중이던 에이전트도 바로 멈춰요.`);
46
+ await sendMessage(slot, by, `[paused] The user paused slot ${slot}. Don't act; wait with slot_inbox(slot=${slot}, wait=600).`, null);
47
+ out.push(`Paused slot ${slot}. All actions on it are now refused, and waiting agents stop at once.`);
49
48
  }
50
49
  return out;
51
50
  }
@@ -60,11 +59,11 @@ export async function resumeSlots(slots, by) {
60
59
  const out = [];
61
60
  for (const slot of slots) {
62
61
  if (!was.includes(slot)) {
63
- out.push(`${slot}번은 멈춰 있지 않아요.`);
62
+ out.push(`Slot ${slot} is not paused.`);
64
63
  continue;
65
64
  }
66
- await sendMessage(slot, by, `[다시 시작] 사용자가 ${slot}번을 다시 시작했어요. 멈춘 동안 화면이 바뀌었을 수 있으니 browser_snapshot으로 다시 읽고 하던 일을 이어 가세요.`, null);
67
- out.push(`${slot}번을 다시 시작했어요. 기다리던 에이전트에게 알렸어요.`);
65
+ await sendMessage(slot, by, `[resumed] The user resumed slot ${slot}. The page may have changed while paused; re-read with browser_snapshot and continue your task.`, null);
66
+ out.push(`Resumed slot ${slot}. Waiting agents were notified.`);
68
67
  }
69
68
  return out;
70
69
  }
@@ -19,7 +19,7 @@ function tunnel(host, port) {
19
19
  const s = connectUpstream();
20
20
  const fail = (e) => { s.destroy(); reject(e); };
21
21
  s.once('error', fail);
22
- s.setTimeout(20_000, () => fail(new Error('프록시 응답 없음')));
22
+ s.setTimeout(20_000, () => fail(new Error('Proxy not responding')));
23
23
  const ready = () => { s.setTimeout(0); s.removeListener('error', fail); resolve(s); };
24
24
  s.once(up.scheme === 'https' ? 'secureConnect' : 'connect', () => {
25
25
  if (up.scheme === 'socks5')
@@ -35,7 +35,7 @@ function tunnel(host, port) {
35
35
  s.pause(); // 다 읽은 뒤 멈춰 둬야, 이어서 온 데이터가 읽는 쪽이 붙기 전에 버려지지 않는다
36
36
  const status = /^HTTP\/1\.[01] (\d{3})/.exec(buf.toString('latin1'))?.[1];
37
37
  if (status !== '200')
38
- return fail(new Error(`프록시가 연결을 거절했어요 (HTTP ${status ?? '?'})`));
38
+ return fail(new Error(`Proxy refused the connection (HTTP ${status ?? '?'})`));
39
39
  const rest = buf.subarray(end + 4);
40
40
  if (rest.length)
41
41
  s.unshift(rest);
@@ -59,7 +59,7 @@ function readBytes(s, n) {
59
59
  s.unshift(buf.subarray(n));
60
60
  resolve(buf.subarray(0, n));
61
61
  };
62
- const onClose = () => reject(new Error('프록시가 연결을 끊었어요'));
62
+ const onClose = () => reject(new Error('Proxy closed the connection'));
63
63
  s.on('data', onData);
64
64
  s.once('close', onClose);
65
65
  s.resume(); // 앞에서 멈춰 둔 소켓은 data 리스너만으로는 다시 흐르지 않는다
@@ -73,10 +73,10 @@ async function socks5(s, host, port) {
73
73
  s.write(Buffer.concat([Buffer.from([1, u.length]), u, Buffer.from([p.length]), p]));
74
74
  const [, ok] = await readBytes(s, 2);
75
75
  if (ok !== 0)
76
- throw new Error('socks5 프록시가 아이디·비밀번호를 거절했어요');
76
+ throw new Error('socks5 proxy rejected the username/password');
77
77
  }
78
78
  else if (method !== 0)
79
- throw new Error('socks5 프록시가 인증 방식을 받지 않았어요');
79
+ throw new Error('socks5 proxy rejected the auth method');
80
80
  // 주소 이름을 그대로 넘겨 DNS도 프록시 쪽에서 풀게 한다 (이 PC의 DNS로 새지 않게)
81
81
  const h = host.replace(/^\[|\]$/g, '');
82
82
  const ipType = net.isIP(h);
@@ -86,7 +86,7 @@ async function socks5(s, host, port) {
86
86
  s.write(Buffer.concat([Buffer.from([5, 1, 0]), addr, Buffer.from([port >> 8, port & 255])]));
87
87
  const head = await readBytes(s, 4);
88
88
  if (head[1] !== 0)
89
- throw new Error(`socks5 프록시가 연결을 거절했어요 (코드 ${head[1]})`);
89
+ throw new Error(`socks5 proxy refused the connection (code ${head[1]})`);
90
90
  const len = head[3] === 1 ? 4 : head[3] === 4 ? 16 : (await readBytes(s, 1))[0];
91
91
  await readBytes(s, len + 2);
92
92
  }
@@ -114,7 +114,7 @@ const server = http.createServer((req, res) => {
114
114
  const headers = { ...req.headers };
115
115
  delete headers['proxy-connection'];
116
116
  const done = (e) => { if (!res.headersSent)
117
- res.writeHead(502, { 'content-type': 'text/plain; charset=utf-8' }); res.end(`CDPM 프록시 중계 오류: ${e.message}`); };
117
+ res.writeHead(502, { 'content-type': 'text/plain; charset=utf-8' }); res.end(`CDPM proxy forwarder error: ${e.message}`); };
118
118
  if (up.scheme === 'socks5') {
119
119
  const port = Number(target.port || 80);
120
120
  tunnel(target.hostname, port).then((sock) => {
@@ -147,7 +147,7 @@ server.on('connect', (req, client, head) => {
147
147
  remote.pipe(client);
148
148
  client.pipe(remote);
149
149
  }, (e) => {
150
- client.end(`HTTP/1.1 502 Bad Gateway\r\ncontent-type: text/plain; charset=utf-8\r\n\r\nCDPM 프록시 중계 오류: ${e.message}`);
150
+ client.end(`HTTP/1.1 502 Bad Gateway\r\ncontent-type: text/plain; charset=utf-8\r\n\r\nCDPM proxy forwarder error: ${e.message}`);
151
151
  });
152
152
  });
153
153
  /** 그 슬롯 포트에 떠 있는 Chrome의 고유 주소 (Chrome마다 다름). 응답이 없으면 undefined. */
@@ -13,11 +13,11 @@ export class LockTimeoutError extends Error {
13
13
  * (느린 프로세스의 잠금을 뺏어 기록이 깨지는 일이 없게).
14
14
  */
15
15
  export async function withLock(fn, timeoutMs = 10_000) {
16
- return withFileLock(paths.lock(), fn, timeoutMs, '저장소 잠금을 얻지 못했어요 (다른 프로세스가 오래 쓰는 중).');
16
+ return withFileLock(paths.lock(), fn, timeoutMs, 'Could not acquire the store lock (another process is holding it).');
17
17
  }
18
18
  /** 슬롯 켜기·끄기를 여러 Claude 세션 사이에서 하나씩 (동시에 켜면 Chrome이 두 번 떠서 하나가 실패함). */
19
19
  export function withSlotLock(slot, fn) {
20
- return withFileLock(paths.slotLock(slot), fn, 90_000, `다른 Claude 세션이 ${slot}번을 켜거나 끄는 중이에요. 잠시 뒤 다시 하세요.`);
20
+ return withFileLock(paths.slotLock(slot), fn, 90_000, `Another Claude session is launching or closing slot ${slot}. Try again shortly.`);
21
21
  }
22
22
  /** 같은 방식의 잠금을 원하는 파일로 (예: 탭 하나를 여러 Claude 세션이 동시에 조작하지 않게). */
23
23
  export async function withFileLock(lockPath, fn, timeoutMs, timeoutMessage) {
package/dist/service.js CHANGED
@@ -9,8 +9,8 @@ import { newSlotRecord, readRegistry, updateRegistry } from './registry/store.js
9
9
  import { MAX_SLOT, portOf } from './slots.js';
10
10
  import { applyDock, DOCK_SUPPORTED } from './taskbar/dock.js';
11
11
  import { applyTaskbar } from './taskbar/watcher.js';
12
- import { ago, josa, nowIso, pidAlive, secondsSince, sleep } from './util.js';
13
- export const EXTERNAL = '(외부)';
12
+ import { ago, nowIso, pidAlive, secondsSince, sleep } from './util.js';
13
+ export const EXTERNAL = '(external)';
14
14
  /** 이 프로세스가 직접 만든 탭 → 만든 에이전트. 기록부에 처음 올릴 때 openedBy로 쓴다. */
15
15
  const createdBy = new Map();
16
16
  const createdAt = new Map();
@@ -27,8 +27,8 @@ export function markCreated(targetId, agent) {
27
27
  }
28
28
  }
29
29
  }
30
- export const notRunningMessage = (slot) => `${slot}번 Chrome은 꺼져 있어요. CDPM은 사용자가 켜 달라고 할 때만 Chrome을 켭니다. ` +
31
- `사용자에게 켤지 물어보고, 켜라고 하면 browser_launch를 쓰세요.`;
30
+ export const notRunningMessage = (slot) => `Chrome on slot ${slot} is off. CDPM starts Chrome only when the user asks. ` +
31
+ `Ask the user whether to start it; if yes, use browser_launch.`;
32
32
  /** 떠 있는 슬롯에 붙는다 (기록·작업표시줄 맞춤). 꺼져 있으면 켜지 않고 오류. */
33
33
  /** 포트 확인. 늦게 답하면(바쁜 Chrome) 길게 한 번 더 묻는다. */
34
34
  async function probeSure(slot) {
@@ -36,7 +36,7 @@ async function probeSure(slot) {
36
36
  if (p.state === 'slow')
37
37
  p = await probe(slot, 8000);
38
38
  if (p.state === 'slow') {
39
- throw new CdpmError(`${slot}번 포트(${portOf(slot)})가 8초 넘게 응답하지 않아요. Chrome이 매우 바쁘거나 멈췄을 수 있어요. 잠시 뒤 다시 시도하세요.`);
39
+ throw new CdpmError(`Slot ${slot} port (${portOf(slot)}) has not responded for over 8s. Chrome may be very busy or hung. Retry shortly.`);
40
40
  }
41
41
  return p;
42
42
  }
@@ -60,7 +60,7 @@ export async function attachSlot(slot) {
60
60
  pid = await browserPid(slot);
61
61
  if (!pid || !pidAlive(pid)) {
62
62
  await forgetSlot(slot);
63
- throw new CdpmError(`${slot}번 포트(${portOf(slot)})에 이 PC가 아닌 Chrome이 연결돼 있어요 (SSH 터널 등). 그 연결을 닫거나 다른 슬롯을 쓰세요.`);
63
+ throw new CdpmError(`Slot ${slot} port (${portOf(slot)}) is connected to a Chrome on another machine (SSH tunnel, etc.). Close that connection or use another slot.`);
64
64
  }
65
65
  await updateRegistry((r) => {
66
66
  const s = (r.slots[String(slot)] ??= newSlotRecord(EXTERNAL, nowIso()));
@@ -72,7 +72,7 @@ export async function attachSlot(slot) {
72
72
  void applyDock(slot, pid); // macOS만
73
73
  }
74
74
  function portBusy(slot, detail) {
75
- return new CdpmError(`${slot}번 슬롯의 포트 ${portOf(slot)}를 Chrome이 아닌 프로그램이 사용 중입니다 (${detail}). 그 프로그램을 종료하거나 다른 슬롯을 쓰세요.`);
75
+ return new CdpmError(`Slot ${slot} port ${portOf(slot)} is used by a non-Chrome program (${detail}). Close it or use another slot.`);
76
76
  }
77
77
  /** 사용자가 켜라고 했을 때만 부른다. 이미 떠 있으면 붙기만 한다. */
78
78
  export function launchSlot(slot, agent, opts = {}) {
@@ -174,7 +174,7 @@ export async function syncTabs(slot) {
174
174
  const opener = openers.get(p.id);
175
175
  if (!openedBy && opener) {
176
176
  const by = s.tabs[opener]?.last?.agent;
177
- openedBy = by ? `${by} (페이지가 염)` : `${s.tabs[opener]?.id ?? '다른 탭'}에서 페이지가 염`;
177
+ openedBy = by ? `${by} (via page)` : `page in ${s.tabs[opener]?.id ?? 'another tab'}`;
178
178
  }
179
179
  const seq = s.nextTabSeq++;
180
180
  s.tabs[p.id] = { id: `t${seq}`, seq, seenAt: nowIso(), openedBy: openedBy ?? EXTERNAL };
@@ -208,13 +208,13 @@ export function pickTab(tabs, tabArg, kind, preferred) {
208
208
  const found = byId ?? byNo;
209
209
  if (found)
210
210
  return { tab: found };
211
- const list = tabs.map((t) => `${t.no}번 [${t.id}]`).join(', ');
212
- return { error: `없는 탭이에요: "${s}". 지금 있는 탭: ${list || '없음'}` };
211
+ const list = tabs.map((t) => `${t.no} [${t.id}]`).join(', ');
212
+ return { error: `No such tab: "${s}". Open tabs: ${list || 'none'}` };
213
213
  }
214
214
  if (tabs.length === 1)
215
215
  return { tab: tabs[0] };
216
216
  if (tabs.length === 0)
217
- return { error: '열린 탭이 없어요.' };
217
+ return { error: 'No open tabs.' };
218
218
  // 이 에이전트가 마지막으로 쓴(또는 새로 연) 탭이 있으면 보기·조작 모두 그 탭
219
219
  const mine = tabs.find((t) => t.targetId === preferred);
220
220
  if (mine)
@@ -222,7 +222,7 @@ export function pickTab(tabs, tabArg, kind, preferred) {
222
222
  // 보기 도구: 앞에 보이는 탭 → 첫 탭. 조작 도구: 쓴 적 있는 탭이 없으면 지정을 요구한다.
223
223
  if (kind === 'view')
224
224
  return { tab: tabs.find((t) => t.active) ?? tabs[0] };
225
- return { error: `탭이 ${tabs.length}개 있고 이 에이전트가 아직 쓴 탭이 없어요. 어느 탭에서 실행할지 tab에 번호나 ID(예: "${tabs[0].id}")를 지정하세요.` };
225
+ return { error: `There are ${tabs.length} tabs and this agent has not used any yet. Set tab to a number or ID (e.g. "${tabs[0].id}").` };
226
226
  }
227
227
  /** 다른 에이전트가 최근(2분 안)에 조작한 탭을 조작할 때 붙일 경고 (막지는 않음). */
228
228
  export function ownershipWarnings(tab, agent) {
@@ -230,7 +230,7 @@ export function ownershipWarnings(tab, agent) {
230
230
  if (!last || last.agent === agent || secondsSince(last.at) > 120)
231
231
  return [];
232
232
  const when = ago(last.at);
233
- return [`이 탭 [${tab.id}]은 ${josa(last.agent, '이', '가')} ${when === '방금' ? when : `${when}에`} ${last.action}했어요. 같이 쓰는 중이면 slot_send로 알려 주세요.`];
233
+ return [`Tab [${tab.id}] was used by ${last.agent} ${when} (${last.action}). If sharing it, tell them via slot_send.`];
234
234
  }
235
235
  /** 행동 기록. 기록부 잠금에 실패해도 도구 동작은 성공으로 두고 false를 돌려준다. */
236
236
  export async function recordAction(slot, targetId, agent, action, summary, anon = false, title) {
package/dist/slots.js CHANGED
@@ -23,7 +23,7 @@ export function isValidSlot(slot) {
23
23
  }
24
24
  export function assertSlot(slot) {
25
25
  if (!isValidSlot(slot)) {
26
- throw new CdpmError(`슬롯은 ${MIN_SLOT}~${MAX_SLOT}번입니다. (받은 값: ${String(slot)})`);
26
+ throw new CdpmError(`Slot must be ${MIN_SLOT}-${MAX_SLOT} (got: ${String(slot)})`);
27
27
  }
28
28
  }
29
29
  /**
@@ -1,35 +1,35 @@
1
1
  import { portOf } from '../slots.js';
2
2
  import { ago, displayWidth, padEnd, shortUrl, truncate } from '../util.js';
3
3
  export function tabLines(tabs, markTargetId, withSummary = false) {
4
- const titles = tabs.map((t) => truncate(t.title || '(제목 없음)', 34));
4
+ const titles = tabs.map((t) => truncate(t.title || '(untitled)', 34));
5
5
  const urls = tabs.map((t) => shortUrl(t.url, 34));
6
6
  const tw = Math.max(0, ...titles.map(displayWidth));
7
7
  const uw = Math.max(0, ...urls.map(displayWidth));
8
8
  const lines = [];
9
9
  tabs.forEach((t, i) => {
10
10
  const mark = t.targetId === markTargetId ? '>' : ' ';
11
- const last = t.rec.last ? ` 마지막: ${t.rec.last.agent} ${t.rec.last.action} (${ago(t.rec.last.at)})` : '';
12
- const active = t.active ? ' ·앞' : '';
13
- lines.push(`${mark} ${t.no}. [${t.id}]${active} ${padEnd(titles[i], tw)} ${padEnd(urls[i], uw)} 연 사람: ${t.rec.openedBy}${last}`);
11
+ const last = t.rec.last ? ` last: ${t.rec.last.agent} ${t.rec.last.action} (${ago(t.rec.last.at)})` : '';
12
+ const active = t.active ? ' ·front' : '';
13
+ lines.push(`${mark} ${t.no}. [${t.id}]${active} ${padEnd(titles[i], tw)} ${padEnd(urls[i], uw)} opened by: ${t.rec.openedBy}${last}`);
14
14
  if (withSummary && t.rec.summary) {
15
- lines.push(` 요약: ${t.rec.summary.agent} — ${t.rec.summary.text} (${ago(t.rec.summary.at)})`);
15
+ lines.push(` summary: ${t.rec.summary.agent} — ${t.rec.summary.text} (${ago(t.rec.summary.at)})`);
16
16
  }
17
17
  });
18
18
  return lines;
19
19
  }
20
20
  export function formatHeader(h) {
21
21
  const exec = h.tabs.find((t) => t.targetId === h.executedTargetId);
22
- const lines = [`[${h.slot}번] 탭 ${h.tabs.length}개${exec ? ` · ${exec.no}번 탭 [${exec.id}]에서 실행함` : ''}`];
22
+ const lines = [`[Slot ${h.slot}] ${h.tabs.length} tab(s)${exec ? ` · ran on tab ${exec.no} [${exec.id}]` : ''}`];
23
23
  lines.push(...tabLines(h.tabs, h.executedTargetId));
24
24
  for (const t of h.tabs) {
25
25
  const d = h.dialogs?.get(t.targetId);
26
26
  if (d)
27
- lines.push(`[주의] ${d.type} 알림창 떠 있음 (${t.no}번 탭 [${t.id}]): "${truncate(d.message, 80)}" — 내용을 보고 browser_dialog로 직접 처리 (시키지 않은 결제·삭제 같은 확정 창만 사용자에게 묻기)`);
27
+ lines.push(`[warning] dialog open (${d.type}) on tab ${t.no} [${t.id}]: "${truncate(d.message, 80)}" — read it and handle it yourself with browser_dialog (ask the user only for confirmations of unrequested payment/deletion etc.)`);
28
28
  }
29
29
  for (const w of h.warnings ?? [])
30
- lines.push(`[주의] ${w}`);
30
+ lines.push(`[warning] ${w}`);
31
31
  if (h.messages?.length) {
32
- lines.push(`새 메시지 ${h.messages.length}개 (여기서 읽음 처리됨 — slot_inbox에는 다시 나오지 않아요)`);
32
+ lines.push(`${h.messages.length} new message(s) (marked read here; won't appear again in slot_inbox)`);
33
33
  lines.push(...formatMessages(h.messages).map((l) => ` ${l}`));
34
34
  }
35
35
  return lines.join('\n');
@@ -38,10 +38,10 @@ export function formatMessages(msgs) {
38
38
  return msgs.map((m) => `${m.from}${m.to ? ` → ${m.to}` : ''} (${ago(m.at)}): ${m.text}`);
39
39
  }
40
40
  export function formatSlotStatus(slot, rec, tabs) {
41
- const mode = rec.headless ? ' · 헤드리스' : '';
42
- const lines = [`[${slot}번] 포트 ${portOf(slot)}${mode} · 탭 ${tabs ? `${tabs.length}개` : '?'} · 띄운 쪽: ${rec.launchedBy ?? '(외부)'} (${ago(rec.launchedAt)})`];
41
+ const mode = rec.headless ? ' · headless' : '';
42
+ const lines = [`[Slot ${slot}] port ${portOf(slot)}${mode} · ${tabs ? `${tabs.length}` : '?'} tab(s) · launched by: ${rec.launchedBy ?? '(external)'} (${ago(rec.launchedAt)})`];
43
43
  if (rec.summary)
44
- lines.push(` 요약: ${rec.summary.agent} — ${rec.summary.text} (${ago(rec.summary.at)})`);
44
+ lines.push(` summary: ${rec.summary.agent} — ${rec.summary.text} (${ago(rec.summary.at)})`);
45
45
  if (tabs)
46
46
  lines.push(...tabLines(tabs, undefined, true).map((l) => ` ${l}`));
47
47
  return lines.join('\n');
@@ -4,13 +4,13 @@ const MAX_REMOVED_SHOWN = 15;
4
4
  function footer(p, total) {
5
5
  if (p.pages <= 1)
6
6
  return '';
7
- return `\n— 1/${p.pages}쪽 (전체 ${total.toLocaleString()}자) · 이어 보기: browser_snapshot page=2`;
7
+ return `\n— page 1/${p.pages} (${total.toLocaleString()} chars total) · continue: browser_snapshot page=2`;
8
8
  }
9
9
  /** 스냅샷 1쪽 (browser_snapshot과 같은 모양). */
10
10
  async function snapshotPage1(s, agent) {
11
11
  const { text } = await takeSnapshot(s, agent);
12
12
  if (!text)
13
- return '(읽을 수 있는 요소가 없어요)';
13
+ return '(no readable elements)';
14
14
  const p = paginate(text, 1);
15
15
  return p.body + footer(p, text.length);
16
16
  }
@@ -24,9 +24,9 @@ async function changes(s, agent) {
24
24
  const samePage = prev && prev.url.split('#')[0] === url.split('#')[0];
25
25
  if (!prev || !samePage) {
26
26
  if (!text)
27
- return '(읽을 수 있는 요소가 없어요)';
27
+ return '(no readable elements)';
28
28
  const p = paginate(text, 1);
29
- return `(${prev ? '다른 페이지로 바뀌어서' : '비교할 직전 화면이 없어서'} 전체를 보여줘요)\n${p.body}${footer(p, text.length)}`;
29
+ return `(${prev ? 'page changed' : 'no previous snapshot to compare'}; showing full page)\n${p.body}${footer(p, text.length)}`;
30
30
  }
31
31
  const count = (lines) => {
32
32
  const m = new Map();
@@ -54,16 +54,16 @@ async function changes(s, agent) {
54
54
  removed.push(l);
55
55
  }
56
56
  if (!added.length && !removed.length)
57
- return '(화면 변화 없음)';
58
- const out = [`바뀐 부분 (직전 화면 대비): 새로 생김 ${added.length}줄 · 사라짐 ${removed.length}줄`];
57
+ return '(no changes)';
58
+ const out = [`Changes since last snapshot: ${added.length} added · ${removed.length} removed`];
59
59
  if (added.length) {
60
60
  const p = paginate(added.map((l) => `+ ${l.trimStart()}`).join('\n'), 1);
61
- out.push(p.body + (p.pages > 1 ? `\n— 새로 생긴 줄이 많아 일부만 보여줘요 (전체: browser_snapshot)` : ''));
61
+ out.push(p.body + (p.pages > 1 ? `\n— too many new lines; partial (full: browser_snapshot)` : ''));
62
62
  }
63
63
  if (removed.length) {
64
64
  out.push(...removed.slice(0, MAX_REMOVED_SHOWN).map((l) => `- ${l.trimStart()}`));
65
65
  if (removed.length > MAX_REMOVED_SHOWN)
66
- out.push(`- … 외 ${removed.length - MAX_REMOVED_SHOWN}줄`);
66
+ out.push(`- … ${removed.length - MAX_REMOVED_SHOWN} more`);
67
67
  }
68
68
  return out.join('\n');
69
69
  }
@@ -73,9 +73,9 @@ export async function readAfter(s, agent, mode) {
73
73
  return '';
74
74
  try {
75
75
  const body = mode === 'text' ? await act.extractText(s, agent, undefined, 1) : mode === 'snapshot' ? await snapshotPage1(s, agent) : await changes(s, agent);
76
- return `\n\n[화면: ${mode === 'text' ? '본문' : mode === 'snapshot' ? '스냅샷' : '바뀐 부분'}]\n${body}`;
76
+ return `\n\n[page: ${mode}]\n${body}`;
77
77
  }
78
78
  catch (e) {
79
- return `\n\n[화면 읽기 실패: ${e.message}]`;
79
+ return `\n\n[page read failed: ${e.message}]`;
80
80
  }
81
81
  }