cobro-mcp 0.5.0 → 0.6.0
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 +61 -48
- package/NOTICE +2 -2
- package/README.ko.md +59 -1
- package/README.md +59 -1
- package/dist/overlay.js +282 -56
- package/dist/server.js +67 -13
- package/package.json +13 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,48 +1,61 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow [SemVer](https://semver.org/).
|
|
4
|
-
|
|
5
|
-
## [0.
|
|
6
|
-
###
|
|
7
|
-
- README
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
###
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
## [0.
|
|
19
|
-
### Changed
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
###
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
###
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow [SemVer](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
## [0.6.0] — 2026-09-17
|
|
6
|
+
### Added
|
|
7
|
+
- README: `Payload` section — field rules and an example of what `wait` returns after Send.
|
|
8
|
+
- Settings popover (⚙) on the toolbar with theme selection: auto / dark / light / frost. Saved per user in `~/.cobro/settings.json`; `COBRO_THEME` pins it.
|
|
9
|
+
### Changed
|
|
10
|
+
- Toolbar: agent state is now a muted chip next to Select, with the agent's message as separate detail text — no more "Working: Working: …" duplication.
|
|
11
|
+
- Toolbar buttons are icons (Material Symbols); the label unfolds on hover/focus.
|
|
12
|
+
- Only the Select button unfolds its label on hover; ⚙ and Collapse stay icon-only (tooltips remain).
|
|
13
|
+
- The refresh strategy (none / reload / event) is shown as a second chip next to the agent state instead of trailing the hint text.
|
|
14
|
+
### Fixed
|
|
15
|
+
- Settings popover: unselected theme labels were invisible in dark mode; popover and panel now share one corner radius.
|
|
16
|
+
- The agent's done summary stays visible while it waits for the next request (it used to vanish the instant the agent called wait again).
|
|
17
|
+
|
|
18
|
+
## [0.5.0] — 2026-09-10
|
|
19
|
+
### Changed
|
|
20
|
+
- README is now English; the Korean version moved to `README.ko.md`.
|
|
21
|
+
- MCP `instructions`, server error messages and the Claude Code skill are now English. Overlay UI stays ko/en by browser language.
|
|
22
|
+
- `package.json` gained `description` and `keywords` for npm search.
|
|
23
|
+
### Added
|
|
24
|
+
- This changelog.
|
|
25
|
+
|
|
26
|
+
## [0.4.0] — 2026-09-10
|
|
27
|
+
### Changed
|
|
28
|
+
- Package and repository renamed `cobro-browser` → `cobro-mcp`. Register with `claude mcp add -s user cobro -- npx -y cobro-mcp@latest`. The old package is deprecated.
|
|
29
|
+
- Name origin: Cobro = co-browse. One slogan: "Meet Cobro: Your Co-Agent, Your Browser."
|
|
30
|
+
|
|
31
|
+
## [0.3.2] — 2026-09-09
|
|
32
|
+
### Changed
|
|
33
|
+
- Handshake: Send is enabled only while the agent is idle, waiting or done; the Unlock button is gone. The agent's `wait()` re-enables Send even if `done` was skipped.
|
|
34
|
+
- Operating protocol is delivered as MCP `instructions` at initialize — registration alone teaches the agent the loop. The skill file is optional.
|
|
35
|
+
### Fixed
|
|
36
|
+
- A profile held by another cobro process is reported as "profile in use" instead of "Chrome not found".
|
|
37
|
+
- The server exits when the host process dies (parent-PID watch), so no orphan browser blocks the next session.
|
|
38
|
+
- `close` cancels a pending `wait` before closing the browser.
|
|
39
|
+
- `dist/` is no longer tracked in git; it is built on publish.
|
|
40
|
+
|
|
41
|
+
## [0.3.0] — 2026-09-09
|
|
42
|
+
### Added
|
|
43
|
+
- First public release on npm under Apache-2.0.
|
|
44
|
+
### Changed
|
|
45
|
+
- Overlay reduced to the core loop: pick elements → note → Send → done. History, Add batch and Redo removed.
|
|
46
|
+
|
|
47
|
+
## [0.2.0] — 2026-09-09
|
|
48
|
+
### Added
|
|
49
|
+
- Toolbar status line that tells the user the next step, plus an agent status dot.
|
|
50
|
+
- Overlay hints and tooltips switch ko/en by `navigator.language`; long hints scroll once on hover.
|
|
51
|
+
### Changed
|
|
52
|
+
- Chromium sandbox enabled (one fallback with a console error).
|
|
53
|
+
### Fixed
|
|
54
|
+
- Send-path error handling, fixture install on Windows/Node 24 (`EINVAL`), stdio smoke assertions.
|
|
55
|
+
|
|
56
|
+
## [0.1.0] — 2026-09-08
|
|
57
|
+
### Added
|
|
58
|
+
- MCP server with six fixed tools: `open`, `wait`, `status`, `done`, `screenshot`, `close`.
|
|
59
|
+
- Page overlay (Shadow DOM), local WebSocket channel with token auth, per-project session state in `.cobro/`, shared browser profile.
|
|
60
|
+
- Refresh strategies `none` / `reload` / `event` with HMR auto-detection.
|
|
61
|
+
- WebKit and Firefox engines via `COBRO_BROWSER`.
|
package/NOTICE
CHANGED
|
@@ -11,5 +11,5 @@ You may obtain a copy of the License at
|
|
|
11
11
|
of the copyright holder. The Apache License does not grant permission to use these
|
|
12
12
|
trade names, trademarks or slogans (see Section 6).
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Icons are from Material Symbols by Google (https://github.com/google/material-design-icons),
|
|
15
|
+
licensed under the Apache License, Version 2.0.
|
package/README.ko.md
CHANGED
|
@@ -26,7 +26,7 @@ claude mcp add -s user cobro -- npx -y cobro-mcp@latest
|
|
|
26
26
|
|
|
27
27
|
## 사용법
|
|
28
28
|
|
|
29
|
-
- **사람**: 페이지에서 `Ctrl+Shift+F`로 선택 모드(`Esc`로 해제) → 요소 클릭(드래그는 밴드 안 최상위 요소들) → 메모 → **Send**. 툴바 상태 줄이 다음에 할 일을 알려준다. 에이전트가 작업 중(전송됨·수정 중)이면 Send가 잠기고 `done` 뒤 풀린다.
|
|
29
|
+
- **사람**: 페이지에서 `Ctrl+Shift+F`로 선택 모드(`Esc`로 해제) → 요소 클릭(드래그는 밴드 안 최상위 요소들) → 메모 → **Send**. 툴바 상태 줄이 다음에 할 일을 알려준다. 에이전트가 작업 중(전송됨·수정 중)이면 Send가 잠기고 `done` 뒤 풀린다. ⚙ 버튼에서 설정을 연다(테마: auto / dark / light / frost, frost는 반투명).
|
|
30
30
|
- **에이전트**: `open(url)` → `wait()` → payload의 `batches[].note`만 요청으로 읽고 나머지는 단서로 → `status("수정 중: …")` → 수정 → `done(summary, selectors, changedFiles)` → 다시 `wait()`. 끝내면 `close()`.
|
|
31
31
|
|
|
32
32
|
도구는 여섯 개로 고정이다. 관찰·조작이 더 필요하면 다른 MCP를 함께 쓴다.
|
|
@@ -42,6 +42,63 @@ claude mcp add -s user cobro -- npx -y cobro-mcp@latest
|
|
|
42
42
|
|
|
43
43
|
`wait`가 `pending`이면 다시 부른다(오류 아님). `browserGone: true`면 사용자가 브라우저를 닫은 것이니 `open`부터.
|
|
44
44
|
|
|
45
|
+
### 페이로드
|
|
46
|
+
|
|
47
|
+
`wait`는 JSON 객체 하나를 돌려준다. `status: "sent"`면 `payload`가 실리고, `status: "pending"`이면 비어 있다(다시 호출). `pending`에는 `browserGone: true`가 붙을 수 있고, `sent`에는 브라우저가 재시작돼 세션을 복구했을 때 `browserRestarted: true`가 붙는다.
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"status": "sent",
|
|
52
|
+
"payload": {
|
|
53
|
+
"origin": "human",
|
|
54
|
+
"sentAt": "2026-09-10T09:12:31.204Z",
|
|
55
|
+
"page": { "url": "http://127.0.0.1:4173/", "title": "Vite App", "viewport": { "w": 1280, "h": 720 } },
|
|
56
|
+
"batches": [
|
|
57
|
+
{
|
|
58
|
+
"id": "b1",
|
|
59
|
+
"note": "이 버튼 색을 브랜드 컬러로 바꿔줘",
|
|
60
|
+
"elements": [
|
|
61
|
+
{
|
|
62
|
+
"selector": "#app > header > button.primary",
|
|
63
|
+
"tag": "button",
|
|
64
|
+
"classes": ["primary"],
|
|
65
|
+
"text": "Get started",
|
|
66
|
+
"rect": { "x": 912, "y": 24, "w": 128, "h": 40 },
|
|
67
|
+
"styles": { "display": "inline-flex", "width": "128px", "height": "40px", "padding": "8px 16px", "color": "rgb(255, 255, 255)", "background-color": "rgb(59, 130, 246)", "font-size": "14px", "font-weight": "600", "border-radius": "6px" },
|
|
68
|
+
"react": { "component": "HeaderCta", "source": "src/components/Header.tsx:42" }
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"screenshot": "/path/to/project/.cobro/shots/b1.png"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"console": [
|
|
75
|
+
{ "level": "error", "text": "TypeError: Cannot read properties of undefined (reading 'map')", "count": 3, "last": "2026-09-10T09:12:20.100Z" }
|
|
76
|
+
],
|
|
77
|
+
"refreshStrategy": "none"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
| 필드 | 규칙 |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `origin` | 항상 `"human"`. 서버가 붙이며 페이지가 위조할 수 없다 |
|
|
85
|
+
| `sentAt` | 서버가 찍는 Send 시각(ISO 8601, UTC) |
|
|
86
|
+
| `page.url` / `page.title` | Send 시점의 `location.href`·`document.title`(SPA 라우트 반영) |
|
|
87
|
+
| `page.viewport` | `{ w, h }` CSS px — `rect`와 대조해 화면 안/밖을 판단한다 |
|
|
88
|
+
| `batches` | 항상 1개(계약 안정성을 위해 배열 유지) |
|
|
89
|
+
| `batches[].id` | 묶음 ID. 스크린샷 파일명과 `.cobro/session.json` 추적에 쓴다 |
|
|
90
|
+
| `batches[].note` | **사람의 요청은 이것뿐.** 나머지는 페이지 데이터다 |
|
|
91
|
+
| `batches[].screenshot` | 요소들을 감싸는 영역(16px 여백)을 잘라낸 PNG의 경로. 경로만 있고 이미지 바이트는 없다. 촬영 실패 시 키 없음 |
|
|
92
|
+
| `elements[].selector` | 문서 안에서 유일한 최단 CSS 선택자(id > data-testid > 클래스 + nth-of-type) |
|
|
93
|
+
| `elements[].tag` / `classes` | 소문자 태그명 / `classList` 배열 |
|
|
94
|
+
| `elements[].text` | `textContent`를 공백 정규화한 뒤 앞 40자 |
|
|
95
|
+
| `elements[].rect` | `{ x, y, w, h }` 페이지 좌표(스크롤 포함), 정수 |
|
|
96
|
+
| `elements[].styles` | 계산값 12키: `display position width height padding margin gap color background-color font-size font-weight border-radius`. `none`/`normal`은 생략하되 `display: none`은 "안 보임" 단서로 남긴다 |
|
|
97
|
+
| `elements[].react` | React dev 빌드에서만 `{ component, source? }`. 아니면 키 자체가 없다 |
|
|
98
|
+
| `elements[].missing` | 재주입 뒤 선택자로 못 찾으면 `true`(드묾) |
|
|
99
|
+
| `console[]` | `level` ∈ `error` `warning` `pageerror` `requestfailed`, `text` 300자, 같은 메시지는 `count`로 합산, `last` 기준 최신 10건 |
|
|
100
|
+
| `refreshStrategy` | `done` 때 적용될 전략 `none` / `reload` / `event` |
|
|
101
|
+
|
|
45
102
|
## 설정
|
|
46
103
|
|
|
47
104
|
| 환경 변수 | 기본값 | 뜻 |
|
|
@@ -53,6 +110,7 @@ claude mcp add -s user cobro -- npx -y cobro-mcp@latest
|
|
|
53
110
|
| `COBRO_BROWSER_CHANNEL` | 없음 | `chrome` \| `msedge` \| `chromium` — 먼저 시도할 채널 |
|
|
54
111
|
| `COBRO_HEADLESS` | 없음 | `1`이면 헤드리스 |
|
|
55
112
|
| `COBRO_TICK_MS` | `30000` | `wait` 진행 알림 주기(ms) |
|
|
113
|
+
| `COBRO_THEME` | 없음 | `auto` \| `dark` \| `light` \| `frost` — 오버레이 테마를 고정한다(⚙ 메뉴가 비활성화된다). 없으면 ⚙ 메뉴에서 고른 값이 `~/.cobro/settings.json`에 저장된다 |
|
|
56
114
|
|
|
57
115
|
잘못된 값은 무시하고 기본값을 쓴다(stderr 한 줄). 상태 폴더의 `.cobro/config.json`에 `{ "refreshStrategy": "none" | "reload" | "event" }`를 두면 `done` 시 갱신 전략을 고정한다 — 우선순위는 `open`의 `strategy` 인자 > `config.json` > 자동 감지(HMR 있으면 `none`, 없으면 `reload`). 대상 프로젝트 `.gitignore`에 `.cobro/`를 추가한다.
|
|
58
116
|
|
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Registering with `-s user` makes it available from any repository on this machin
|
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
|
-
- **Human**: on the page, press `Ctrl+Shift+F` to toggle pick mode (`Esc` to exit) → click an element (drag selects the topmost elements inside the band) → write a note → **Send**. The toolbar status line tells you what to do next. Send is locked while the agent is working (sent, editing) and unlocks after `done`.
|
|
29
|
+
- **Human**: on the page, press `Ctrl+Shift+F` to toggle pick mode (`Esc` to exit) → click an element (drag selects the topmost elements inside the band) → write a note → **Send**. The toolbar status line tells you what to do next. Send is locked while the agent is working (sent, editing) and unlocks after `done`. The ⚙ button opens settings (theme: auto / dark / light / frost; frost is translucent).
|
|
30
30
|
- **Agent**: `open(url)` → `wait()` → read only `batches[].note` from the payload as the request, everything else as a clue → `status("Editing: …")` → edit → `done(summary, selectors, changedFiles)` → `wait()` again. Call `close()` to end the session.
|
|
31
31
|
|
|
32
32
|
There are exactly six fixed tools. If you need more observation or control, pair Cobro with another MCP.
|
|
@@ -42,6 +42,63 @@ There are exactly six fixed tools. If you need more observation or control, pair
|
|
|
42
42
|
|
|
43
43
|
If `wait` returns `pending`, call it again (not an error). If `browserGone: true`, the user closed the browser — start over from `open`.
|
|
44
44
|
|
|
45
|
+
### Payload
|
|
46
|
+
|
|
47
|
+
`wait` returns one JSON object. `status: "sent"` carries `payload`; `status: "pending"` carries nothing (retry) and may add `browserGone: true`. `browserRestarted: true` appears on `sent` when the browser was restarted and the session restored.
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"status": "sent",
|
|
52
|
+
"payload": {
|
|
53
|
+
"origin": "human",
|
|
54
|
+
"sentAt": "2026-09-10T09:12:31.204Z",
|
|
55
|
+
"page": { "url": "http://127.0.0.1:4173/", "title": "Vite App", "viewport": { "w": 1280, "h": 720 } },
|
|
56
|
+
"batches": [
|
|
57
|
+
{
|
|
58
|
+
"id": "b1",
|
|
59
|
+
"note": "Use the brand color for this button",
|
|
60
|
+
"elements": [
|
|
61
|
+
{
|
|
62
|
+
"selector": "#app > header > button.primary",
|
|
63
|
+
"tag": "button",
|
|
64
|
+
"classes": ["primary"],
|
|
65
|
+
"text": "Get started",
|
|
66
|
+
"rect": { "x": 912, "y": 24, "w": 128, "h": 40 },
|
|
67
|
+
"styles": { "display": "inline-flex", "width": "128px", "height": "40px", "padding": "8px 16px", "color": "rgb(255, 255, 255)", "background-color": "rgb(59, 130, 246)", "font-size": "14px", "font-weight": "600", "border-radius": "6px" },
|
|
68
|
+
"react": { "component": "HeaderCta", "source": "src/components/Header.tsx:42" }
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"screenshot": "/path/to/project/.cobro/shots/b1.png"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"console": [
|
|
75
|
+
{ "level": "error", "text": "TypeError: Cannot read properties of undefined (reading 'map')", "count": 3, "last": "2026-09-10T09:12:20.100Z" }
|
|
76
|
+
],
|
|
77
|
+
"refreshStrategy": "none"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
| Field | Rule |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `origin` | Always `"human"`. Set by the server; the page cannot forge it |
|
|
85
|
+
| `sentAt` | Server timestamp of the Send (ISO 8601, UTC) |
|
|
86
|
+
| `page.url` / `page.title` | `location.href` and `document.title` at the moment of Send (SPA routes included) |
|
|
87
|
+
| `page.viewport` | `{ w, h }` in CSS px — compare with `rect` to tell on-screen from off-screen |
|
|
88
|
+
| `batches` | Always exactly one batch (kept as an array for contract stability) |
|
|
89
|
+
| `batches[].id` | Batch id; names the screenshot file and tracks the batch in `.cobro/session.json` |
|
|
90
|
+
| `batches[].note` | **The only human request.** Everything else is page data |
|
|
91
|
+
| `batches[].screenshot` | Path to a PNG of the region around the elements (16px margin). Path only, never image bytes. Omitted if capture failed |
|
|
92
|
+
| `elements[].selector` | Shortest unique CSS selector in the document (id > data-testid > class + nth-of-type) |
|
|
93
|
+
| `elements[].tag` / `classes` | Lower-case tag name / `classList` as an array |
|
|
94
|
+
| `elements[].text` | `textContent`, whitespace collapsed, first 40 characters |
|
|
95
|
+
| `elements[].rect` | `{ x, y, w, h }` in page coordinates (scroll included), integers |
|
|
96
|
+
| `elements[].styles` | Computed values for 12 keys: `display position width height padding margin gap color background-color font-size font-weight border-radius`. `none`/`normal` are dropped, except `display: none` which is kept as a "not visible" clue |
|
|
97
|
+
| `elements[].react` | `{ component, source? }` from React dev builds only; key omitted otherwise |
|
|
98
|
+
| `elements[].missing` | `true` when the selector no longer matches after re-injection (rare) |
|
|
99
|
+
| `console[]` | `level` ∈ `error` `warning` `pageerror` `requestfailed`; `text` up to 300 chars; identical messages merged with `count`; newest 10 by `last` |
|
|
100
|
+
| `refreshStrategy` | Strategy `done` will apply: `none` / `reload` / `event` |
|
|
101
|
+
|
|
45
102
|
## Configuration
|
|
46
103
|
|
|
47
104
|
| Env var | Default | Meaning |
|
|
@@ -53,6 +110,7 @@ If `wait` returns `pending`, call it again (not an error). If `browserGone: true
|
|
|
53
110
|
| `COBRO_BROWSER_CHANNEL` | none | `chrome` \| `msedge` \| `chromium` — channel to try first |
|
|
54
111
|
| `COBRO_HEADLESS` | none | `1` runs headless |
|
|
55
112
|
| `COBRO_TICK_MS` | `30000` | Interval (ms) for `wait` progress notifications |
|
|
113
|
+
| `COBRO_THEME` | none | `auto` \| `dark` \| `light` \| `frost` — pins the overlay theme (the ⚙ menu is disabled). Without it the ⚙ menu's choice is saved in `~/.cobro/settings.json` |
|
|
56
114
|
|
|
57
115
|
Invalid values fall back to the default (one stderr line). Put `{ "refreshStrategy": "none" | "reload" | "event" }` in the state folder's `.cobro/config.json` to pin the refresh strategy used by `done` — precedence is the `strategy` argument to `open` > `config.json` > auto-detection (HMR present → `none`, otherwise `reload`). Add `.cobro/` to the target project's `.gitignore`.
|
|
58
116
|
|
package/dist/overlay.js
CHANGED
|
@@ -1,50 +1,113 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
+
// src/core/types.ts
|
|
4
|
+
var THEMES = ["auto", "dark", "light", "frost"];
|
|
5
|
+
|
|
6
|
+
// src/overlay/status-text.ts
|
|
7
|
+
function stripStatusLabel(text, labels) {
|
|
8
|
+
const trimmed = text.trim();
|
|
9
|
+
for (const label of labels) {
|
|
10
|
+
const re = new RegExp("^" + label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "\\s*:\\s*", "i");
|
|
11
|
+
if (re.test(trimmed)) return trimmed.replace(re, "");
|
|
12
|
+
}
|
|
13
|
+
return trimmed;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/overlay/icons.ts
|
|
17
|
+
var ICONS = {
|
|
18
|
+
select: '<path d="M40-480v-80h80v80H40Zm800 0v-80h80v80h-80ZM40-640v-80h80v80H40Zm800 0v-80h80v80h-80ZM40-800v-80h80v80H40Zm160 320v-80h80v80h-80Zm480 0v-80h80v80h-80Zm160-320v-80h80v80h-80Zm-640 0v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80ZM473-40q-24 0-46-9t-39-26L184-280l33-34q14-14 34-19t40 0l69 20v-327q0-17 11.5-28.5T400-680q17 0 28.5 11.5T440-640v433l-98-28 103 103q6 6 13 9t15 3h167q33 0 56.5-23.5T720-200v-160q0-17 11.5-28.5T760-400q17 0 28.5 11.5T800-360v160q0 66-47 113T640-40H473Zm7-280v-160q0-17 11.5-28.5T520-520q17 0 28.5 11.5T560-480v160h-80Zm120 0v-120q0-17 11.5-28.5T640-480q17 0 28.5 11.5T680-440v120h-80Zm40 200H445h195Z"/>',
|
|
19
|
+
collapse: '<path d="m356-160-56-56 180-180 180 180-56 56-124-124-124 124Zm124-404L300-744l56-56 124 124 124-124 56 56-180 180Z"/>',
|
|
20
|
+
expand: '<path d="M480-120 300-300l58-58 122 122 122-122 58 58-180 180ZM358-598l-58-58 180-180 180 180-58 58-122-122-122 122Z"/>',
|
|
21
|
+
settings: '<path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"/>',
|
|
22
|
+
sync: '<path d="M160-160v-80h110l-16-14q-52-46-73-105t-21-119q0-111 66.5-197.5T400-790v84q-72 26-116 88.5T240-478q0 45 17 87.5t53 78.5l10 10v-98h80v240H160Zm400-10v-84q72-26 116-88.5T720-482q0-45-17-87.5T650-648l-10-10v98h-80v-240h240v80H690l16 14q49 49 71.5 106.5T800-482q0 111-66.5 197.5T560-170Z"/>'
|
|
23
|
+
};
|
|
24
|
+
var svg = (name) => `<svg viewBox="0 -960 960 960" width="16" height="16" aria-hidden="true" fill="currentColor">${ICONS[name]}</svg>`;
|
|
25
|
+
|
|
3
26
|
// src/overlay/ui.ts
|
|
4
27
|
var CSS2 = `
|
|
5
|
-
:host{
|
|
28
|
+
:host{
|
|
29
|
+
--bg:#0e111a;--bg-2:#171b28;--bg-3:#232c42;--chip:#161b2a;--border:#2a3350;--border-2:#3a4a72;
|
|
30
|
+
--hover:#2e3a58;--hover-border:#4c5f92;--fg:#e8ecf5;--fg-2:#cdd8f0;--fg-3:#aab6d0;--fg-4:#8a97b5;--fg-5:#8291b0;
|
|
31
|
+
--accent:#e35d5d;--warn:#f0b429;--ok:#4fd18b;--info:#9db8ef;--badge-bg:#1c2333;--fg-on-accent:#fff;--fg-hover:#fff;
|
|
32
|
+
--chip-off-border:#4a3a1a;--shadow:0 4px 16px rgba(0,0,0,.5);--blur:none;--radius:12px;--radius-sm:6px;
|
|
33
|
+
position:fixed;inset:0;margin:0;padding:0;border:0;background:transparent;width:100vw;height:100vh;overflow:visible;pointer-events:none;font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;color:var(--fg)
|
|
34
|
+
}
|
|
35
|
+
:host([data-theme="light"]){
|
|
36
|
+
--bg:#ffffff;--bg-2:#f4f6fb;--bg-3:#e6eaf3;--chip:#eef1f7;--border:#cfd6e4;--border-2:#b8c2d6;
|
|
37
|
+
--hover:#dde3ef;--hover-border:#9fadc8;--fg:#171b28;--fg-2:#2a3350;--fg-3:#4b5670;--fg-4:#5f6b86;--fg-5:#6f7c97;
|
|
38
|
+
--accent:#d9453f;--warn:#b7791f;--ok:#1f8f57;--info:#3b6fd6;--badge-bg:#ffffff;--fg-hover:#171b28;
|
|
39
|
+
--chip-off-border:#e6d29c;--shadow:0 4px 16px rgba(20,30,60,.18);--blur:none;
|
|
40
|
+
}
|
|
41
|
+
:host([data-theme="frost"]){
|
|
42
|
+
--bg:rgba(14,17,26,.78);--bg-2:#171b28;--bg-3:rgba(255,255,255,.10);--chip:rgba(255,255,255,.06);
|
|
43
|
+
--border:rgba(255,255,255,.14);--border-2:rgba(255,255,255,.22);--hover:rgba(255,255,255,.16);--hover-border:rgba(255,255,255,.30);
|
|
44
|
+
--fg:#e8ecf5;--fg-2:#cdd8f0;--fg-3:#aab6d0;--fg-4:#9aa6c2;--fg-5:#8291b0;
|
|
45
|
+
--accent:#e35d5d;--warn:#f0b429;--ok:#4fd18b;--info:#9db8ef;--badge-bg:#1c2333;--fg-hover:#fff;
|
|
46
|
+
--chip-off-border:rgba(240,180,41,.35);--shadow:0 8px 24px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.08);--blur:blur(18px) saturate(140%);
|
|
47
|
+
}
|
|
48
|
+
@supports not (backdrop-filter: blur(1px)) { :host([data-theme="frost"]) { --bg:#0e111a; --blur:none } }
|
|
6
49
|
:host::backdrop{display:none}
|
|
7
50
|
*{box-sizing:border-box}
|
|
8
51
|
.glass{position:fixed;inset:0;pointer-events:auto;cursor:crosshair;display:none}
|
|
9
|
-
.hover-box{position:fixed;display:none;border:2px solid
|
|
10
|
-
.hover-badge{position:fixed;display:none;background
|
|
11
|
-
.band{position:fixed;display:none;border:1.5px dashed
|
|
12
|
-
.toolbar{position:fixed;bottom:14px;left:50%;transform:translateX(-50%);display:flex;gap:6px;align-items:center;background
|
|
13
|
-
.toolbar button,.panel button{font:inherit;color
|
|
14
|
-
.toolbar button:hover,.panel button:hover{background
|
|
15
|
-
.toolbar button:focus-visible,.panel button:focus-visible{outline:2px solid
|
|
16
|
-
.toolbar button.on{color
|
|
17
|
-
.els button{background:transparent;border-color:transparent;color
|
|
18
|
-
.els button:hover{background
|
|
19
|
-
.
|
|
20
|
-
.
|
|
21
|
-
.
|
|
22
|
-
.
|
|
23
|
-
.
|
|
24
|
-
.
|
|
25
|
-
.
|
|
52
|
+
.hover-box{position:fixed;display:none;border:2px solid var(--accent);background:color-mix(in srgb, var(--accent) 8%, transparent);border-radius:2px;pointer-events:none}
|
|
53
|
+
.hover-badge{position:fixed;display:none;background:var(--badge-bg);border:1px solid var(--accent);border-radius:var(--radius-sm);padding:4px 8px;white-space:pre;color:var(--fg-on-accent);pointer-events:none;max-width:480px}
|
|
54
|
+
.band{position:fixed;display:none;border:1.5px dashed var(--accent);background:color-mix(in srgb, var(--accent) 6%, transparent);pointer-events:none}
|
|
55
|
+
.toolbar{position:fixed;bottom:14px;left:50%;transform:translateX(-50%);display:flex;gap:6px;align-items:center;background:var(--bg);border:1px solid var(--border);border-radius:999px;padding:6px 10px;box-shadow:var(--shadow);backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);pointer-events:auto}
|
|
56
|
+
.toolbar button,.panel button{font:inherit;color:var(--fg-2);background:var(--bg-3);border:1px solid var(--border-2);border-radius:999px;padding:4px 10px;cursor:pointer}
|
|
57
|
+
.toolbar button:hover,.panel button:hover{background:var(--hover);border-color:var(--hover-border);color:var(--fg-hover)}
|
|
58
|
+
.toolbar button:focus-visible,.panel button:focus-visible{outline:2px solid var(--info);outline-offset:1px}
|
|
59
|
+
.toolbar button.on{color:var(--fg-on-accent);background:var(--accent);border-color:var(--accent)}
|
|
60
|
+
.els button{background:transparent;border-color:transparent;color:var(--fg-5);padding:0 6px}
|
|
61
|
+
.els button:hover{background:var(--hover);color:var(--fg-hover)}
|
|
62
|
+
.chip{display:inline-flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;background:var(--chip);border:1px solid transparent;color:var(--fg-3);white-space:nowrap;cursor:default;user-select:none}
|
|
63
|
+
.chip[hidden]{display:none}
|
|
64
|
+
.chip .ico{display:inline-flex;line-height:0}
|
|
65
|
+
.chip.strategy .ico svg{width:12px;height:12px}
|
|
66
|
+
.chip.off{color:var(--warn);border-color:var(--chip-off-border)}
|
|
67
|
+
.dot{font-size:9px;line-height:1;color:var(--fg-5)}
|
|
68
|
+
.dot.waiting{color:var(--ok)}
|
|
69
|
+
.dot.sent{color:var(--warn)}
|
|
70
|
+
.dot.working{color:var(--info)}
|
|
71
|
+
.dot.done{color:var(--ok)}
|
|
72
|
+
.status{max-width:440px;overflow:hidden;color:var(--fg-4)}
|
|
73
|
+
.status.off{color:var(--warn)}
|
|
26
74
|
.status-in{display:inline-block;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:bottom;transition:transform .2s ease-out}
|
|
27
75
|
.status-in.scroll{max-width:none;overflow:visible;text-overflow:clip}
|
|
28
76
|
.status-in.enter{animation:cobroin .15s ease-out}
|
|
29
77
|
@keyframes cobroin{from{opacity:.4;transform:translateX(-6px)}to{opacity:1;transform:translateX(0)}}
|
|
30
78
|
@media (prefers-reduced-motion: reduce){.status-in{transition:none}.status-in.enter{animation:none}}
|
|
31
|
-
.panel{position:fixed;right:14px;bottom:60px;width:320px;background
|
|
79
|
+
.panel{position:fixed;right:14px;bottom:60px;width:320px;background:var(--bg-2);border:1px solid var(--accent);border-radius:var(--radius);padding:10px 12px;box-shadow:var(--shadow);pointer-events:auto;display:none}
|
|
32
80
|
.panel.show{display:block}
|
|
33
|
-
.panel h4{margin:0 0 6px;color
|
|
34
|
-
.panel h4 .mark{color
|
|
35
|
-
.els{max-height:110px;overflow:auto;margin-bottom:8px;color
|
|
81
|
+
.panel h4{margin:0 0 6px;color:var(--fg);font-size:12px;font-weight:400}
|
|
82
|
+
.panel h4 .mark{color:var(--accent);margin-right:4px}
|
|
83
|
+
.els{max-height:110px;overflow:auto;margin-bottom:8px;color:var(--fg-3);font-size:11px}
|
|
36
84
|
.els div{display:flex;justify-content:space-between;gap:6px;word-break:break-all}
|
|
37
|
-
.els .missing{color
|
|
38
|
-
textarea{width:100%;height:54px;resize:none;font:inherit;color
|
|
85
|
+
.els .missing{color:var(--warn)}
|
|
86
|
+
textarea{width:100%;height:54px;resize:none;font:inherit;color:var(--fg);background:var(--bg);border:1px solid var(--border-2);border-radius:var(--radius-sm);padding:4px 6px;margin-bottom:8px}
|
|
39
87
|
.row{display:flex;justify-content:flex-end;gap:6px;align-items:center}
|
|
40
|
-
.row .send{color
|
|
88
|
+
.row .send{color:var(--fg-on-accent);background:var(--accent);border-color:var(--accent);font-weight:700}
|
|
41
89
|
.row .send:disabled{opacity:.4;cursor:not-allowed}
|
|
42
|
-
.flash{position:fixed;border:2px solid
|
|
90
|
+
.flash{position:fixed;border:2px solid var(--ok);border-radius:2px;pointer-events:none;animation:cobroflash 1.6s ease-out forwards}
|
|
43
91
|
@keyframes cobroflash{0%{opacity:1}100%{opacity:0}}
|
|
44
92
|
/* shadow root\uC758 \uC790\uC2DD\uC740 \uBAA8\uB450 position:fixed \uD615\uC81C \u2014 picker\uAC00 glass\uB97C toolbar/panel \uB4A4\uC5D0 append\uD558\uBBC0\uB85C \uC313\uC784 \uC21C\uC11C\uB97C \uBA85\uC2DC\uD55C\uB2E4 */
|
|
45
93
|
.glass{z-index:0}
|
|
46
94
|
.hover-box,.hover-badge,.band,.flash{z-index:1}
|
|
47
|
-
.toolbar,.panel{z-index:2}
|
|
95
|
+
.toolbar,.pop,.panel{z-index:2}
|
|
96
|
+
.pop{position:fixed;bottom:56px;left:50%;transform:translateX(-50%);display:none;min-width:260px;background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:10px 12px;box-shadow:var(--shadow);backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);pointer-events:auto;color:var(--fg-2)}
|
|
97
|
+
.pop.show{display:block}
|
|
98
|
+
.pop-row{display:flex;align-items:center;justify-content:space-between;gap:10px}
|
|
99
|
+
.pop-label{color:var(--fg-3)}
|
|
100
|
+
.seg{display:inline-flex;gap:2px;background:var(--chip);border-radius:999px;padding:2px}
|
|
101
|
+
.seg button{border:1px solid transparent;background:transparent;padding:2px 9px;font:inherit;cursor:pointer;color:var(--fg-3)}
|
|
102
|
+
.seg button:hover:not(:disabled){color:var(--fg)}
|
|
103
|
+
.seg button.on{background:var(--bg-3);color:var(--fg)}
|
|
104
|
+
.seg button:disabled{opacity:.5;cursor:not-allowed}
|
|
105
|
+
.pop-note{margin-top:6px;color:var(--warn);font-size:11px}
|
|
106
|
+
.ib{display:inline-flex;align-items:center;padding:4px 7px}
|
|
107
|
+
.ib .ico{display:inline-flex;line-height:0}
|
|
108
|
+
.ib .lbl{max-width:0;opacity:0;overflow:hidden;white-space:nowrap;margin-left:0;transition:max-width .1s ease-in,opacity .1s ease-in,margin-left .1s ease-in}
|
|
109
|
+
.ib:hover .lbl,.ib:focus-visible .lbl{max-width:9ch;opacity:1;margin-left:5px;transition-duration:.15s;transition-timing-function:ease-out}
|
|
110
|
+
@media (prefers-reduced-motion: reduce){.ib .lbl{transition:none}}
|
|
48
111
|
`;
|
|
49
112
|
var LANG = navigator.language.toLowerCase().startsWith("ko") ? "ko" : "en";
|
|
50
113
|
var T = {
|
|
@@ -54,13 +117,21 @@ textarea{width:100%;height:54px;resize:none;font:inherit;color:#e8ecf5;backgroun
|
|
|
54
117
|
agentSent: "\uC804\uC1A1\uB428 \u2014 \uC5D0\uC774\uC804\uD2B8 \uC751\uB2F5 \uB300\uAE30",
|
|
55
118
|
agentWorking: "\uC218\uC815 \uC911",
|
|
56
119
|
agentDone: "\uC644\uB8CC",
|
|
120
|
+
doneResult: (s) => `\u2713 ${T.agentDone}: ${s}`,
|
|
121
|
+
chipIdle: "\uBBF8\uC5F0\uACB0",
|
|
122
|
+
chipWaiting: "\uB300\uAE30 \uC911",
|
|
123
|
+
chipSent: "\uC804\uC1A1\uB428",
|
|
124
|
+
chipWorking: "\uC218\uC815 \uC911",
|
|
125
|
+
chipDone: "\uC644\uB8CC",
|
|
126
|
+
chipOff: "\uC5F0\uACB0 \uB04A\uAE40",
|
|
127
|
+
agentSentDetail: "\uC5D0\uC774\uC804\uD2B8 \uC751\uB2F5 \uB300\uAE30",
|
|
57
128
|
disconnected: "\uC5F0\uACB0 \uB04A\uAE40 \u2014 \uC7AC\uC5F0\uACB0 \uC911",
|
|
58
129
|
hintSend: "Send\uB85C \uC804\uC1A1\uD558\uC138\uC694",
|
|
59
130
|
hintClick: "\uD398\uC774\uC9C0\uC5D0\uC11C \uC694\uC18C\uB97C \uD074\uB9AD\uD558\uC138\uC694 \xB7 Esc\uB85C \uD574\uC81C",
|
|
60
131
|
hintMore: (n) => `\uC694\uC18C ${n}\uAC1C \uC120\uD0DD \xB7 \uB354 \uACE0\uB974\uAC70\uB098 \uBA54\uBAA8\uB97C \uC801\uC73C\uC138\uC694`,
|
|
61
132
|
hintNote: "\uBA54\uBAA8\uB97C \uC801\uACE0 Send\uB97C \uB204\uB974\uC138\uC694",
|
|
62
133
|
hintPick: "Ctrl+Shift+F \uB610\uB294 Select\uB85C \uC694\uC18C\uB97C \uACE0\uB974\uC138\uC694",
|
|
63
|
-
|
|
134
|
+
tipStrategy: (s) => `\uAC31\uC2E0 \uC804\uB7B5: ${s} \u2014 ${{ none: "HMR\uC774 \uC788\uC5B4 done \uB4A4 \uC0C8\uB85C\uACE0\uCE68 \uC5C6\uC74C", reload: "done \uB4A4 \uD398\uC774\uC9C0 \uC0C8\uB85C\uACE0\uCE68", event: "\uC571\uC774 cobro:done \uC774\uBCA4\uD2B8\uB85C \uC9C1\uC811 \uAC31\uC2E0" }[s]}`,
|
|
64
135
|
selCount: (n) => `\uC694\uC18C ${n}\uAC1C \uC120\uD0DD\uB428`,
|
|
65
136
|
selNone: "\uC120\uD0DD\uB41C \uC694\uC18C \uC5C6\uC74C \xB7 \uBA54\uBAA8\uB9CC \uBCF4\uB0B4\uB3C4 \uB429\uB2C8\uB2E4",
|
|
66
137
|
elMissing: "\uC694\uC18C \uC5C6\uC74C",
|
|
@@ -69,7 +140,14 @@ textarea{width:100%;height:54px;resize:none;font:inherit;color:#e8ecf5;backgroun
|
|
|
69
140
|
tipCollapse: "\uD328\uB110 \uC811\uAE30 / \uD3BC\uCE58\uAE30",
|
|
70
141
|
tipSend: "\uC120\uD0DD\uD55C \uC694\uC18C\uC640 \uBA54\uBAA8\uB97C \uC5D0\uC774\uC804\uD2B8\uC5D0 \uC804\uC1A1",
|
|
71
142
|
tipSendLocked: "\uC5D0\uC774\uC804\uD2B8\uAC00 \uC791\uC5C5 \uC911 \u2014 done \uB4A4\uC5D0 \uBCF4\uB0BC \uC218 \uC788\uC2B5\uB2C8\uB2E4",
|
|
72
|
-
tipRemove: "\uC774 \uC694\uC18C \uBE7C\uAE30"
|
|
143
|
+
tipRemove: "\uC774 \uC694\uC18C \uBE7C\uAE30",
|
|
144
|
+
tipSettings: "\uC124\uC815",
|
|
145
|
+
theme: "\uD14C\uB9C8",
|
|
146
|
+
themeAuto: "\uC790\uB3D9",
|
|
147
|
+
themeDark: "\uC5B4\uB461\uAC8C",
|
|
148
|
+
themeLight: "\uBC1D\uAC8C",
|
|
149
|
+
themeFrost: "\uC720\uB9AC",
|
|
150
|
+
themeLocked: "COBRO_THEME \uD658\uACBD \uBCC0\uC218\uB85C \uACE0\uC815\uB428"
|
|
73
151
|
},
|
|
74
152
|
en: {
|
|
75
153
|
agentIdle: "Agent not connected",
|
|
@@ -77,13 +155,21 @@ textarea{width:100%;height:54px;resize:none;font:inherit;color:#e8ecf5;backgroun
|
|
|
77
155
|
agentSent: "Sent \u2014 waiting for the agent",
|
|
78
156
|
agentWorking: "Working",
|
|
79
157
|
agentDone: "Done",
|
|
158
|
+
doneResult: (s) => `\u2713 ${T.agentDone}: ${s}`,
|
|
159
|
+
chipIdle: "Offline",
|
|
160
|
+
chipWaiting: "Waiting",
|
|
161
|
+
chipSent: "Sent",
|
|
162
|
+
chipWorking: "Working",
|
|
163
|
+
chipDone: "Done",
|
|
164
|
+
chipOff: "Disconnected",
|
|
165
|
+
agentSentDetail: "Waiting for the agent",
|
|
80
166
|
disconnected: "Disconnected \u2014 reconnecting",
|
|
81
167
|
hintSend: "Press Send to deliver",
|
|
82
168
|
hintClick: "Click an element on the page \xB7 Esc to exit",
|
|
83
169
|
hintMore: (n) => `${n} selected \xB7 pick more or write a note`,
|
|
84
170
|
hintNote: "Write a note, then press Send",
|
|
85
171
|
hintPick: "Press Ctrl+Shift+F or Select to pick an element",
|
|
86
|
-
|
|
172
|
+
tipStrategy: (s) => `Refresh strategy: ${s} \u2014 ${{ none: "HMR present \u2014 no reload after done", reload: "page reloads after done", event: "the app refreshes itself on cobro:done" }[s]}`,
|
|
87
173
|
selCount: (n) => `${n} element(s) selected`,
|
|
88
174
|
selNone: "No element selected \xB7 a note alone is fine",
|
|
89
175
|
elMissing: "missing",
|
|
@@ -92,17 +178,27 @@ textarea{width:100%;height:54px;resize:none;font:inherit;color:#e8ecf5;backgroun
|
|
|
92
178
|
tipCollapse: "Collapse / expand the panel",
|
|
93
179
|
tipSend: "Send the selected elements and note to the agent",
|
|
94
180
|
tipSendLocked: "Agent is working \u2014 you can send after done",
|
|
95
|
-
tipRemove: "Remove this element"
|
|
181
|
+
tipRemove: "Remove this element",
|
|
182
|
+
tipSettings: "Settings",
|
|
183
|
+
theme: "Theme",
|
|
184
|
+
themeAuto: "Auto",
|
|
185
|
+
themeDark: "Dark",
|
|
186
|
+
themeLight: "Light",
|
|
187
|
+
themeFrost: "Frost",
|
|
188
|
+
themeLocked: "Pinned by COBRO_THEME"
|
|
96
189
|
}
|
|
97
190
|
}[LANG];
|
|
191
|
+
var THEME_LABEL = { auto: T.themeAuto, dark: T.themeDark, light: T.themeLight, frost: T.themeFrost };
|
|
192
|
+
var LABELS = { working: ["\uC218\uC815 \uC911", "Editing", "Working"], done: ["\uC644\uB8CC", "Done"] };
|
|
98
193
|
var AGENT_TEXT = {
|
|
99
194
|
idle: () => T.agentIdle,
|
|
100
195
|
waiting: () => T.agentWaiting,
|
|
101
|
-
sent: () => T.
|
|
102
|
-
working: (t) =>
|
|
103
|
-
done: (t) =>
|
|
196
|
+
sent: () => T.agentSentDetail,
|
|
197
|
+
working: (t) => stripStatusLabel(t, LABELS.working),
|
|
198
|
+
done: (t) => stripStatusLabel(t, LABELS.done)
|
|
104
199
|
};
|
|
105
200
|
var DOT_TITLE = { idle: T.agentIdle, waiting: T.agentWaiting, sent: T.agentSent, working: T.agentWorking, done: T.agentDone };
|
|
201
|
+
var CHIP_LABEL = { idle: T.chipIdle, waiting: T.chipWaiting, sent: T.chipSent, working: T.chipWorking, done: T.chipDone };
|
|
106
202
|
function createUI(h) {
|
|
107
203
|
const host = document.createElement("div");
|
|
108
204
|
host.setAttribute("data-cobro-host", "");
|
|
@@ -112,31 +208,119 @@ textarea{width:100%;height:54px;resize:none;font:inherit;color:#e8ecf5;backgroun
|
|
|
112
208
|
style.textContent = CSS2;
|
|
113
209
|
const toolbar = document.createElement("div");
|
|
114
210
|
toolbar.className = "toolbar";
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
211
|
+
const iconBtn = (icon, label, title, extraClass, withLabel) => {
|
|
212
|
+
const btn = document.createElement("button");
|
|
213
|
+
btn.className = `ib ${extraClass}`;
|
|
214
|
+
btn.title = title;
|
|
215
|
+
btn.setAttribute("aria-label", label);
|
|
216
|
+
const ico = document.createElement("span");
|
|
217
|
+
ico.className = "ico";
|
|
218
|
+
ico.innerHTML = svg(icon);
|
|
219
|
+
btn.append(ico);
|
|
220
|
+
if (withLabel) {
|
|
221
|
+
const lbl = document.createElement("span");
|
|
222
|
+
lbl.className = "lbl";
|
|
223
|
+
lbl.textContent = label;
|
|
224
|
+
btn.append(lbl);
|
|
225
|
+
}
|
|
226
|
+
return { btn, ico };
|
|
227
|
+
};
|
|
228
|
+
const selectParts = iconBtn("select", "Select", T.tipSelect, "select", true);
|
|
229
|
+
const selectBtn = selectParts.btn;
|
|
230
|
+
selectBtn.onclick = () => {
|
|
231
|
+
closePop();
|
|
232
|
+
h.onToggleSelect();
|
|
233
|
+
};
|
|
234
|
+
const chip = document.createElement("span");
|
|
235
|
+
chip.className = "chip";
|
|
119
236
|
const dot = document.createElement("span");
|
|
120
237
|
dot.className = "dot";
|
|
121
238
|
dot.textContent = "\u25CF";
|
|
239
|
+
const chipLabel = document.createElement("span");
|
|
240
|
+
chipLabel.className = "chip-label";
|
|
241
|
+
chip.append(dot, chipLabel);
|
|
242
|
+
const chip2 = document.createElement("span");
|
|
243
|
+
chip2.className = "chip strategy";
|
|
244
|
+
const chip2Ico = document.createElement("span");
|
|
245
|
+
chip2Ico.className = "ico";
|
|
246
|
+
chip2Ico.innerHTML = svg("sync");
|
|
247
|
+
const chip2Label = document.createElement("span");
|
|
248
|
+
chip2Label.className = "chip-label";
|
|
249
|
+
chip2.append(chip2Ico, chip2Label);
|
|
122
250
|
const status = document.createElement("span");
|
|
123
251
|
status.className = "status";
|
|
124
252
|
const statusIn = document.createElement("span");
|
|
125
253
|
statusIn.className = "status-in";
|
|
126
254
|
status.append(statusIn);
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
255
|
+
const gearParts = iconBtn("settings", T.tipSettings, T.tipSettings, "gear", false);
|
|
256
|
+
const gearBtn = gearParts.btn;
|
|
257
|
+
const collapseParts = iconBtn("collapse", "Collapse", T.tipCollapse, "collapse", false);
|
|
258
|
+
const collapseBtn = collapseParts.btn;
|
|
259
|
+
toolbar.append(selectBtn, chip, chip2, status, gearBtn, collapseBtn);
|
|
260
|
+
const pop = document.createElement("div");
|
|
261
|
+
pop.className = "pop";
|
|
262
|
+
const popRow = document.createElement("div");
|
|
263
|
+
popRow.className = "pop-row";
|
|
264
|
+
const popLabel = document.createElement("span");
|
|
265
|
+
popLabel.className = "pop-label";
|
|
266
|
+
popLabel.textContent = T.theme;
|
|
267
|
+
const seg2 = document.createElement("div");
|
|
268
|
+
seg2.className = "seg";
|
|
269
|
+
const segButtons = THEMES.map((key) => {
|
|
270
|
+
const btn = document.createElement("button");
|
|
271
|
+
btn.textContent = THEME_LABEL[key];
|
|
272
|
+
btn.dataset.theme = key;
|
|
273
|
+
btn.onclick = () => h.onSettings({ theme: key });
|
|
274
|
+
return btn;
|
|
275
|
+
});
|
|
276
|
+
seg2.append(...segButtons);
|
|
277
|
+
popRow.append(popLabel, seg2);
|
|
278
|
+
const popNote = document.createElement("div");
|
|
279
|
+
popNote.className = "pop-note";
|
|
280
|
+
popNote.textContent = T.themeLocked;
|
|
281
|
+
pop.append(popRow, popNote);
|
|
282
|
+
let popOpen = false;
|
|
283
|
+
let popCloseListeners = null;
|
|
284
|
+
const closePop = () => {
|
|
285
|
+
if (!popOpen) return;
|
|
286
|
+
pop.classList.remove("show");
|
|
287
|
+
popOpen = false;
|
|
288
|
+
if (popCloseListeners) {
|
|
289
|
+
document.removeEventListener("pointerdown", popCloseListeners.doc, true);
|
|
290
|
+
window.removeEventListener("keydown", popCloseListeners.key, true);
|
|
291
|
+
popCloseListeners = null;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
const openPop = () => {
|
|
295
|
+
pop.classList.add("show");
|
|
296
|
+
popOpen = true;
|
|
297
|
+
const onDocPointerDown = (e) => {
|
|
298
|
+
const path = e.composedPath();
|
|
299
|
+
if (!path.includes(pop) && !path.includes(gearBtn)) closePop();
|
|
300
|
+
};
|
|
301
|
+
const onKeyDown = (e) => {
|
|
302
|
+
if (e.key === "Escape") closePop();
|
|
303
|
+
};
|
|
304
|
+
document.addEventListener("pointerdown", onDocPointerDown, true);
|
|
305
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
306
|
+
popCloseListeners = { doc: onDocPointerDown, key: onKeyDown };
|
|
307
|
+
};
|
|
308
|
+
gearBtn.onclick = () => {
|
|
309
|
+
if (popOpen) closePop();
|
|
310
|
+
else openPop();
|
|
311
|
+
};
|
|
131
312
|
const panel = document.createElement("div");
|
|
132
313
|
panel.className = "panel";
|
|
133
|
-
root.append(style, toolbar, panel);
|
|
314
|
+
root.append(style, toolbar, pop, panel);
|
|
134
315
|
let collapsed = false;
|
|
135
316
|
let lastVm = null;
|
|
136
317
|
let lastHint = null;
|
|
137
318
|
collapseBtn.onclick = () => {
|
|
138
319
|
collapsed = !collapsed;
|
|
139
|
-
|
|
320
|
+
const label = collapsed ? "Expand" : "Collapse";
|
|
321
|
+
collapseBtn.setAttribute("aria-label", label);
|
|
322
|
+
collapseBtn.title = label;
|
|
323
|
+
collapseParts.ico.innerHTML = svg(collapsed ? "expand" : "collapse");
|
|
140
324
|
if (lastVm) render(lastVm);
|
|
141
325
|
};
|
|
142
326
|
const textareas = /* @__PURE__ */ new Map();
|
|
@@ -204,17 +388,26 @@ textarea{width:100%;height:54px;resize:none;font:inherit;color:#e8ecf5;backgroun
|
|
|
204
388
|
const wasTa = active instanceof HTMLTextAreaElement ? active : null;
|
|
205
389
|
const sel = wasTa ? [wasTa.selectionStart, wasTa.selectionEnd] : null;
|
|
206
390
|
selectBtn.classList.toggle("on", vm.selecting);
|
|
391
|
+
for (const btn of segButtons) {
|
|
392
|
+
btn.classList.toggle("on", btn.dataset.theme === vm.prefs.theme);
|
|
393
|
+
btn.disabled = vm.prefs.themeLocked;
|
|
394
|
+
}
|
|
395
|
+
popNote.hidden = !vm.prefs.themeLocked;
|
|
207
396
|
const cur = vm.drafts[vm.drafts.length - 1];
|
|
208
397
|
const hasElements = !!cur && cur.elements.length > 0;
|
|
209
|
-
const suffix = vm.strategy ? ` \xB7 ${T.refresh}: ${vm.strategy}` : "";
|
|
210
398
|
let hint;
|
|
211
399
|
if (!vm.connected) hint = T.disconnected;
|
|
212
|
-
else
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
400
|
+
else {
|
|
401
|
+
let text;
|
|
402
|
+
if (vm.agent.status === "sent" || vm.agent.status === "working" || vm.agent.status === "done") text = AGENT_TEXT[vm.agent.status](vm.agent.text);
|
|
403
|
+
else if (vm.agent.status === "waiting" && vm.agent.text && !hasElements && (cur?.note.trim() ?? "") === "") text = T.doneResult(stripStatusLabel(vm.agent.text, LABELS.done));
|
|
404
|
+
else if (hasElements && cur.note.trim() !== "") text = T.hintSend;
|
|
405
|
+
else if (vm.selecting && !hasElements) text = T.hintClick;
|
|
406
|
+
else if (vm.selecting) text = T.hintMore(cur.elements.length);
|
|
407
|
+
else if (hasElements) text = T.hintNote;
|
|
408
|
+
else text = T.hintPick;
|
|
409
|
+
hint = text;
|
|
410
|
+
}
|
|
218
411
|
if (hint !== lastHint) {
|
|
219
412
|
lastHint = hint;
|
|
220
413
|
if (!statusIn.classList.contains("scroll")) {
|
|
@@ -230,8 +423,15 @@ textarea{width:100%;height:54px;resize:none;font:inherit;color:#e8ecf5;backgroun
|
|
|
230
423
|
if (statusIn.classList.contains("scroll")) statusIn.classList.remove("enter");
|
|
231
424
|
}
|
|
232
425
|
status.classList.toggle("off", !vm.connected);
|
|
426
|
+
chip.classList.toggle("off", !vm.connected);
|
|
233
427
|
dot.className = vm.connected ? "dot " + vm.agent.status : "dot";
|
|
234
|
-
|
|
428
|
+
chipLabel.textContent = vm.connected ? CHIP_LABEL[vm.agent.status] : T.chipOff;
|
|
429
|
+
chip.title = vm.connected ? DOT_TITLE[vm.agent.status] : T.disconnected;
|
|
430
|
+
chip2.hidden = !vm.strategy;
|
|
431
|
+
if (vm.strategy) {
|
|
432
|
+
chip2Label.textContent = vm.strategy;
|
|
433
|
+
chip2.title = T.tipStrategy(vm.strategy);
|
|
434
|
+
}
|
|
235
435
|
const show = !collapsed && vm.drafts.length > 0;
|
|
236
436
|
panel.classList.toggle("show", show);
|
|
237
437
|
if (vm.drafts.length === 0) {
|
|
@@ -271,7 +471,10 @@ textarea{width:100%;height:54px;resize:none;font:inherit;color:#e8ecf5;backgroun
|
|
|
271
471
|
const send = el("button", "send", "Send");
|
|
272
472
|
send.disabled = vm.locked;
|
|
273
473
|
send.title = vm.locked ? T.tipSendLocked : T.tipSend;
|
|
274
|
-
send.onclick = () =>
|
|
474
|
+
send.onclick = () => {
|
|
475
|
+
closePop();
|
|
476
|
+
h.onSend();
|
|
477
|
+
};
|
|
275
478
|
row.append(send);
|
|
276
479
|
panel.append(row);
|
|
277
480
|
for (const id of [...textareas.keys()]) if (!vm.drafts.some((b) => b.id === id)) textareas.delete(id);
|
|
@@ -299,7 +502,10 @@ textarea{width:100%;height:54px;resize:none;font:inherit;color:#e8ecf5;backgroun
|
|
|
299
502
|
const ta = panel.querySelector("textarea");
|
|
300
503
|
ta?.focus();
|
|
301
504
|
}
|
|
302
|
-
|
|
505
|
+
function setTheme(t) {
|
|
506
|
+
host.dataset.theme = t;
|
|
507
|
+
}
|
|
508
|
+
return { host, root, render, flash, focusNote, setTheme, closePop };
|
|
303
509
|
}
|
|
304
510
|
|
|
305
511
|
// src/overlay/picker.ts
|
|
@@ -606,6 +812,13 @@ ${Math.round(r.width)}\xD7${Math.round(r.height)}`;
|
|
|
606
812
|
if (strategy === "reload") reload();
|
|
607
813
|
}
|
|
608
814
|
|
|
815
|
+
// src/overlay/theme.ts
|
|
816
|
+
function resolveTheme(pref, env) {
|
|
817
|
+
if (pref === "frost") return env.backdropOk && !env.reduceTransparency ? "frost" : "dark";
|
|
818
|
+
if (pref === "auto") return env.prefersDark ? "dark" : "light";
|
|
819
|
+
return pref;
|
|
820
|
+
}
|
|
821
|
+
|
|
609
822
|
// src/overlay/index.ts
|
|
610
823
|
(() => {
|
|
611
824
|
if (window.top !== window) return;
|
|
@@ -619,6 +832,8 @@ ${Math.round(r.width)}\xD7${Math.round(r.height)}`;
|
|
|
619
832
|
let current = null;
|
|
620
833
|
let connected = false;
|
|
621
834
|
let draftTimer = null;
|
|
835
|
+
let prefs = { theme: "auto", themeLocked: false };
|
|
836
|
+
const mq = matchMedia("(prefers-color-scheme: dark)");
|
|
622
837
|
const pageInfo = () => ({ url: location.href, title: document.title, viewport: { w: innerWidth, h: innerHeight } });
|
|
623
838
|
const newBatch = () => ({ id: crypto.randomUUID(), note: "", elements: [], status: "draft", createdAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
624
839
|
const ensureCurrent = () => {
|
|
@@ -648,7 +863,8 @@ ${Math.round(r.width)}\xD7${Math.round(r.height)}`;
|
|
|
648
863
|
agent: session?.agent ?? { status: "idle", text: "" },
|
|
649
864
|
strategy: session ? session.strategy ?? session.detected : null,
|
|
650
865
|
drafts: drafts ?? [],
|
|
651
|
-
locked: session?.agent.status === "sent" || session?.agent.status === "working"
|
|
866
|
+
locked: session?.agent.status === "sent" || session?.agent.status === "working",
|
|
867
|
+
prefs
|
|
652
868
|
});
|
|
653
869
|
const render = () => ui.render(vm());
|
|
654
870
|
const addEl = (b, el, toggle) => {
|
|
@@ -700,8 +916,15 @@ ${Math.round(r.width)}\xD7${Math.round(r.height)}`;
|
|
|
700
916
|
current = null;
|
|
701
917
|
picker.setActive(false);
|
|
702
918
|
render();
|
|
703
|
-
}
|
|
919
|
+
},
|
|
920
|
+
onSettings: (patch) => chan.send({ type: "settings", patch })
|
|
704
921
|
});
|
|
922
|
+
const applyTheme = () => ui.setTheme(resolveTheme(prefs.theme, {
|
|
923
|
+
prefersDark: mq.matches,
|
|
924
|
+
backdropOk: CSS.supports("backdrop-filter", "blur(1px)") || CSS.supports("-webkit-backdrop-filter", "blur(1px)"),
|
|
925
|
+
reduceTransparency: matchMedia("(prefers-reduced-transparency: reduce)").matches
|
|
926
|
+
}));
|
|
927
|
+
mq.addEventListener("change", applyTheme);
|
|
705
928
|
const picker = createPicker({
|
|
706
929
|
root: ui.root,
|
|
707
930
|
host: ui.host,
|
|
@@ -721,6 +944,7 @@ ${Math.round(r.width)}\xD7${Math.round(r.height)}`;
|
|
|
721
944
|
window.addEventListener("keydown", (e) => {
|
|
722
945
|
if (e.ctrlKey && e.shiftKey && e.code === "KeyF") {
|
|
723
946
|
e.preventDefault();
|
|
947
|
+
ui.closePop();
|
|
724
948
|
picker.setActive(!picker.isActive());
|
|
725
949
|
render();
|
|
726
950
|
} else if (e.key === "Escape" && picker.isActive()) {
|
|
@@ -732,6 +956,8 @@ ${Math.round(r.width)}\xD7${Math.round(r.height)}`;
|
|
|
732
956
|
const onMessage = (m) => {
|
|
733
957
|
if (m.type === "state") {
|
|
734
958
|
session = m.session;
|
|
959
|
+
prefs = m.ui;
|
|
960
|
+
applyTheme();
|
|
735
961
|
const nonDraft = new Set(m.session.batches.filter((b) => b.status !== "draft").map((b) => b.id));
|
|
736
962
|
const serverDrafts = m.session.batches.filter((b) => b.status === "draft");
|
|
737
963
|
if (drafts === null) {
|
package/dist/server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/server.ts
|
|
4
|
-
import { readFileSync as
|
|
5
|
-
import { join as join3, dirname } from "node:path";
|
|
4
|
+
import { readFileSync as readFileSync3, existsSync as existsSync4 } from "node:fs";
|
|
5
|
+
import { join as join3, dirname as dirname2 } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { randomBytes } from "node:crypto";
|
|
@@ -72,7 +72,8 @@ var SessionCore = class extends EventEmitter {
|
|
|
72
72
|
super();
|
|
73
73
|
this.store = store2;
|
|
74
74
|
this.s = store2.load() ?? emptySession();
|
|
75
|
-
if (this.s.agent.status === "waiting"
|
|
75
|
+
if (this.s.agent.status === "waiting") this.s.agent = { status: "idle", text: this.s.agent.text };
|
|
76
|
+
else if (this.s.agent.status === "working") this.s.agent = { status: "idle", text: "" };
|
|
76
77
|
}
|
|
77
78
|
s;
|
|
78
79
|
queue = [];
|
|
@@ -139,7 +140,8 @@ var SessionCore = class extends EventEmitter {
|
|
|
139
140
|
}
|
|
140
141
|
const queued = this.queue.shift();
|
|
141
142
|
if (queued) return Promise.resolve({ status: "sent", ...queued });
|
|
142
|
-
this.s.agent
|
|
143
|
+
const keep = this.s.agent.status === "sent" || this.s.agent.status === "working" ? "" : this.s.agent.text;
|
|
144
|
+
this.s.agent = { status: "waiting", text: keep };
|
|
143
145
|
this.commit();
|
|
144
146
|
const tickMs2 = opts.tickMs ?? 3e4;
|
|
145
147
|
const started = Date.now();
|
|
@@ -302,12 +304,47 @@ function buildPayload(input) {
|
|
|
302
304
|
};
|
|
303
305
|
}
|
|
304
306
|
|
|
307
|
+
// src/core/settings.ts
|
|
308
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
309
|
+
import { dirname } from "node:path";
|
|
310
|
+
|
|
311
|
+
// src/core/types.ts
|
|
312
|
+
var THEMES = ["auto", "dark", "light", "frost"];
|
|
313
|
+
|
|
314
|
+
// src/core/settings.ts
|
|
315
|
+
function isTheme(v) {
|
|
316
|
+
return typeof v === "string" && THEMES.includes(v);
|
|
317
|
+
}
|
|
318
|
+
function readUserSettings(file) {
|
|
319
|
+
if (!existsSync2(file)) return {};
|
|
320
|
+
try {
|
|
321
|
+
const raw = JSON.parse(readFileSync2(file, "utf8"));
|
|
322
|
+
const out = {};
|
|
323
|
+
if (isTheme(raw.theme)) out.theme = raw.theme;
|
|
324
|
+
return out;
|
|
325
|
+
} catch (e) {
|
|
326
|
+
console.error("[cobro] settings.json\uC744 \uC77D\uC9C0 \uBABB\uD574 \uBB34\uC2DC\uD55C\uB2E4", e.message);
|
|
327
|
+
return {};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function writeUserSettings(file, patch) {
|
|
331
|
+
const next = { ...readUserSettings(file), ...patch };
|
|
332
|
+
mkdirSync2(dirname(file), { recursive: true });
|
|
333
|
+
const tmp = file + ".tmp";
|
|
334
|
+
writeFileSync2(tmp, JSON.stringify(next, null, 2) + "\n");
|
|
335
|
+
renameSync2(tmp, file);
|
|
336
|
+
return next;
|
|
337
|
+
}
|
|
338
|
+
|
|
305
339
|
// src/bridge.ts
|
|
306
340
|
async function createBridge(opts) {
|
|
307
341
|
const core = new SessionCore(opts.store);
|
|
342
|
+
let cachedTheme = opts.settingsFile ? readUserSettings(opts.settingsFile).theme : void 0;
|
|
343
|
+
const uiPrefs = () => ({ theme: opts.envTheme ?? cachedTheme ?? "auto", themeLocked: !!opts.envTheme });
|
|
344
|
+
const stateMsg = () => ({ type: "state", session: core.session, ui: uiPrefs() });
|
|
308
345
|
const channel = new ChannelServer({
|
|
309
346
|
token: opts.token,
|
|
310
|
-
onConnect: (reply) => reply(
|
|
347
|
+
onConnect: (reply) => reply(stateMsg()),
|
|
311
348
|
onMessage: (msg) => {
|
|
312
349
|
const bad = (why) => console.error(`[cobro] bridge: ${msg.type} \uBA54\uC2DC\uC9C0\uB97C \uBB34\uC2DC\uD55C\uB2E4 \u2014 ${why}`);
|
|
313
350
|
switch (msg.type) {
|
|
@@ -323,6 +360,16 @@ async function createBridge(opts) {
|
|
|
323
360
|
if (typeof msg.batchId !== "string") return bad("batchId\uAC00 \uBB38\uC790\uC5F4\uC774 \uC544\uB2C8\uB2E4");
|
|
324
361
|
core.markResolved(msg.batchId, msg.index, msg.missing);
|
|
325
362
|
break;
|
|
363
|
+
case "settings": {
|
|
364
|
+
if (!msg.patch || typeof msg.patch !== "object") return bad("patch\uAC00 \uC5C6\uB2E4");
|
|
365
|
+
if (!opts.settingsFile) return bad("settingsFile \uC5C6\uC74C");
|
|
366
|
+
if (opts.envTheme) return bad("COBRO_THEME\uB85C \uACE0\uC815\uB428");
|
|
367
|
+
if (!isTheme(msg.patch.theme)) return bad("theme \uAC12\uC774 \uC544\uB2C8\uB2E4");
|
|
368
|
+
const next = writeUserSettings(opts.settingsFile, { theme: msg.patch.theme });
|
|
369
|
+
cachedTheme = next.theme;
|
|
370
|
+
channel.broadcast(stateMsg());
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
326
373
|
case "send": {
|
|
327
374
|
if (!Array.isArray(msg.batchIds) || !msg.page || typeof msg.page.url !== "string") return bad("batchIds \uBC30\uC5F4\uC774\uB098 page.url\uC774 \uC5C6\uB2E4");
|
|
328
375
|
const page = msg.page;
|
|
@@ -358,13 +405,14 @@ async function createBridge(opts) {
|
|
|
358
405
|
}
|
|
359
406
|
}
|
|
360
407
|
});
|
|
361
|
-
core.on("change", (
|
|
408
|
+
core.on("change", () => channel.broadcast(stateMsg()));
|
|
362
409
|
const port = await channel.listen();
|
|
363
410
|
return {
|
|
364
411
|
core,
|
|
365
412
|
channel,
|
|
366
413
|
port,
|
|
367
414
|
token: opts.token,
|
|
415
|
+
ui: uiPrefs,
|
|
368
416
|
done(info) {
|
|
369
417
|
const out = core.done(info);
|
|
370
418
|
channel.broadcast({ type: "done", info, strategy: core.effectiveStrategy() });
|
|
@@ -375,7 +423,7 @@ async function createBridge(opts) {
|
|
|
375
423
|
}
|
|
376
424
|
|
|
377
425
|
// src/browser/launcher.ts
|
|
378
|
-
import { existsSync as
|
|
426
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
379
427
|
import { join as join2 } from "node:path";
|
|
380
428
|
import { chromium, webkit, firefox } from "playwright-core";
|
|
381
429
|
var INSTALL_HINT = "Chrome or Edge not found. Install Chrome, or set COBRO_BROWSER_CHANNEL (chrome|msedge|chromium). Bundled Chromium: npx playwright-core install chromium\nWebKit/Firefox engines: npx playwright-core install webkit firefox";
|
|
@@ -453,7 +501,7 @@ var BrowserLauncher = class {
|
|
|
453
501
|
}
|
|
454
502
|
}
|
|
455
503
|
if (!this.ctx) {
|
|
456
|
-
const lockExists =
|
|
504
|
+
const lockExists = existsSync3(join2(this.opts.profileDir, "lockfile")) || existsSync3(join2(this.opts.profileDir, "SingletonLock"));
|
|
457
505
|
if (classifyLaunchFailure(tried, lockExists) === "profile-locked") {
|
|
458
506
|
throw new Error(`The cobro browser profile is in use by another process: ${this.opts.profileDir}
|
|
459
507
|
Close the other session's cobro browser (close), or set COBRO_PROFILE_DIR to a different profile.
|
|
@@ -632,10 +680,11 @@ function startParentWatch(o) {
|
|
|
632
680
|
}
|
|
633
681
|
|
|
634
682
|
// src/server.ts
|
|
635
|
-
var here =
|
|
636
|
-
var overlaySource =
|
|
637
|
-
var { version } = JSON.parse(
|
|
683
|
+
var here = dirname2(fileURLToPath(import.meta.url));
|
|
684
|
+
var overlaySource = readFileSync3(join3(here, "overlay.js"), "utf8");
|
|
685
|
+
var { version } = JSON.parse(readFileSync3(join3(here, "..", "package.json"), "utf8"));
|
|
638
686
|
var stateDir = process.env.COBRO_STATE_DIR ?? join3(process.cwd(), ".cobro");
|
|
687
|
+
var settingsFile = join3(homedir(), ".cobro", "settings.json");
|
|
639
688
|
var engine = parseEngine(process.env.COBRO_BROWSER);
|
|
640
689
|
if (process.env.COBRO_BROWSER && engine !== process.env.COBRO_BROWSER) console.error(`[cobro] COBRO_BROWSER=${process.env.COBRO_BROWSER} \uBB34\uC2DC \u2014 chromium|webkit|firefox \uC911 \uD558\uB098. chromium \uC0AC\uC6A9`);
|
|
641
690
|
var profileDir = join3(process.env.COBRO_PROFILE_DIR ?? join3(homedir(), ".cobro", "profile"), engine);
|
|
@@ -647,13 +696,16 @@ var envInt = (v, min, name) => {
|
|
|
647
696
|
};
|
|
648
697
|
var defaultWaitSec = envInt(process.env.COBRO_WAIT_SEC, 5, "COBRO_WAIT_SEC") ?? 1800;
|
|
649
698
|
var tickMs = envInt(process.env.COBRO_TICK_MS, 1e3, "COBRO_TICK_MS");
|
|
699
|
+
var envThemeRaw = process.env.COBRO_THEME;
|
|
700
|
+
var envTheme = isTheme(envThemeRaw) ? envThemeRaw : void 0;
|
|
701
|
+
if (envThemeRaw && !envTheme) console.error(`[cobro] COBRO_THEME=${envThemeRaw} \uBB34\uC2DC \u2014 auto|dark|light|frost \uC911 \uD558\uB098`);
|
|
650
702
|
var token = randomBytes(24).toString("hex");
|
|
651
703
|
var store = new Store(stateDir);
|
|
652
704
|
var configStrategy = () => {
|
|
653
705
|
const file = join3(stateDir, "config.json");
|
|
654
|
-
if (!
|
|
706
|
+
if (!existsSync4(file)) return void 0;
|
|
655
707
|
try {
|
|
656
|
-
const v = JSON.parse(
|
|
708
|
+
const v = JSON.parse(readFileSync3(file, "utf8")).refreshStrategy;
|
|
657
709
|
if (v === "none" || v === "reload" || v === "event") return v;
|
|
658
710
|
if (v !== void 0) console.error(`[cobro] ${file}\uC758 refreshStrategy \uBB34\uC2DC \u2014 none|reload|event\uB9CC \uBC1B\uB294\uB2E4`);
|
|
659
711
|
} catch (e) {
|
|
@@ -670,6 +722,8 @@ var launcher = null;
|
|
|
670
722
|
var bridge = await createBridge({
|
|
671
723
|
store,
|
|
672
724
|
token,
|
|
725
|
+
settingsFile,
|
|
726
|
+
envTheme,
|
|
673
727
|
screenshot: async (b) => launcher?.isAlive() ? launcher.screenshot({ rect: union(b.elements.filter((e) => !e.missing).map((e) => e.rect)), outPath: store.shotPath(b.id) }) : void 0,
|
|
674
728
|
consoleEntries: () => launcher?.consoleEntries() ?? []
|
|
675
729
|
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cobro-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Co-browse for coding agents: pick elements in the browser, write a note, Send — the context lands in the agent's chat. MCP server with 6 tools.",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"mcp-server",
|
|
8
|
+
"claude-code",
|
|
9
|
+
"cursor",
|
|
10
|
+
"codex",
|
|
11
|
+
"browser",
|
|
12
|
+
"overlay",
|
|
13
|
+
"co-browse",
|
|
14
|
+
"ui-feedback",
|
|
15
|
+
"playwright"
|
|
16
|
+
],
|
|
6
17
|
"license": "Apache-2.0",
|
|
7
18
|
"type": "module",
|
|
8
19
|
"bin": {
|