@adhdev/daemon-core 0.6.53 → 0.6.55
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/dist/index.d.ts +76 -34
- package/dist/index.js +714 -271
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/providers/_builtin/_helpers/index.js +26 -26
- package/providers/_builtin/cli/aider-cli/provider.json +37 -0
- package/providers/_builtin/cli/aider-cli/scripts/1.0/detect_status.js +20 -0
- package/providers/_builtin/cli/aider-cli/scripts/1.0/parse_approval.js +10 -0
- package/providers/_builtin/cli/aider-cli/scripts/1.0/parse_output.js +49 -0
- package/providers/_builtin/cli/aider-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/cli/claude-cli/provider.json +9 -2
- package/providers/_builtin/cli/claude-cli/scripts/1.0/detect_status.js +31 -0
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_approval.js +38 -0
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_output.js +164 -0
- package/providers/_builtin/cli/claude-cli/scripts/1.0/scripts.js +42 -0
- package/providers/_builtin/cli/codex-cli/provider.json +9 -2
- package/providers/_builtin/cli/codex-cli/scripts/1.0/detect_status.js +20 -0
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_approval.js +15 -0
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_output.js +68 -0
- package/providers/_builtin/cli/codex-cli/scripts/1.0/scripts.js +11 -0
- package/providers/_builtin/cli/cursor-cli/provider.json +37 -0
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/detect_status.js +19 -0
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/parse_approval.js +10 -0
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/parse_output.js +48 -0
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/cli/gemini-cli/provider.json +9 -2
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/detect_status.js +26 -0
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/parse_approval.js +22 -0
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/parse_output.js +71 -0
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/scripts.js +12 -0
- package/providers/_builtin/cli/github-copilot-cli/provider.json +37 -0
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/detect_status.js +19 -0
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/parse_approval.js +9 -0
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/parse_output.js +48 -0
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/cli/goose-cli/provider.json +37 -0
- package/providers/_builtin/cli/goose-cli/scripts/1.0/detect_status.js +20 -0
- package/providers/_builtin/cli/goose-cli/scripts/1.0/parse_approval.js +10 -0
- package/providers/_builtin/cli/goose-cli/scripts/1.0/parse_output.js +48 -0
- package/providers/_builtin/cli/goose-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/cli/opencode-cli/provider.json +37 -0
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/detect_status.js +15 -0
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/parse_approval.js +9 -0
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/parse_output.js +48 -0
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/scripts.js +7 -0
- package/providers/_builtin/extension/cline/scripts/1.0/focus_editor.js +5 -5
- package/providers/_builtin/extension/cline/scripts/1.0/list_chats.js +11 -11
- package/providers/_builtin/extension/cline/scripts/1.0/list_models.js +6 -6
- package/providers/_builtin/extension/cline/scripts/1.0/list_modes.js +5 -5
- package/providers/_builtin/extension/cline/scripts/1.0/new_session.js +12 -12
- package/providers/_builtin/extension/cline/scripts/1.0/open_panel.js +7 -7
- package/providers/_builtin/extension/cline/scripts/1.0/read_chat.js +29 -29
- package/providers/_builtin/extension/cline/scripts/1.0/resolve_action.js +19 -19
- package/providers/_builtin/extension/cline/scripts/1.0/send_message.js +15 -15
- package/providers/_builtin/extension/cline/scripts/1.0/set_mode.js +4 -4
- package/providers/_builtin/extension/cline/scripts/1.0/set_model.js +4 -4
- package/providers/_builtin/extension/cline/scripts/1.0/switch_session.js +21 -21
- package/providers/_builtin/extension/codex/scripts/1.0/explore_controls_webview.js +2 -2
- package/providers/_builtin/extension/codex/scripts/1.0/list_models.js +1 -1
- package/providers/_builtin/extension/codex/scripts/1.0/list_modes.js +1 -1
- package/providers/_builtin/extension/codex/scripts/1.0/new_session.js +2 -2
- package/providers/_builtin/extension/codex/scripts/1.0/read_chat.js +6 -6
- package/providers/_builtin/extension/codex/scripts/1.0/resolve_action.js +3 -3
- package/providers/_builtin/extension/codex/scripts/1.0/set_model.js +1 -1
- package/providers/_builtin/ide/antigravity/scripts/1.0/focus_editor.js +2 -2
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_chats.js +19 -19
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_models.js +1 -1
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_modes.js +1 -1
- package/providers/_builtin/ide/antigravity/scripts/1.0/new_session.js +17 -17
- package/providers/_builtin/ide/antigravity/scripts/1.0/read_chat.js +41 -41
- package/providers/_builtin/ide/antigravity/scripts/1.0/resolve_action.js +6 -6
- package/providers/_builtin/ide/antigravity/scripts/1.0/send_message.js +13 -13
- package/providers/_builtin/ide/antigravity/scripts/1.0/set_model.js +1 -1
- package/providers/_builtin/ide/antigravity/scripts/1.0/switch_session.js +13 -13
- package/providers/_builtin/ide/cursor/scripts/1.0/dismiss_notification.js +3 -3
- package/providers/_builtin/ide/cursor/scripts/1.0/focus_editor.js +1 -1
- package/providers/_builtin/ide/cursor/scripts/1.0/list_models.js +12 -12
- package/providers/_builtin/ide/cursor/scripts/1.0/list_modes.js +5 -5
- package/providers/_builtin/ide/cursor/scripts/1.0/list_notifications.js +2 -2
- package/providers/_builtin/ide/cursor/scripts/1.0/list_sessions.js +5 -5
- package/providers/_builtin/ide/cursor/scripts/1.0/new_session.js +1 -1
- package/providers/_builtin/ide/cursor/scripts/1.0/open_panel.js +3 -3
- package/providers/_builtin/ide/cursor/scripts/1.0/read_chat.js +9 -9
- package/providers/_builtin/ide/cursor/scripts/1.0/resolve_action.js +4 -4
- package/providers/_builtin/ide/cursor/scripts/1.0/send_message.js +5 -5
- package/providers/_builtin/ide/cursor/scripts/1.0/set_mode.js +4 -4
- package/providers/_builtin/ide/cursor/scripts/1.0/set_model.js +12 -12
- package/providers/_builtin/ide/cursor/scripts/1.0/switch_session.js +2 -2
- package/providers/_builtin/ide/kiro/scripts/1.0/focus_editor.js +2 -2
- package/providers/_builtin/ide/kiro/scripts/1.0/open_panel.js +7 -7
- package/providers/_builtin/ide/kiro/scripts/1.0/resolve_action.js +3 -3
- package/providers/_builtin/ide/kiro/scripts/1.0/send_message.js +4 -4
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_list_sessions.js +2 -2
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_new_session.js +5 -5
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_read_chat.js +13 -13
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_resolve_action.js +1 -1
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_send_message.js +8 -8
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_set_mode.js +1 -1
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_set_model.js +1 -1
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_switch_session.js +3 -3
- package/providers/_builtin/ide/pearai/.tmp/after_rich.json +157 -0
- package/providers/_builtin/ide/pearai/.tmp/after_rich_raw.json +161 -0
- package/providers/_builtin/ide/pearai/.tmp/after_switch.json +592 -0
- package/providers/_builtin/ide/pearai/.tmp/after_switch_raw.json +596 -0
- package/providers/_builtin/ide/pearai/.tmp/home_dump_raw.json +176 -0
- package/providers/_builtin/ide/pearai/.tmp/items_raw.json +778 -0
- package/providers/_builtin/ide/pearai/.tmp/webview_dump.json +157 -0
- package/providers/_builtin/ide/pearai/.tmp/webview_dump_raw.json +161 -0
- package/providers/_builtin/ide/pearai/provider.json +1 -3
- package/providers/_builtin/ide/pearai/scripts/1.0/focus_editor.js +12 -16
- package/providers/_builtin/ide/pearai/scripts/1.0/list_models.js +45 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/list_modes.js +44 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/list_sessions.js +82 -27
- package/providers/_builtin/ide/pearai/scripts/1.0/new_session.js +26 -43
- package/providers/_builtin/ide/pearai/scripts/1.0/open_panel.js +10 -33
- package/providers/_builtin/ide/pearai/scripts/1.0/read_chat.js +169 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/resolve_action.js +47 -41
- package/providers/_builtin/ide/pearai/scripts/1.0/scripts.js +36 -7
- package/providers/_builtin/ide/pearai/scripts/1.0/send_message.js +97 -22
- package/providers/_builtin/ide/pearai/scripts/1.0/set_mode.js +51 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/set_model.js +54 -0
- package/providers/_builtin/ide/pearai/scripts/1.0/switch_session.js +81 -0
- package/providers/_builtin/ide/trae/scripts/1.0/focus_editor.js +2 -2
- package/providers/_builtin/ide/trae/scripts/1.0/list_chats.js +2 -2
- package/providers/_builtin/ide/trae/scripts/1.0/new_session.js +4 -4
- package/providers/_builtin/ide/trae/scripts/1.0/open_panel.js +6 -6
- package/providers/_builtin/ide/trae/scripts/1.0/read_chat.js +13 -13
- package/providers/_builtin/ide/trae/scripts/1.0/resolve_action.js +3 -3
- package/providers/_builtin/ide/trae/scripts/1.0/send_message.js +11 -11
- package/providers/_builtin/ide/trae/scripts/1.0/switch_session.js +2 -2
- package/providers/_builtin/ide/windsurf/scripts/1.0/focus_editor.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_chats.js +4 -4
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_sessions.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0/new_session.js +9 -9
- package/providers/_builtin/ide/windsurf/scripts/1.0/open_panel.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0/resolve_action.js +8 -8
- package/providers/_builtin/ide/windsurf/scripts/1.0/switch_session.js +8 -8
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/focus_editor.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/list_chats.js +12 -12
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/new_session.js +15 -15
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/open_panel.js +10 -10
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/read_chat.js +33 -33
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/resolve_action.js +6 -6
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/send_message.js +16 -16
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/switch_session.js +7 -7
- package/providers/_builtin/registry.json +76 -3
- package/src/cli-adapters/provider-cli-adapter.ts +267 -251
- package/src/cli-adapters/terminal-screen.ts +268 -0
- package/src/commands/chat-commands.ts +41 -15
- package/src/commands/cli-manager.ts +4 -2
- package/src/daemon/dev-server.ts +245 -35
- package/src/providers/acp-provider-instance.ts +1 -1
- package/src/providers/cli-provider-instance.ts +21 -8
- package/src/providers/provider-loader.ts +3 -2
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_list_models.js +0 -43
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_list_modes.js +0 -35
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_list_sessions.js +0 -62
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_new_session.js +0 -49
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_read_chat.js +0 -92
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_resolve_action.js +0 -59
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_send_message.js +0 -72
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_set_mode.js +0 -36
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_set_model.js +0 -36
- package/providers/_builtin/ide/pearai/scripts/1.0/webview_switch_session.js +0 -34
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PearAI — webview_read_chat (webview iframe 내부에서 실행)
|
|
3
|
-
*
|
|
4
|
-
* PearAI는 Roo Code / Cline 기반의 Agent 패널을 사용.
|
|
5
|
-
* React로 렌더링된 DOM에서 메시지를 파싱.
|
|
6
|
-
*
|
|
7
|
-
* DOM 단서:
|
|
8
|
-
* - textarea.chat-text-area: 입력 필드
|
|
9
|
-
* - Task: ... : 유저 메시지
|
|
10
|
-
* - API Request 등: 시스템 메시지
|
|
11
|
-
*
|
|
12
|
-
* 반환: ReadChatResult { id, status, messages, inputContent? }
|
|
13
|
-
*/
|
|
14
|
-
(() => {
|
|
15
|
-
try {
|
|
16
|
-
const messages = [];
|
|
17
|
-
|
|
18
|
-
// 메시지 블록 찾기 — 다양한 셀렉터 시도
|
|
19
|
-
// Cline/Roo Code 기반이므로 유사한 구조
|
|
20
|
-
const allText = document.body?.textContent || '';
|
|
21
|
-
|
|
22
|
-
// Task 헤더에서 유저 메시지
|
|
23
|
-
const taskEl = document.querySelector('[class*="task-header"], [class*="TaskHeader"]');
|
|
24
|
-
if (taskEl) {
|
|
25
|
-
const taskText = taskEl.textContent?.trim() || '';
|
|
26
|
-
if (taskText) {
|
|
27
|
-
messages.push({ role: 'user', content: taskText.replace(/^Task:\s*/i, ''), index: 0 });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// 채팅 메시지 영역 파싱 — 공통 클래스
|
|
32
|
-
const chatMessages = document.querySelectorAll('[class*="chat-row"], [class*="ChatRow"], [class*="message-row"], [class*="MessageRow"]');
|
|
33
|
-
chatMessages.forEach((msg, idx) => {
|
|
34
|
-
const text = msg.textContent?.trim() || '';
|
|
35
|
-
if (!text) return;
|
|
36
|
-
|
|
37
|
-
// role 판정 — 클래스명이나 아이콘으로
|
|
38
|
-
const isUser = msg.querySelector('[class*="user"]') != null || msg.classList.toString().includes('user');
|
|
39
|
-
messages.push({
|
|
40
|
-
role: isUser ? 'user' : 'assistant',
|
|
41
|
-
content: text.substring(0, 2000),
|
|
42
|
-
index: idx,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// 메시지가 없으면 전체 텍스트에서 추출
|
|
47
|
-
if (messages.length === 0 && allText.length > 50) {
|
|
48
|
-
// Task: 패턴 찾기
|
|
49
|
-
const taskMatch = allText.match(/Task:\s*(.+?)(?:\d+[\d.,]*k|\d+\s*$)/s);
|
|
50
|
-
if (taskMatch) {
|
|
51
|
-
messages.push({ role: 'user', content: taskMatch[1].trim().substring(0, 500), index: 0 });
|
|
52
|
-
}
|
|
53
|
-
// AI 응답 찾기 (간략화)
|
|
54
|
-
const bodyContent = allText.substring(0, 2000);
|
|
55
|
-
if (bodyContent.includes('API Request') || bodyContent.includes('Initial Checkpoint')) {
|
|
56
|
-
// 응답이 있음을 표시
|
|
57
|
-
messages.push({ role: 'assistant', content: '(response in progress or completed)', index: 1 });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 상태 감지
|
|
62
|
-
let status = 'idle';
|
|
63
|
-
const cancelBtn = document.querySelector('button[class*="cancel"], [aria-label*="cancel" i]');
|
|
64
|
-
if (cancelBtn && cancelBtn.offsetWidth > 0 && cancelBtn.textContent?.toLowerCase().includes('cancel')) {
|
|
65
|
-
status = 'generating';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// API Request... (로딩) → generating
|
|
69
|
-
const loadingEl = document.querySelector('[class*="loading"], [class*="spinner"]');
|
|
70
|
-
if (loadingEl && loadingEl.offsetWidth > 0) {
|
|
71
|
-
status = 'generating';
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// "Retrying" → error/generating
|
|
75
|
-
if (allText.includes('Retrying in') || allText.includes('Retry attempt')) {
|
|
76
|
-
status = 'generating';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 입력 필드
|
|
80
|
-
const textarea = document.querySelector('textarea[placeholder*="Type"], textarea.chat-text-area, textarea');
|
|
81
|
-
const inputContent = textarea ? textarea.value || textarea.textContent?.trim() : '';
|
|
82
|
-
|
|
83
|
-
return JSON.stringify({
|
|
84
|
-
id: 'pearai-agent',
|
|
85
|
-
status,
|
|
86
|
-
messages,
|
|
87
|
-
inputContent: inputContent || undefined,
|
|
88
|
-
});
|
|
89
|
-
} catch (e) {
|
|
90
|
-
return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
|
|
91
|
-
}
|
|
92
|
-
})()
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PearAI — webview_resolve_action
|
|
3
|
-
*
|
|
4
|
-
* PearAI Agent(Roo Code 기반)는 승인/거절 버튼을 webview 내부에 렌더링함.
|
|
5
|
-
* 버튼을 찾아 직접 click() 이벤트 발생.
|
|
6
|
-
*
|
|
7
|
-
* 파라미터: ${ BUTTON_TEXT }
|
|
8
|
-
*/
|
|
9
|
-
(() => {
|
|
10
|
-
try {
|
|
11
|
-
const want = ${ BUTTON_TEXT };
|
|
12
|
-
const wantNorm = (want || '').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
13
|
-
|
|
14
|
-
function norm(t) { return (t || '').replace(/\s+/g, ' ').trim().toLowerCase(); }
|
|
15
|
-
|
|
16
|
-
function matches(el) {
|
|
17
|
-
const t = norm(el.textContent);
|
|
18
|
-
if (!t || t.length > 80) return false;
|
|
19
|
-
if (t === wantNorm) return true;
|
|
20
|
-
if (t.indexOf(wantNorm) === 0) return true;
|
|
21
|
-
if (wantNorm.indexOf(t) >= 0 && t.length > 2) return true;
|
|
22
|
-
if (/^(run|approve|allow|accept|yes)\b/.test(wantNorm)) {
|
|
23
|
-
if (/^(run|allow|accept|approve)\b/.test(t)) return true;
|
|
24
|
-
}
|
|
25
|
-
if (/^(reject|deny|no|abort)\b/.test(wantNorm)) {
|
|
26
|
-
if (/^(reject|deny)\b/.test(t)) return true;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const sel = 'button, [role="button"], .vsc-button';
|
|
32
|
-
const allBtns = [...document.querySelectorAll(sel)].filter(b => b.offsetWidth > 0 && b.offsetHeight > 0);
|
|
33
|
-
|
|
34
|
-
let found = null;
|
|
35
|
-
for (let i = allBtns.length - 1; i >= 0; i--) {
|
|
36
|
-
if (matches(allBtns[i])) { found = allBtns[i]; break; }
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (found) {
|
|
40
|
-
found.focus?.();
|
|
41
|
-
const rect = found.getBoundingClientRect();
|
|
42
|
-
const x = rect.left + rect.width / 2;
|
|
43
|
-
const y = rect.top + rect.height / 2;
|
|
44
|
-
for (const type of ['pointerdown', 'mousedown', 'pointerup', 'mouseup', 'click']) {
|
|
45
|
-
found.dispatchEvent(new PointerEvent(type, {
|
|
46
|
-
bubbles: true, cancelable: true, view: window,
|
|
47
|
-
clientX: x, clientY: y, pointerId: 1, pointerType: 'mouse'
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
return JSON.stringify({
|
|
51
|
-
resolved: true,
|
|
52
|
-
clicked: found.textContent || wantNorm
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return JSON.stringify({ resolved: false, error: 'Button not found: ' + wantNorm });
|
|
56
|
-
} catch (e) {
|
|
57
|
-
return JSON.stringify({ resolved: false, error: e.message });
|
|
58
|
-
}
|
|
59
|
-
})()
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kiro — webview_send_message (webview iframe 내부에서 실행)
|
|
3
|
-
*
|
|
4
|
-
* Kiro의 채팅 입력은 webview iframe 안의 ProseMirror/tiptap 에디터.
|
|
5
|
-
* execCommand('insertText') + Enter 키 이벤트로 메시지 전송.
|
|
6
|
-
*
|
|
7
|
-
* 파라미터: ${ MESSAGE }
|
|
8
|
-
*/
|
|
9
|
-
(async () => {
|
|
10
|
-
try {
|
|
11
|
-
const msg = ${ MESSAGE };
|
|
12
|
-
|
|
13
|
-
// ─── 1. 입력 필드 찾기 ───
|
|
14
|
-
const editor =
|
|
15
|
-
document.querySelector('.tiptap.ProseMirror') ||
|
|
16
|
-
document.querySelector('[contenteditable="true"]') ||
|
|
17
|
-
document.querySelector('textarea');
|
|
18
|
-
|
|
19
|
-
if (!editor) return JSON.stringify({ sent: false, error: 'no input found in webview' });
|
|
20
|
-
|
|
21
|
-
const isTextarea = editor.tagName === 'TEXTAREA';
|
|
22
|
-
|
|
23
|
-
if (isTextarea) {
|
|
24
|
-
editor.focus();
|
|
25
|
-
const nativeSetter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')?.set;
|
|
26
|
-
if (nativeSetter) nativeSetter.call(editor, msg);
|
|
27
|
-
else editor.value = msg;
|
|
28
|
-
editor.dispatchEvent(new Event('input', { bubbles: true }));
|
|
29
|
-
await new Promise(r => setTimeout(r, 300));
|
|
30
|
-
|
|
31
|
-
const enterOpts = { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true, cancelable: true, composed: true };
|
|
32
|
-
editor.dispatchEvent(new KeyboardEvent('keydown', enterOpts));
|
|
33
|
-
editor.dispatchEvent(new KeyboardEvent('keypress', enterOpts));
|
|
34
|
-
editor.dispatchEvent(new KeyboardEvent('keyup', enterOpts));
|
|
35
|
-
return JSON.stringify({ sent: true });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ─── 2. contenteditable (ProseMirror / tiptap) ───
|
|
39
|
-
editor.focus();
|
|
40
|
-
await new Promise(r => setTimeout(r, 100));
|
|
41
|
-
|
|
42
|
-
// 전체 선택 + 삭제 + 삽입
|
|
43
|
-
const sel = window.getSelection();
|
|
44
|
-
const range = document.createRange();
|
|
45
|
-
range.selectNodeContents(editor);
|
|
46
|
-
sel.removeAllRanges();
|
|
47
|
-
sel.addRange(range);
|
|
48
|
-
await new Promise(r => setTimeout(r, 50));
|
|
49
|
-
|
|
50
|
-
document.execCommand('delete', false, null);
|
|
51
|
-
await new Promise(r => setTimeout(r, 50));
|
|
52
|
-
document.execCommand('insertText', false, msg);
|
|
53
|
-
|
|
54
|
-
editor.dispatchEvent(new Event('input', { bubbles: true }));
|
|
55
|
-
await new Promise(r => setTimeout(r, 400));
|
|
56
|
-
|
|
57
|
-
// ─── 3. Enter 키 전송 ───
|
|
58
|
-
const enterOpts = {
|
|
59
|
-
key: 'Enter', code: 'Enter',
|
|
60
|
-
keyCode: 13, which: 13,
|
|
61
|
-
bubbles: true, cancelable: true, composed: true,
|
|
62
|
-
};
|
|
63
|
-
editor.dispatchEvent(new KeyboardEvent('keydown', enterOpts));
|
|
64
|
-
await new Promise(r => setTimeout(r, 50));
|
|
65
|
-
editor.dispatchEvent(new KeyboardEvent('keypress', enterOpts));
|
|
66
|
-
editor.dispatchEvent(new KeyboardEvent('keyup', enterOpts));
|
|
67
|
-
|
|
68
|
-
return JSON.stringify({ sent: true });
|
|
69
|
-
} catch (e) {
|
|
70
|
-
return JSON.stringify({ sent: false, error: e.message });
|
|
71
|
-
}
|
|
72
|
-
})()
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cline — set_mode
|
|
3
|
-
* 모드 selector에서 지정된 모드 선택
|
|
4
|
-
* ${MODE} → JSON.stringify(modeName)
|
|
5
|
-
* → { success: boolean }
|
|
6
|
-
*/
|
|
7
|
-
(async () => {
|
|
8
|
-
try {
|
|
9
|
-
const inner = document.querySelector('iframe');
|
|
10
|
-
const doc = inner?.contentDocument || inner?.contentWindow?.document;
|
|
11
|
-
if (!doc) return JSON.stringify({ success: false, error: 'no doc' });
|
|
12
|
-
|
|
13
|
-
const target = ${MODE};
|
|
14
|
-
const trigger = doc.querySelector('[data-testid="mode-selector-trigger"], [data-testid="mode-switch"]');
|
|
15
|
-
if (!trigger) return JSON.stringify({ success: false, error: 'no mode trigger' });
|
|
16
|
-
|
|
17
|
-
// 드롭다운 열기
|
|
18
|
-
trigger.click();
|
|
19
|
-
await new Promise(r => setTimeout(r, 300));
|
|
20
|
-
|
|
21
|
-
// 옵션에서 타겟 모드 찾기
|
|
22
|
-
const options = doc.querySelectorAll('[data-testid*="mode-option"], [role="option"], [class*="dropdown"] [class*="item"], [class*="listbox"] [class*="option"]');
|
|
23
|
-
for (const opt of options) {
|
|
24
|
-
const text = (opt.textContent || '').trim();
|
|
25
|
-
if (text === target || text.toLowerCase().includes(target.toLowerCase())) {
|
|
26
|
-
opt.click();
|
|
27
|
-
await new Promise(r => setTimeout(r, 200));
|
|
28
|
-
return JSON.stringify({ success: true, mode: text });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 닫기
|
|
33
|
-
doc.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
|
|
34
|
-
return JSON.stringify({ success: false, error: 'mode not found: ' + target });
|
|
35
|
-
} catch (e) { return JSON.stringify({ success: false, error: e.message }); }
|
|
36
|
-
})()
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cline — set_model
|
|
3
|
-
* 드롭다운에서 지정된 모델 선택
|
|
4
|
-
* ${MODEL} → JSON.stringify(modelName)
|
|
5
|
-
* → { success: boolean }
|
|
6
|
-
*/
|
|
7
|
-
(async () => {
|
|
8
|
-
try {
|
|
9
|
-
const inner = document.querySelector('iframe');
|
|
10
|
-
const doc = inner?.contentDocument || inner?.contentWindow?.document;
|
|
11
|
-
if (!doc) return JSON.stringify({ success: false, error: 'no doc' });
|
|
12
|
-
|
|
13
|
-
const target = ${MODEL};
|
|
14
|
-
const trigger = doc.querySelector('[data-testid="model-selector"], [data-testid*="model-dropdown"], [data-testid="dropdown-trigger"]');
|
|
15
|
-
if (!trigger) return JSON.stringify({ success: false, error: 'no model trigger' });
|
|
16
|
-
|
|
17
|
-
// 드롭다운 열기
|
|
18
|
-
trigger.click();
|
|
19
|
-
await new Promise(r => setTimeout(r, 300));
|
|
20
|
-
|
|
21
|
-
// 옵션에서 타겟 모델 찾기
|
|
22
|
-
const options = doc.querySelectorAll('[data-testid*="dropdown-option"], [role="option"], [class*="dropdown"] [class*="item"], [class*="listbox"] [class*="option"]');
|
|
23
|
-
for (const opt of options) {
|
|
24
|
-
const text = (opt.textContent || '').trim();
|
|
25
|
-
if (text === target || text.includes(target)) {
|
|
26
|
-
opt.click();
|
|
27
|
-
await new Promise(r => setTimeout(r, 200));
|
|
28
|
-
return JSON.stringify({ success: true, model: text });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 닫기
|
|
33
|
-
doc.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
|
|
34
|
-
return JSON.stringify({ success: false, error: 'model not found: ' + target });
|
|
35
|
-
} catch (e) { return JSON.stringify({ success: false, error: e.message }); }
|
|
36
|
-
})()
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PearAI — webview_switch_session (webview iframe 내부에서 실행)
|
|
3
|
-
*
|
|
4
|
-
* data-testid="task-item-{UUID}" 항목을 클릭하여 세션 전환.
|
|
5
|
-
* SESSION_ID는 task UUID 형태 (예: "51a08aba-1078-410c-a601-0e859205b12c")
|
|
6
|
-
*/
|
|
7
|
-
(() => {
|
|
8
|
-
try {
|
|
9
|
-
const targetId = ${SESSION_ID};
|
|
10
|
-
|
|
11
|
-
// ─── UUID 기반 매칭 ───
|
|
12
|
-
const selector = '[data-testid="task-item-' + targetId + '"]';
|
|
13
|
-
const targetItem = document.querySelector(selector);
|
|
14
|
-
if (targetItem) {
|
|
15
|
-
targetItem.click();
|
|
16
|
-
return JSON.stringify({ switched: true, id: targetId });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// ─── 인덱스 기반 fallback (숫자로 전달된 경우) ───
|
|
20
|
-
const index = parseInt(targetId, 10);
|
|
21
|
-
if (!isNaN(index)) {
|
|
22
|
-
const allItems = document.querySelectorAll('[data-testid^="task-item-"]');
|
|
23
|
-
if (allItems[index]) {
|
|
24
|
-
allItems[index].click();
|
|
25
|
-
const taskId = (allItems[index].getAttribute('data-testid') || '').replace('task-item-', '');
|
|
26
|
-
return JSON.stringify({ switched: true, id: taskId, method: 'index' });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return JSON.stringify({ switched: false, error: 'Task item not found: ' + targetId });
|
|
31
|
-
} catch (e) {
|
|
32
|
-
return JSON.stringify({ switched: false, error: e.message });
|
|
33
|
-
}
|
|
34
|
-
})()
|