cdpm-mcp 0.1.7 → 0.1.8
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/chrome/version.js +76 -0
- package/dist/service.js +118 -4
- package/dist/tools/register.js +13 -0
- 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.8 (2026-10-17)
|
|
7
|
+
|
|
8
|
+
- 슬롯 Chrome이 실행 중에 업데이트되면 새 탭이 빈 채로 멈추던 문제를 해결했어요. Windows는 Chrome 업데이트가 `chrome.exe`를 새 버전으로 바꿔치기하는데, 옛 버전으로 도는 Chrome이 새 탭용 화면 프로세스(렌더러)를 띄울 때 바뀐 실행 파일을 써서 버전이 맞지 않아 바로 죽어요(실측: 154로 돌던 슬롯은 새 탭이 응답 없음, 155로 뜬 슬롯은 정상). 이미 열려 있던 탭은 멀쩡하지만, 다른 사이트로 넘어가거나 새로 고치면 죽을 수 있어요.
|
|
9
|
+
- CDPM이 슬롯 Chrome의 버전과 디스크에 설치된 Chrome의 버전을 비교해요. 슬롯에 붙을 때 한 번 비교하고, 그 뒤로는 10초마다 `chrome.exe` 파일이 바뀌었는지만 봐요(파일 정보만 읽어서 가벼움). 파일이 바뀌었을 때만 슬롯들에 버전을 물어 비교해요. 바꿔치기는 이름만 바뀌어 수정 시각이 그대로일 수 있어서, 파일 자체가 바뀌었는지(파일 번호·크기)도 봐요.
|
|
10
|
+
- 다르면 그 슬롯을 새 버전으로 자동으로 다시 켜요. 열려 있던 탭 주소를 순서대로 다시 열고, 창 모드·헤드리스는 그대로예요. 로그인은 프로필에 남아요. 다음 도구 결과 머리말에 다시 켰다는 알림이 에이전트마다 한 번 붙어요 (탭 ID가 바뀌었고 저장 안 한 입력은 사라졌다는 안내 포함).
|
|
11
|
+
- 프록시 슬롯은 접속 정보가 기록에 없어서 자동으로 다시 켜지 않고 알리기만 해요. 다시 켜도 버전이 계속 다르면 같은 상황으로는 다시 켜지 않아요 (무한 반복 방지).
|
|
12
|
+
|
|
6
13
|
## 0.1.7 (2026-10-17)
|
|
7
14
|
|
|
8
15
|
- PC가 재부팅된 뒤 Windows가 슬롯 Chrome을 다시 띄우면, 작업표시줄의 슬롯 아이콘이 일반 Chrome 아이콘으로 풀리던 문제를 고쳤어요. 기록부에는 재부팅 전 Chrome 번호가 남아 있는데, CDPM은 그 번호가 죽었을 때만 다시 확인했어요. 옛 번호를 다른 프로그램이 받으면 영영 안 고쳐지고, 그 프로그램이 VS Code처럼 같은 창 종류를 쓰면 슬롯 아이콘이 엉뚱한 창에 붙을 수도 있었어요.
|
package/README.ko.md
CHANGED
|
@@ -254,6 +254,7 @@ Windows `%LOCALAPPDATA%\cdpm\`, macOS `~/Library/Application Support/cdpm/`, Lin
|
|
|
254
254
|
- 실행 인자는 `--remote-debugging-port`, `--user-data-dir`, `--no-first-run`, `--no-default-browser-check`, `--window-name=N번`뿐이에요 (헤드리스 요청 시 `--headless`, 사용자가 프록시를 부탁했을 때만 `--proxy-server`와 `--force-webrtc-ip-handling-policy=disable_non_proxied_udp` 추가). 헤드리스 Chrome은 User-Agent에 `HeadlessChrome`이 그대로 찍혀요.
|
|
255
255
|
- 창 크기·위치·상태, 뷰포트, 확대 비율을 바꾸지 않아요. 페이지가 클릭 때문에 전체 화면이 되면 바로 해제해요.
|
|
256
256
|
- `Runtime.enable`을 쓰지 않고, 판단용 스크립트는 전부 isolated world에서 실행해요.
|
|
257
|
+
- 슬롯이 켜져 있는 동안 Chrome이 업데이트되면(Windows는 `chrome.exe`를 바꿔치기) 옛 버전 Chrome이 화면 프로세스를 띄우지 못해 새 탭이 빈 채로 멈춰요. CDPM이 실행 중인 버전과 설치된 버전을 비교해서(슬롯에 붙을 때, 그리고 10초마다 파일 정보만 봐서 `chrome.exe`가 바뀌었을 때) 다르면 그 슬롯을 새 버전으로 다시 켜고 탭을 순서대로 다시 열어요(로그인 유지, 프록시 슬롯은 알리기만).
|
|
257
258
|
- Chrome 권한 요청 말풍선은 페이지가 아니라 브라우저 화면이라 스냅샷·스크린샷에 안 보이고 페이지 도구로 누를 수 없는데, 페이지는 그 답을 기다리며 멈춰요. Windows에서는 CDPM이 이걸 찾아서(슬롯 Chrome 창에 딸린 작은 창 중 제목에 탭의 사이트 주소가 들어간 것. 번역·비밀번호 저장 말풍선은 걸러지고 Chrome 언어와 상관없음) 결과 머리말로 알리고, `browser_wait` 중이면 뜨는 즉시 멈추고, Claude가 `browser_permission`으로 버튼을 눌러요(UI Automation. 창이 최소화되거나 가려져 있어도 됨). 사용자가 시키지 않은 카메라·마이크·위치 허용은 먼저 물어봐요.
|
|
258
259
|
- 알림창(alert/confirm/prompt/beforeunload)을 정해진 규칙으로 자동 처리하지 않아요. 떠 있으면 알리고, Claude가 내용을 보고 `browser_dialog`로 직접 확인·취소해요. 사용자가 시키지 않은 되돌릴 수 없는 일(결제·삭제 등)을 확정하는 창일 때만 먼저 물어봐요.
|
|
259
260
|
- 거부하는 동작: `mailto:`·`tel:`·앱 전용 주소로 클릭·이동·켜면서 열기·새 탭 열기(다른 프로그램 실행), `<select>` 클릭(목록 창), `Ctrl+C/X/V`·`Shift+Insert`(사용자 클립보드)
|
package/README.md
CHANGED
|
@@ -186,6 +186,7 @@ Data lives in `%LOCALAPPDATA%\cdpm\` on Windows `~/Library/Application Support/c
|
|
|
186
186
|
- Launch flags are only `--remote-debugging-port`, `--user-data-dir`, `--no-first-run`, `--no-default-browser-check`, `--window-name` (plus `--headless` on request, and `--proxy-server` + `--force-webrtc-ip-handling-policy=disable_non_proxied_udp` only when the user asks for a proxy; headless Chrome still reports `HeadlessChrome`).
|
|
187
187
|
- Never changes window size/position/state, viewport, or zoom; if a click makes the page fullscreen, it is exited immediately.
|
|
188
188
|
- No `Runtime.enable`; helper scripts run in an isolated world.
|
|
189
|
+
- If Chrome updates itself while a slot is running (Windows swaps `chrome.exe`), the old browser can no longer start renderers, so new tabs hang blank. CDPM compares the running version with the installed one (on attach, and whenever the `chrome.exe` file changes, checked every 10s from file info only) and restarts that slot on the new version, reopening its tabs in order (logins are kept; proxy slots are only reported).
|
|
189
190
|
- Chrome permission bubbles are browser UI, so they never show up in snapshots or screenshots and page tools can't click them, while the page waits on them. On Windows, CDPM spots them (a small window owned by the slot's Chrome whose title contains a tab's host, so translate or password bubbles are ignored and the Chrome language doesn't matter), warns in the result header, stops `browser_wait` as soon as one appears, and lets Claude press a button with `browser_permission` (UI Automation; works while the window is minimized or covered). Claude asks before allowing camera, microphone or location the user didn't ask for.
|
|
190
191
|
- Dialogs (alert/confirm/prompt/beforeunload) are reported, never handled automatically. Claude reads the message and handles it itself with `browser_dialog` (accept or dismiss); it asks the user only when the dialog would confirm something irreversible the user did not ask for (a payment, a deletion).
|
|
191
192
|
- Refuses: `mailto:`/`tel:`/app-scheme links and addresses in click, navigate, launch start pages and new tabs (would launch other programs), clicking `<select>` (popup), `Ctrl+C/X/V`/`Shift+Insert` (user clipboard). Downloads triggered by navigation are reported with the file name.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// 디스크에 설치된 Chrome 실행 파일의 버전. 실행 중인 슬롯 Chrome의 버전과 다르면 "실행 중에 업데이트된" 것이다:
|
|
2
|
+
// Windows는 업데이트가 chrome.exe를 새 버전으로 바꿔치기하는데, 옛 버전으로 도는 본체가 새 탭용 렌더러를 띄울 때
|
|
3
|
+
// 바뀐 chrome.exe를 실행해 버전이 맞지 않아 렌더러가 바로 죽는다 → 새 탭·다른 사이트로 이동한 탭이 빈 채로 멈춘다 (실측).
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { findChrome } from './finder.js';
|
|
8
|
+
/** Windows 실행 파일(PE)의 버전 정보에서 ProductVersion 값을 읽는다 (예: "155.0.8059.82"). */
|
|
9
|
+
export function peProductVersion(buf) {
|
|
10
|
+
const key = Buffer.from('ProductVersion\0', 'utf16le');
|
|
11
|
+
for (let at = buf.indexOf(key); at >= 0; at = buf.indexOf(key, at + 2)) {
|
|
12
|
+
let p = at + key.length;
|
|
13
|
+
while (p % 4)
|
|
14
|
+
p++; // 값은 4바이트 경계에서 시작한다
|
|
15
|
+
let end = p;
|
|
16
|
+
while (end + 1 < buf.length && end - p < 128 && (buf[end] | buf[end + 1]) !== 0)
|
|
17
|
+
end += 2;
|
|
18
|
+
const v = buf.toString('utf16le', p, end).trim();
|
|
19
|
+
if (/^\d+(\.\d+){1,3}$/.test(v))
|
|
20
|
+
return v;
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
let cache;
|
|
25
|
+
/**
|
|
26
|
+
* 설치된 Chrome 실행 파일의 "정체" (경로·파일 번호·크기·수정 시각). 파일 정보만 보므로 아주 가볍다.
|
|
27
|
+
* 바뀌었을 때만 버전을 다시 읽고 슬롯들과 비교하면 된다.
|
|
28
|
+
*/
|
|
29
|
+
export function installedChromeKey() {
|
|
30
|
+
if (process.env.CDPM_TEST_INSTALLED_VERSION)
|
|
31
|
+
return `test|${process.env.CDPM_TEST_INSTALLED_VERSION}`;
|
|
32
|
+
try {
|
|
33
|
+
const exe = findChrome();
|
|
34
|
+
const st = fs.statSync(exe, { bigint: true });
|
|
35
|
+
return `${exe}|${st.ino}|${st.size}|${st.mtimeMs}`;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 설치된 Chrome 버전. 실행 파일이 바뀔 때만 다시 읽는다. 바꿔치기는 이름만 바꾸는 것이라 수정 시각이 그대로일 수 있어서
|
|
43
|
+
* 파일 번호(ino)·크기까지 함께 본다. 알 수 없으면 undefined (그때는 비교하지 않는다).
|
|
44
|
+
*/
|
|
45
|
+
export function installedChromeVersion() {
|
|
46
|
+
if (process.env.CDPM_TEST_INSTALLED_VERSION)
|
|
47
|
+
return process.env.CDPM_TEST_INSTALLED_VERSION; // 시험용
|
|
48
|
+
try {
|
|
49
|
+
const exe = findChrome();
|
|
50
|
+
const key = installedChromeKey();
|
|
51
|
+
if (!key)
|
|
52
|
+
return undefined;
|
|
53
|
+
if (cache?.key === key)
|
|
54
|
+
return cache.version;
|
|
55
|
+
let version;
|
|
56
|
+
if (process.platform === 'win32')
|
|
57
|
+
version = peProductVersion(fs.readFileSync(exe));
|
|
58
|
+
else if (process.platform === 'darwin') {
|
|
59
|
+
const plist = fs.readFileSync(path.join(path.dirname(exe), '..', 'Info.plist'), 'utf8');
|
|
60
|
+
version = /<key>CFBundleShortVersionString<\/key>\s*<string>([\d.]+)<\/string>/.exec(plist)?.[1];
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const out = execFileSync(exe, ['--version'], { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
|
|
64
|
+
version = /(\d+(?:\.\d+){1,3})/.exec(out)?.[1];
|
|
65
|
+
}
|
|
66
|
+
cache = { key, version };
|
|
67
|
+
return version;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** /json/version의 Browser 값("Chrome/154.0.8037.98", "HeadlessChrome/...")에서 버전만 */
|
|
74
|
+
export function runningVersion(browser) {
|
|
75
|
+
return /\/(\d+(?:\.\d+){1,3})/.exec(browser ?? '')?.[1];
|
|
76
|
+
}
|
package/dist/service.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// 슬롯 실행 보장, 탭 목록과 기록부 맞추기, 행동 기록.
|
|
2
2
|
import { launchChrome } from './chrome/launcher.js';
|
|
3
3
|
import { describeProxy } from './chrome/proxy.js';
|
|
4
|
+
import { installedChromeKey, installedChromeVersion, runningVersion } from './chrome/version.js';
|
|
4
5
|
import { browserConnection, dropSlotConnections, hasLiveBrowserConnection, pageSession } from './cdp/sessions.js';
|
|
5
6
|
import { listPages, probe } from './cdp/targets.js';
|
|
6
7
|
import { CdpmError } from './errors.js';
|
|
@@ -42,7 +43,7 @@ async function probeSure(slot) {
|
|
|
42
43
|
}
|
|
43
44
|
return p;
|
|
44
45
|
}
|
|
45
|
-
export async function attachSlot(slot) {
|
|
46
|
+
export async function attachSlot(slot, opts = {}) {
|
|
46
47
|
// 빠른 길: 이 프로세스의 연결이 살아 있고 기록된 Chrome도 살아 있으면 포트에 다시 묻지 않는다.
|
|
47
48
|
const known = readRegistry().slots[String(slot)];
|
|
48
49
|
// 기록된 번호는 이 프로세스가 확인한 것일 때만 믿는다 (다른 세션이 다시 켰거나 재부팅 뒤 옛 번호일 수 있음)
|
|
@@ -81,7 +82,10 @@ export async function attachSlot(slot) {
|
|
|
81
82
|
confirmedPid.set(slot, actual);
|
|
82
83
|
applyTaskbar(slot, pid);
|
|
83
84
|
if (DOCK_SUPPORTED && !rec?.headless)
|
|
84
|
-
void applyDock(slot, pid);
|
|
85
|
+
void applyDock(slot, pid);
|
|
86
|
+
// 실행 중에 Chrome이 업데이트됐으면(새 탭이 안 열림) 새 버전으로 다시 켠다
|
|
87
|
+
if (!opts.inLock && p.state === 'chrome')
|
|
88
|
+
await restartIfUpdated(slot, p.version.Browser); // macOS만
|
|
85
89
|
}
|
|
86
90
|
function portBusy(slot, detail) {
|
|
87
91
|
return new CdpmError(`Slot ${slot} port ${portOf(slot)} is used by a non-Chrome program (${detail}). Close it or use another slot.`);
|
|
@@ -96,7 +100,7 @@ async function launchSlotLocked(slot, agent, opts) {
|
|
|
96
100
|
if (p.state === 'other')
|
|
97
101
|
throw portBusy(slot, p.detail);
|
|
98
102
|
if (p.state === 'chrome') {
|
|
99
|
-
await attachSlot(slot);
|
|
103
|
+
await attachSlot(slot, { inLock: true });
|
|
100
104
|
return { launched: false };
|
|
101
105
|
}
|
|
102
106
|
// 방금 끈 Chrome은 포트를 닫은 뒤에도 잠깐 살아서 프로필을 붙잡고 있다. 그때 새로 켜면 새 Chrome이
|
|
@@ -138,6 +142,114 @@ export async function freeSlots(n) {
|
|
|
138
142
|
export async function firstFreeSlot() {
|
|
139
143
|
return (await freeSlots(1))[0];
|
|
140
144
|
}
|
|
145
|
+
/** 실행 중 업데이트로 다시 켠 버전 쌍 (슬롯 → "옛>새"). 다시 켜도 버전이 안 맞으면 같은 쌍으로 또 켜지 않는다 (무한 반복 방지) */
|
|
146
|
+
const updateRestarted = new Map();
|
|
147
|
+
/** 슬롯 Chrome(/json/version의 Browser)이 디스크에 설치된 Chrome과 버전이 다르면 두 버전. 알 수 없으면 undefined */
|
|
148
|
+
export function staleVersion(browser) {
|
|
149
|
+
const running = runningVersion(browser);
|
|
150
|
+
const installed = installedChromeVersion();
|
|
151
|
+
return running && installed && running !== installed ? { running, installed } : undefined;
|
|
152
|
+
}
|
|
153
|
+
const isBlankUrl = (u) => !u || u === 'about:blank' || /^chrome:\/\/(newtab|new-tab-page)\/?$/.test(u) || u.startsWith('chrome-search://');
|
|
154
|
+
async function setNotice(slot, text) {
|
|
155
|
+
await updateRegistry((r) => {
|
|
156
|
+
const s = r.slots[String(slot)];
|
|
157
|
+
if (s)
|
|
158
|
+
s.notice = { text, at: nowIso() };
|
|
159
|
+
}).catch(() => undefined);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 슬롯 Chrome이 실행 중에 업데이트됐으면(디스크의 Chrome과 버전이 다름) 새 버전으로 다시 켠다. 옛 버전 본체는 바뀐
|
|
163
|
+
* 실행 파일로 렌더러를 띄우지 못해 새 탭·다른 사이트로 넘어간 탭이 빈 채로 멈추기 때문이다. 열려 있던 탭 주소를 순서대로
|
|
164
|
+
* 다시 열고, 창 모드·헤드리스는 그대로 둔다 (로그인은 프로필에 남음). 프록시 슬롯은 접속 정보가 기록에 없어 다시 켜지
|
|
165
|
+
* 않고 알리기만 한다. 다시 켰으면 true.
|
|
166
|
+
*/
|
|
167
|
+
export async function restartIfUpdated(slot, browser) {
|
|
168
|
+
const first = staleVersion(browser);
|
|
169
|
+
if (!first)
|
|
170
|
+
return false;
|
|
171
|
+
const pair = `${first.running}>${first.installed}`;
|
|
172
|
+
if (updateRestarted.get(slot) === pair)
|
|
173
|
+
return false;
|
|
174
|
+
updateRestarted.set(slot, pair);
|
|
175
|
+
return withSlotLock(slot, async () => {
|
|
176
|
+
// 잠금을 기다리는 동안 다른 세션이 이미 다시 켰을 수 있다
|
|
177
|
+
const p = await probe(slot, 1500);
|
|
178
|
+
const stale = p.state === 'chrome' ? staleVersion(p.version.Browser) : undefined;
|
|
179
|
+
if (!stale)
|
|
180
|
+
return false;
|
|
181
|
+
const rec = readRegistry().slots[String(slot)];
|
|
182
|
+
const from = `${stale.running} → ${stale.installed}`;
|
|
183
|
+
if (rec?.proxy) {
|
|
184
|
+
await setNotice(slot, `Slot ${slot} Chrome was updated while running (${from}), so new tabs and cross-site navigations may hang. It uses a proxy, so CDPM did not restart it: ask the user to restart it (browser_close, then browser_launch with the same proxy).`);
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
const tabs = await syncTabs(slot).catch(() => []);
|
|
188
|
+
const urls = tabs.map((t) => t.url).filter((u) => !isBlankUrl(u));
|
|
189
|
+
const browserConn = await browserConnection(slot);
|
|
190
|
+
await browserConn.send('Browser.close', {}, 5000).catch(() => undefined);
|
|
191
|
+
for (let i = 0; i < 25 && (await probe(slot, 500)).state === 'chrome'; i++)
|
|
192
|
+
await sleep(200);
|
|
193
|
+
// 포트가 닫혀도 프로세스는 잠깐 더 살아 프로필을 붙잡는다. 끝날 때까지 기다려야 다시 켤 수 있다.
|
|
194
|
+
for (let i = 0; rec?.pid && i < 50 && pidAlive(rec.pid); i++)
|
|
195
|
+
await sleep(100);
|
|
196
|
+
await forgetSlot(slot);
|
|
197
|
+
const launched = await launchChrome(slot, { headless: rec?.headless, url: urls[0] });
|
|
198
|
+
const pid = launched.pid ?? (await browserPid(slot));
|
|
199
|
+
if (pid)
|
|
200
|
+
confirmedPid.set(slot, pid);
|
|
201
|
+
const text = `Slot ${slot} Chrome had been updated while running (${from}), so new tabs could not load. CDPM restarted it on the new version` +
|
|
202
|
+
`${urls.length ? ` and reopened ${urls.length} tab(s)` : ''}. Logins are kept, but tab IDs changed and unsaved page input was lost.`;
|
|
203
|
+
await updateRegistry((r) => {
|
|
204
|
+
r.slots[String(slot)] = {
|
|
205
|
+
...newSlotRecord(rec?.launchedBy ?? EXTERNAL, nowIso(), pid),
|
|
206
|
+
...(rec?.headless ? { headless: true } : {}),
|
|
207
|
+
notice: { text, at: nowIso() },
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
const conn = await browserConnection(slot).catch(() => undefined);
|
|
211
|
+
for (const u of urls.slice(1))
|
|
212
|
+
await conn?.send('Target.createTarget', { url: u, background: true }).catch(() => undefined);
|
|
213
|
+
await syncTabs(slot).catch(() => undefined);
|
|
214
|
+
for (let i = 0; !rec?.headless && i < 50; i++) {
|
|
215
|
+
if (applyTaskbar(slot, pid) > 0)
|
|
216
|
+
break;
|
|
217
|
+
await sleep(100);
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* 슬롯 감시: 10초마다 설치된 chrome.exe가 바뀌었는지만 본다 (파일 정보만, 슬롯에는 묻지 않음).
|
|
224
|
+
* 바뀌었을 때(그리고 이 CDPM이 처음 확인할 때 한 번)만 슬롯마다 버전을 물어 비교하고, 다르면 다시 켠다.
|
|
225
|
+
* 업데이트는 슬롯이 켜져 있는 동안에도 일어난다 (평소 쓰는 Chrome을 껐다 켜는 순간 같은 chrome.exe가 바뀜).
|
|
226
|
+
*/
|
|
227
|
+
let lastInstalledKey;
|
|
228
|
+
let lastUpdateCheck = 0;
|
|
229
|
+
export async function checkUpdatedChrome() {
|
|
230
|
+
if (Date.now() - lastUpdateCheck < 10_000)
|
|
231
|
+
return [];
|
|
232
|
+
lastUpdateCheck = Date.now();
|
|
233
|
+
const key = installedChromeKey();
|
|
234
|
+
if (!key || key === lastInstalledKey)
|
|
235
|
+
return [];
|
|
236
|
+
const restarted = [];
|
|
237
|
+
let unsure = false;
|
|
238
|
+
for (const s of Object.keys(readRegistry().slots)) {
|
|
239
|
+
const slot = Number(s);
|
|
240
|
+
const p = await probe(slot, 1500);
|
|
241
|
+
if (p.state === 'slow')
|
|
242
|
+
unsure = true; // 바쁜 슬롯은 다음 확인 때 다시
|
|
243
|
+
if (p.state !== 'chrome' || !staleVersion(p.version.Browser))
|
|
244
|
+
continue;
|
|
245
|
+
if (await restartIfUpdated(slot, p.version.Browser).catch(() => false))
|
|
246
|
+
restarted.push(slot);
|
|
247
|
+
}
|
|
248
|
+
// 모든 슬롯을 확인했으면 이 실행 파일은 끝. 응답이 늦은 슬롯이 있었으면 다음 주기에 다시 비교한다
|
|
249
|
+
if (!unsure)
|
|
250
|
+
lastInstalledKey = key;
|
|
251
|
+
return restarted;
|
|
252
|
+
}
|
|
141
253
|
/**
|
|
142
254
|
* 기록부의 Chrome 번호가 지금 포트의 Chrome 본체와 같은지 확인하고, 다르면 고친다. 확인한 번호를 돌려준다.
|
|
143
255
|
* 포트가 비어 있거나(Chrome 꺼짐) 확인할 수 없으면 undefined (기록은 그대로).
|
|
@@ -350,7 +462,9 @@ export function startSlotWatcher(intervalMs = 2000) {
|
|
|
350
462
|
if (busy)
|
|
351
463
|
return;
|
|
352
464
|
busy = true;
|
|
353
|
-
checkClosedWindows().catch(() => undefined)
|
|
465
|
+
checkClosedWindows().catch(() => undefined)
|
|
466
|
+
.then(() => checkUpdatedChrome().catch(() => undefined))
|
|
467
|
+
.finally(() => (busy = false));
|
|
354
468
|
}, intervalMs);
|
|
355
469
|
slotWatcher.unref();
|
|
356
470
|
}
|
package/dist/tools/register.js
CHANGED
|
@@ -93,10 +93,23 @@ onAgentForgotten((agent) => {
|
|
|
93
93
|
if (k.endsWith(`:${agent}`))
|
|
94
94
|
m.delete(k);
|
|
95
95
|
});
|
|
96
|
+
/** 이미 보여준 슬롯 알림 (슬롯:에이전트:시각) */
|
|
97
|
+
const shownNotices = new Set();
|
|
96
98
|
async function header(slot, agent, tabs, opts = {}) {
|
|
97
99
|
touchAgent(agent);
|
|
98
100
|
const messages = opts.skipMessages ? [] : await takeUnread(slot, agent).catch(() => []);
|
|
99
101
|
const warnings = [...(opts.warnings ?? [])];
|
|
102
|
+
// 슬롯 알림(업데이트 때문에 다시 켬 등)은 에이전트마다 한 번 (10분 안)
|
|
103
|
+
const notice = readRegistry().slots[String(slot)]?.notice;
|
|
104
|
+
if (notice && secondsSince(notice.at) < 600) {
|
|
105
|
+
const k = `${slot}:${agent}:${notice.at}`;
|
|
106
|
+
if (!shownNotices.has(k)) {
|
|
107
|
+
if (shownNotices.size > 500)
|
|
108
|
+
shownNotices.clear();
|
|
109
|
+
shownNotices.add(k);
|
|
110
|
+
warnings.push(notice.text);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
100
113
|
for (const t of tabs) {
|
|
101
114
|
const blocks = liveBlocks(t);
|
|
102
115
|
if (blocks.length)
|
package/package.json
CHANGED