@adhdev/daemon-core 0.6.58 → 0.6.60
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 +1 -1
- package/dist/index.js +87 -89
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/detection/ide-detector.ts +1 -1
- package/src/providers/provider-loader.ts +3 -6
- package/providers/_builtin/.github/workflows/generate-registry.yml +0 -76
- package/providers/_builtin/COMPATIBILITY.md +0 -217
- package/providers/_builtin/CONTRIBUTING.md +0 -200
- package/providers/_builtin/README.md +0 -119
- package/providers/_builtin/_helpers/index.js +0 -188
- package/providers/_builtin/acp/agentpool/provider.json +0 -54
- package/providers/_builtin/acp/amp/provider.json +0 -52
- package/providers/_builtin/acp/auggie/provider.json +0 -57
- package/providers/_builtin/acp/autodev/provider.json +0 -54
- package/providers/_builtin/acp/autohand/provider.json +0 -52
- package/providers/_builtin/acp/blackbox-ai/provider.json +0 -54
- package/providers/_builtin/acp/claude-agent/provider.json +0 -57
- package/providers/_builtin/acp/cline-acp/provider.json +0 -54
- package/providers/_builtin/acp/codebuddy/provider.json +0 -54
- package/providers/_builtin/acp/codex-cli/provider.json +0 -57
- package/providers/_builtin/acp/corust-agent/provider.json +0 -52
- package/providers/_builtin/acp/crow-cli/provider.json +0 -54
- package/providers/_builtin/acp/cursor-acp/provider.json +0 -54
- package/providers/_builtin/acp/deepagents/provider.json +0 -52
- package/providers/_builtin/acp/dimcode/provider.json +0 -54
- package/providers/_builtin/acp/docker-cagent/provider.json +0 -57
- package/providers/_builtin/acp/factory-droid/provider.json +0 -60
- package/providers/_builtin/acp/fast-agent/provider.json +0 -52
- package/providers/_builtin/acp/gemini-cli/provider.json +0 -114
- package/providers/_builtin/acp/github-copilot/provider.json +0 -54
- package/providers/_builtin/acp/goose/provider.json +0 -57
- package/providers/_builtin/acp/junie/provider.json +0 -52
- package/providers/_builtin/acp/kilo/provider.json +0 -54
- package/providers/_builtin/acp/kimi-cli/provider.json +0 -57
- package/providers/_builtin/acp/minion-code/provider.json +0 -52
- package/providers/_builtin/acp/mistral-vibe/provider.json +0 -57
- package/providers/_builtin/acp/nova/provider.json +0 -54
- package/providers/_builtin/acp/openclaw/provider.json +0 -54
- package/providers/_builtin/acp/opencode/provider.json +0 -52
- package/providers/_builtin/acp/openhands/provider.json +0 -54
- package/providers/_builtin/acp/pi-acp/provider.json +0 -52
- package/providers/_builtin/acp/qoder/provider.json +0 -54
- package/providers/_builtin/acp/qwen-code/provider.json +0 -60
- package/providers/_builtin/acp/stakpak/provider.json +0 -54
- package/providers/_builtin/acp/vtcode/provider.json +0 -54
- package/providers/_builtin/cli/aider-cli/provider.json +0 -37
- package/providers/_builtin/cli/aider-cli/scripts/1.0/detect_status.js +0 -20
- package/providers/_builtin/cli/aider-cli/scripts/1.0/parse_approval.js +0 -10
- package/providers/_builtin/cli/aider-cli/scripts/1.0/parse_output.js +0 -97
- package/providers/_builtin/cli/aider-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/cli/claude-cli/provider.json +0 -121
- package/providers/_builtin/cli/claude-cli/scripts/1.0/detect_status.js +0 -83
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_approval.js +0 -97
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_output.js +0 -417
- package/providers/_builtin/cli/claude-cli/scripts/1.0/scripts.js +0 -42
- package/providers/_builtin/cli/codex-cli/provider.json +0 -90
- package/providers/_builtin/cli/codex-cli/scripts/1.0/detect_status.js +0 -54
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_approval.js +0 -91
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_output.js +0 -522
- package/providers/_builtin/cli/codex-cli/scripts/1.0/scripts.js +0 -11
- package/providers/_builtin/cli/cursor-cli/provider.json +0 -37
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/detect_status.js +0 -19
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/parse_approval.js +0 -10
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/parse_output.js +0 -48
- package/providers/_builtin/cli/cursor-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/cli/gemini-cli/provider.json +0 -109
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/detect_status.js +0 -26
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/parse_approval.js +0 -22
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/parse_output.js +0 -71
- package/providers/_builtin/cli/gemini-cli/scripts/1.0/scripts.js +0 -12
- package/providers/_builtin/cli/github-copilot-cli/provider.json +0 -37
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/detect_status.js +0 -19
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/parse_approval.js +0 -9
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/parse_output.js +0 -48
- package/providers/_builtin/cli/github-copilot-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/cli/goose-cli/provider.json +0 -37
- package/providers/_builtin/cli/goose-cli/scripts/1.0/detect_status.js +0 -20
- package/providers/_builtin/cli/goose-cli/scripts/1.0/parse_approval.js +0 -10
- package/providers/_builtin/cli/goose-cli/scripts/1.0/parse_output.js +0 -48
- package/providers/_builtin/cli/goose-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/cli/opencode-cli/provider.json +0 -37
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/detect_status.js +0 -15
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/parse_approval.js +0 -9
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/parse_output.js +0 -48
- package/providers/_builtin/cli/opencode-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/docs/CDP_SELECTOR_GUIDE.md +0 -370
- package/providers/_builtin/docs/PROVIDER_GUIDE.md +0 -916
- package/providers/_builtin/extension/cline/provider.json +0 -37
- package/providers/_builtin/extension/cline/scripts/1.0/focus_editor.js +0 -48
- package/providers/_builtin/extension/cline/scripts/1.0/list_chats.js +0 -100
- package/providers/_builtin/extension/cline/scripts/1.0/list_models.js +0 -43
- package/providers/_builtin/extension/cline/scripts/1.0/list_modes.js +0 -35
- package/providers/_builtin/extension/cline/scripts/1.0/new_session.js +0 -85
- package/providers/_builtin/extension/cline/scripts/1.0/open_panel.js +0 -25
- package/providers/_builtin/extension/cline/scripts/1.0/read_chat.js +0 -270
- package/providers/_builtin/extension/cline/scripts/1.0/resolve_action.js +0 -83
- package/providers/_builtin/extension/cline/scripts/1.0/scripts.js +0 -82
- package/providers/_builtin/extension/cline/scripts/1.0/send_message.js +0 -95
- package/providers/_builtin/extension/cline/scripts/1.0/set_mode.js +0 -36
- package/providers/_builtin/extension/cline/scripts/1.0/set_model.js +0 -36
- package/providers/_builtin/extension/cline/scripts/1.0/switch_session.js +0 -206
- package/providers/_builtin/extension/codex/provider.json +0 -38
- package/providers/_builtin/extension/codex/scripts/1.0/click_conversation_webview.js +0 -24
- package/providers/_builtin/extension/codex/scripts/1.0/explore_chat_webview.js +0 -110
- package/providers/_builtin/extension/codex/scripts/1.0/explore_controls_webview.js +0 -75
- package/providers/_builtin/extension/codex/scripts/1.0/explore_dom.js +0 -58
- package/providers/_builtin/extension/codex/scripts/1.0/explore_dropdown_webview.js +0 -64
- package/providers/_builtin/extension/codex/scripts/1.0/inspect_code_webview.js +0 -55
- package/providers/_builtin/extension/codex/scripts/1.0/list_models.js +0 -63
- package/providers/_builtin/extension/codex/scripts/1.0/list_modes.js +0 -140
- package/providers/_builtin/extension/codex/scripts/1.0/message_structure_webview.js +0 -79
- package/providers/_builtin/extension/codex/scripts/1.0/new_session.js +0 -26
- package/providers/_builtin/extension/codex/scripts/1.0/read_chat.js +0 -516
- package/providers/_builtin/extension/codex/scripts/1.0/resolve_action.js +0 -82
- package/providers/_builtin/extension/codex/scripts/1.0/send_message.js +0 -42
- package/providers/_builtin/extension/codex/scripts/1.0/set_mode.js +0 -165
- package/providers/_builtin/extension/codex/scripts/1.0/set_model.js +0 -86
- package/providers/_builtin/extension/roo-code/provider.json +0 -37
- package/providers/_builtin/extension/roo-code/scripts/1.0/scripts.js +0 -82
- package/providers/_builtin/ide/antigravity/provider.json +0 -88
- package/providers/_builtin/ide/antigravity/scripts/1.0/focus_editor.js +0 -20
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_chats.js +0 -137
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_models.js +0 -61
- package/providers/_builtin/ide/antigravity/scripts/1.0/list_modes.js +0 -72
- package/providers/_builtin/ide/antigravity/scripts/1.0/new_session.js +0 -75
- package/providers/_builtin/ide/antigravity/scripts/1.0/read_chat.js +0 -352
- package/providers/_builtin/ide/antigravity/scripts/1.0/resolve_action.js +0 -63
- package/providers/_builtin/ide/antigravity/scripts/1.0/scripts.js +0 -67
- package/providers/_builtin/ide/antigravity/scripts/1.0/send_message.js +0 -56
- package/providers/_builtin/ide/antigravity/scripts/1.0/set_mode.js +0 -67
- package/providers/_builtin/ide/antigravity/scripts/1.0/set_model.js +0 -72
- package/providers/_builtin/ide/antigravity/scripts/1.0/switch_session.js +0 -114
- package/providers/_builtin/ide/cursor/provider.json +0 -70
- package/providers/_builtin/ide/cursor/scripts/1.0/dismiss_notification.js +0 -30
- package/providers/_builtin/ide/cursor/scripts/1.0/focus_editor.js +0 -13
- package/providers/_builtin/ide/cursor/scripts/1.0/list_models.js +0 -78
- package/providers/_builtin/ide/cursor/scripts/1.0/list_modes.js +0 -40
- package/providers/_builtin/ide/cursor/scripts/1.0/list_notifications.js +0 -23
- package/providers/_builtin/ide/cursor/scripts/1.0/list_sessions.js +0 -42
- package/providers/_builtin/ide/cursor/scripts/1.0/new_session.js +0 -20
- package/providers/_builtin/ide/cursor/scripts/1.0/open_panel.js +0 -23
- package/providers/_builtin/ide/cursor/scripts/1.0/read_chat.js +0 -318
- package/providers/_builtin/ide/cursor/scripts/1.0/resolve_action.js +0 -19
- package/providers/_builtin/ide/cursor/scripts/1.0/scripts.js +0 -78
- package/providers/_builtin/ide/cursor/scripts/1.0/send_message.js +0 -23
- package/providers/_builtin/ide/cursor/scripts/1.0/set_mode.js +0 -38
- package/providers/_builtin/ide/cursor/scripts/1.0/set_model.js +0 -81
- package/providers/_builtin/ide/cursor/scripts/1.0/switch_session.js +0 -28
- package/providers/_builtin/ide/kiro/provider.json +0 -68
- package/providers/_builtin/ide/kiro/scripts/1.0/focus_editor.js +0 -20
- package/providers/_builtin/ide/kiro/scripts/1.0/open_panel.js +0 -47
- package/providers/_builtin/ide/kiro/scripts/1.0/resolve_action.js +0 -54
- package/providers/_builtin/ide/kiro/scripts/1.0/send_message.js +0 -29
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_dump_html.js +0 -1
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_list_models.js +0 -42
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_list_modes.js +0 -22
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_list_sessions.js +0 -21
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_new_session.js +0 -34
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_read_chat.js +0 -161
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_resolve_action.js +0 -62
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_send_message.js +0 -94
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_set_mode.js +0 -34
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_set_model.js +0 -47
- package/providers/_builtin/ide/kiro/scripts/1.0/webview_switch_session.js +0 -26
- package/providers/_builtin/ide/pearai/.tmp/after_rich.json +0 -157
- package/providers/_builtin/ide/pearai/.tmp/after_rich_raw.json +0 -161
- package/providers/_builtin/ide/pearai/.tmp/after_switch.json +0 -592
- package/providers/_builtin/ide/pearai/.tmp/after_switch_raw.json +0 -596
- package/providers/_builtin/ide/pearai/.tmp/home_dump_raw.json +0 -176
- package/providers/_builtin/ide/pearai/.tmp/items_raw.json +0 -778
- package/providers/_builtin/ide/pearai/.tmp/webview_dump.json +0 -157
- package/providers/_builtin/ide/pearai/.tmp/webview_dump_raw.json +0 -161
- package/providers/_builtin/ide/pearai/provider.json +0 -71
- package/providers/_builtin/ide/pearai/scripts/1.0/focus_editor.js +0 -16
- package/providers/_builtin/ide/pearai/scripts/1.0/list_models.js +0 -45
- package/providers/_builtin/ide/pearai/scripts/1.0/list_modes.js +0 -44
- package/providers/_builtin/ide/pearai/scripts/1.0/list_sessions.js +0 -93
- package/providers/_builtin/ide/pearai/scripts/1.0/new_session.js +0 -38
- package/providers/_builtin/ide/pearai/scripts/1.0/open_panel.js +0 -23
- package/providers/_builtin/ide/pearai/scripts/1.0/read_chat.js +0 -169
- package/providers/_builtin/ide/pearai/scripts/1.0/resolve_action.js +0 -60
- package/providers/_builtin/ide/pearai/scripts/1.0/scripts.js +0 -111
- package/providers/_builtin/ide/pearai/scripts/1.0/send_message.js +0 -104
- package/providers/_builtin/ide/pearai/scripts/1.0/set_mode.js +0 -51
- package/providers/_builtin/ide/pearai/scripts/1.0/set_model.js +0 -54
- package/providers/_builtin/ide/pearai/scripts/1.0/switch_session.js +0 -81
- package/providers/_builtin/ide/trae/provider.json +0 -72
- package/providers/_builtin/ide/trae/scripts/1.0/focus_editor.js +0 -20
- package/providers/_builtin/ide/trae/scripts/1.0/list_chats.js +0 -24
- package/providers/_builtin/ide/trae/scripts/1.0/list_models.js +0 -39
- package/providers/_builtin/ide/trae/scripts/1.0/list_modes.js +0 -39
- package/providers/_builtin/ide/trae/scripts/1.0/new_session.js +0 -30
- package/providers/_builtin/ide/trae/scripts/1.0/open_panel.js +0 -44
- package/providers/_builtin/ide/trae/scripts/1.0/read_chat.js +0 -113
- package/providers/_builtin/ide/trae/scripts/1.0/resolve_action.js +0 -54
- package/providers/_builtin/ide/trae/scripts/1.0/scripts.js +0 -82
- package/providers/_builtin/ide/trae/scripts/1.0/send_message.js +0 -69
- package/providers/_builtin/ide/trae/scripts/1.0/set_mode.js +0 -15
- package/providers/_builtin/ide/trae/scripts/1.0/set_model.js +0 -15
- package/providers/_builtin/ide/trae/scripts/1.0/switch_session.js +0 -23
- package/providers/_builtin/ide/vscode/provider.json +0 -74
- package/providers/_builtin/ide/vscode/scripts/1.0/focus_editor.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/list_models.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/list_sessions.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/new_session.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/open_panel.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/read_chat.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/resolve_action.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/scripts.js +0 -25
- package/providers/_builtin/ide/vscode/scripts/1.0/send_message.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/set_model.js +0 -1
- package/providers/_builtin/ide/vscode/scripts/1.0/switch_session.js +0 -1
- package/providers/_builtin/ide/vscode-insiders/provider.json +0 -68
- package/providers/_builtin/ide/vscodium/provider.json +0 -69
- package/providers/_builtin/ide/windsurf/provider.json +0 -57
- package/providers/_builtin/ide/windsurf/scripts/1.0/focus_editor.js +0 -36
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_chats.js +0 -23
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_models.js +0 -56
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_modes.js +0 -63
- package/providers/_builtin/ide/windsurf/scripts/1.0/list_sessions.js +0 -79
- package/providers/_builtin/ide/windsurf/scripts/1.0/new_session.js +0 -58
- package/providers/_builtin/ide/windsurf/scripts/1.0/open_panel.js +0 -67
- package/providers/_builtin/ide/windsurf/scripts/1.0/read_chat.js +0 -253
- package/providers/_builtin/ide/windsurf/scripts/1.0/resolve_action.js +0 -82
- package/providers/_builtin/ide/windsurf/scripts/1.0/scripts.js +0 -82
- package/providers/_builtin/ide/windsurf/scripts/1.0/send_message.js +0 -20
- package/providers/_builtin/ide/windsurf/scripts/1.0/set_mode.js +0 -43
- package/providers/_builtin/ide/windsurf/scripts/1.0/set_model.js +0 -49
- package/providers/_builtin/ide/windsurf/scripts/1.0/switch_session.js +0 -82
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/focus_editor.js +0 -30
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/list_chats.js +0 -117
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/list_models.js +0 -39
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/list_modes.js +0 -39
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/new_session.js +0 -69
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/open_panel.js +0 -58
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/read_chat.js +0 -315
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/resolve_action.js +0 -68
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/scripts.js +0 -82
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/send_message.js +0 -87
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/set_mode.js +0 -15
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/set_model.js +0 -15
- package/providers/_builtin/ide/windsurf/scripts/1.0.bak/switch_session.js +0 -58
- package/providers/_builtin/registry.json +0 -376
- package/providers/_builtin/validate.js +0 -156
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PearAI — webview_set_model
|
|
3
|
-
* ${ MODEL }
|
|
4
|
-
*/
|
|
5
|
-
(async () => {
|
|
6
|
-
try {
|
|
7
|
-
const target = String(${ MODEL }).trim().toLowerCase();
|
|
8
|
-
const knownModelPattern = /default|gpt|claude|gemini|sonnet|haiku|o1|o3|4\.1|3\.7/i;
|
|
9
|
-
const trigger = Array.from(document.querySelectorAll('button[data-testid="dropdown-trigger"], button[title], button'))
|
|
10
|
-
.find((button) => /select api configuration/i.test(button.getAttribute('title') || ''));
|
|
11
|
-
|
|
12
|
-
if (!trigger) {
|
|
13
|
-
return JSON.stringify({ success: false, error: 'model trigger not found' });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
trigger.click();
|
|
17
|
-
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
18
|
-
|
|
19
|
-
const options = Array.from(document.querySelectorAll('[role="option"], [cmdk-item], [data-radix-collection-item], button, div, span'))
|
|
20
|
-
.filter((node) => {
|
|
21
|
-
const rect = node.getBoundingClientRect();
|
|
22
|
-
const text = (node.textContent || '').trim();
|
|
23
|
-
return node !== trigger
|
|
24
|
-
&& !trigger.contains(node)
|
|
25
|
-
&& rect.width > 0
|
|
26
|
-
&& rect.height > 0
|
|
27
|
-
&& text
|
|
28
|
-
&& text.length < 80
|
|
29
|
-
&& !node.querySelector('textarea')
|
|
30
|
-
&& node.querySelectorAll('button').length === 0
|
|
31
|
-
&& node.children.length <= 2;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const match = options.find((node) => {
|
|
35
|
-
const text = (node.textContent || '').trim().toLowerCase();
|
|
36
|
-
return knownModelPattern.test(text) && (text === target || text.includes(target));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
if (!match) {
|
|
40
|
-
const current = (trigger.textContent || '').trim();
|
|
41
|
-
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
|
|
42
|
-
if (current.toLowerCase() === target || current.toLowerCase().includes(target)) {
|
|
43
|
-
return JSON.stringify({ success: true, model: current });
|
|
44
|
-
}
|
|
45
|
-
return JSON.stringify({ success: false, error: 'model not found: ' + target });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
match.click();
|
|
49
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
50
|
-
return JSON.stringify({ success: true, model: (match.textContent || '').trim() });
|
|
51
|
-
} catch (error) {
|
|
52
|
-
return JSON.stringify({ success: false, error: String(error && error.message || error) });
|
|
53
|
-
}
|
|
54
|
-
})()
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PearAI — webview_switch_session
|
|
3
|
-
* ${ INDEX }
|
|
4
|
-
* ${ TITLE }
|
|
5
|
-
*/
|
|
6
|
-
(() => {
|
|
7
|
-
try {
|
|
8
|
-
const targetIndex = Number(${ INDEX });
|
|
9
|
-
const targetTitle = String(${ TITLE }).trim().toLowerCase();
|
|
10
|
-
|
|
11
|
-
const clickElement = (element) => {
|
|
12
|
-
if (!element) return false;
|
|
13
|
-
const rect = element.getBoundingClientRect();
|
|
14
|
-
const x = rect.left + rect.width / 2;
|
|
15
|
-
const y = rect.top + rect.height / 2;
|
|
16
|
-
element.scrollIntoView({ block: 'center' });
|
|
17
|
-
element.focus?.();
|
|
18
|
-
element.click?.();
|
|
19
|
-
for (const type of ['pointerdown', 'mousedown', 'pointerup', 'mouseup', 'click']) {
|
|
20
|
-
element.dispatchEvent(new PointerEvent(type, {
|
|
21
|
-
bubbles: true,
|
|
22
|
-
cancelable: true,
|
|
23
|
-
view: window,
|
|
24
|
-
clientX: x,
|
|
25
|
-
clientY: y,
|
|
26
|
-
pointerId: 1,
|
|
27
|
-
pointerType: 'mouse',
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const taskItems = Array.from(document.querySelectorAll('[data-testid^="task-item-"]'));
|
|
34
|
-
if (taskItems.length) {
|
|
35
|
-
let match = null;
|
|
36
|
-
if (targetTitle) {
|
|
37
|
-
match = taskItems.find((item) => (item.textContent || '').trim().toLowerCase().includes(targetTitle));
|
|
38
|
-
}
|
|
39
|
-
if (!match && Number.isInteger(targetIndex) && targetIndex >= 0 && targetIndex < taskItems.length) {
|
|
40
|
-
match = taskItems[targetIndex];
|
|
41
|
-
}
|
|
42
|
-
if (match && clickElement(match)) {
|
|
43
|
-
return JSON.stringify({ switched: true, title: (match.textContent || '').trim().slice(0, 120) });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const cards = Array.from(document.querySelectorAll('div')).filter((card) => {
|
|
48
|
-
const className = String(card.className || '');
|
|
49
|
-
const text = (card.textContent || '').trim();
|
|
50
|
-
return className.includes('bg-vscode-editor-background')
|
|
51
|
-
&& className.includes('cursor-pointer')
|
|
52
|
-
&& className.includes('overflow-hidden')
|
|
53
|
-
&& !!card.querySelector('[data-testid="copy-prompt-button"]')
|
|
54
|
-
&& /↑\s*\d|↓\s*\d/i.test(text)
|
|
55
|
-
&& /MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER|JANUARY|FEBRUARY/i.test(text);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
let match = null;
|
|
59
|
-
if (targetTitle) {
|
|
60
|
-
match = cards.find((card) => {
|
|
61
|
-
const promptText = (card.querySelector('.text-vscode-foreground')?.textContent || '').trim().toLowerCase();
|
|
62
|
-
return promptText.includes(targetTitle);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (!match && Number.isInteger(targetIndex) && targetIndex >= 0 && targetIndex < cards.length) {
|
|
66
|
-
match = cards[targetIndex];
|
|
67
|
-
}
|
|
68
|
-
if (!match && cards.length === 1) {
|
|
69
|
-
match = cards[0];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const clickTarget = match ? (match.querySelector('.text-vscode-foreground') || match) : null;
|
|
73
|
-
if (clickTarget && clickElement(clickTarget)) {
|
|
74
|
-
return JSON.stringify({ switched: true, title: (match.textContent || '').trim().slice(0, 120) });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return JSON.stringify({ switched: false, error: 'session not found' });
|
|
78
|
-
} catch (error) {
|
|
79
|
-
return JSON.stringify({ switched: false, error: String(error && error.message || error) });
|
|
80
|
-
}
|
|
81
|
-
})()
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "trae",
|
|
3
|
-
"name": "Trae",
|
|
4
|
-
"category": "ide",
|
|
5
|
-
"displayName": "Trae",
|
|
6
|
-
"icon": "🔮",
|
|
7
|
-
"cli": "trae",
|
|
8
|
-
"cdpPorts": [
|
|
9
|
-
9353,
|
|
10
|
-
9354
|
|
11
|
-
],
|
|
12
|
-
"targetFilter": {
|
|
13
|
-
"urlIncludes": "workbench.html",
|
|
14
|
-
"urlExcludes": [
|
|
15
|
-
"agent"
|
|
16
|
-
],
|
|
17
|
-
"titleExcludes": "extension-output|ADHDev CDP|Debug Console|Output\\s*$|Launchpad"
|
|
18
|
-
},
|
|
19
|
-
"processNames": {
|
|
20
|
-
"darwin": "Trae",
|
|
21
|
-
"win32": [
|
|
22
|
-
"Trae.exe"
|
|
23
|
-
],
|
|
24
|
-
"linux": [
|
|
25
|
-
"trae"
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
"paths": {
|
|
29
|
-
"darwin": [
|
|
30
|
-
"/Applications/Trae.app"
|
|
31
|
-
],
|
|
32
|
-
"win32": [
|
|
33
|
-
"C:\\Users\\*\\AppData\\Local\\Programs\\trae\\Trae.exe"
|
|
34
|
-
],
|
|
35
|
-
"linux": [
|
|
36
|
-
"/opt/trae",
|
|
37
|
-
"/usr/share/trae"
|
|
38
|
-
]
|
|
39
|
-
},
|
|
40
|
-
"inputMethod": "cdp-type-and-send",
|
|
41
|
-
"inputSelector": ".chat-input-v2-input-box-editable, [contenteditable=\"true\"][role=\"textbox\"]",
|
|
42
|
-
"versionCommand": "trae --version",
|
|
43
|
-
"providerVersion": "0.0.0",
|
|
44
|
-
"compatibility": [
|
|
45
|
-
{ "ideVersion": ">=1.0.0", "scriptDir": "scripts/1.0" }
|
|
46
|
-
],
|
|
47
|
-
"defaultScriptDir": "scripts/1.0",
|
|
48
|
-
"settings": {
|
|
49
|
-
"approvalAlert": {
|
|
50
|
-
"type": "boolean",
|
|
51
|
-
"default": true,
|
|
52
|
-
"public": true,
|
|
53
|
-
"label": "Approval Notifications",
|
|
54
|
-
"description": "Show notification when approval is needed"
|
|
55
|
-
},
|
|
56
|
-
"longGeneratingAlert": {
|
|
57
|
-
"type": "boolean",
|
|
58
|
-
"default": true,
|
|
59
|
-
"public": true,
|
|
60
|
-
"label": "Long Generation Alert",
|
|
61
|
-
"description": "Alert when generation takes too long"
|
|
62
|
-
},
|
|
63
|
-
"longGeneratingThresholdSec": {
|
|
64
|
-
"type": "number",
|
|
65
|
-
"default": 180,
|
|
66
|
-
"public": true,
|
|
67
|
-
"label": "Long Generation Threshold (sec)",
|
|
68
|
-
"min": 30,
|
|
69
|
-
"max": 600
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cursor v1 — focus_editor
|
|
3
|
-
*
|
|
4
|
-
* CURSOR.md 4-5: Selector priority
|
|
5
|
-
* [contenteditable="true"][role="textbox"]
|
|
6
|
-
* → .chat-input textarea
|
|
7
|
-
* → .composer-input
|
|
8
|
-
* → textarea
|
|
9
|
-
*
|
|
10
|
-
* final Check: 2026-03-06
|
|
11
|
-
*/
|
|
12
|
-
(() => {
|
|
13
|
-
const editor = document.querySelector('[contenteditable="true"][role="textbox"]')
|
|
14
|
-
|| document.querySelector('.chat-input textarea')
|
|
15
|
-
|| document.querySelector('.composer-input')
|
|
16
|
-
|| document.querySelector('textarea.native-input')
|
|
17
|
-
|| document.querySelector('textarea');
|
|
18
|
-
if (editor) { editor.focus(); return 'focused'; }
|
|
19
|
-
return 'no editor found';
|
|
20
|
-
})()
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trae — list_chats
|
|
3
|
-
*
|
|
4
|
-
* Trae from main DOM / Session list get.
|
|
5
|
-
*/
|
|
6
|
-
(() => {
|
|
7
|
-
try {
|
|
8
|
-
const tabs = document.querySelectorAll('.chat-tab-header, [class*="tab-item"], [class*="TabItem"]');
|
|
9
|
-
if (tabs.length === 0) return JSON.stringify({ sessions: [] });
|
|
10
|
-
|
|
11
|
-
const sessions = Array.from(tabs).map((tab, i) => {
|
|
12
|
-
const title = (tab.textContent || '').replace('✕', '').trim();
|
|
13
|
-
const active = tab.classList.contains('active') ||
|
|
14
|
-
tab.getAttribute('aria-selected') === 'true' ||
|
|
15
|
-
(tab.className || '').toLowerCase().includes('active');
|
|
16
|
-
return { id: String(i), title, active };
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
// list history button Check
|
|
20
|
-
return JSON.stringify({ sessions });
|
|
21
|
-
} catch (e) {
|
|
22
|
-
return JSON.stringify({ error: e.message, sessions: [] });
|
|
23
|
-
}
|
|
24
|
-
})()
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic fallback — list_models
|
|
3
|
-
*/
|
|
4
|
-
(() => {
|
|
5
|
-
try {
|
|
6
|
-
const models = [];
|
|
7
|
-
let current = '';
|
|
8
|
-
|
|
9
|
-
// Try generic Model string from select/button
|
|
10
|
-
const sel = document.querySelectorAll('select, [class*="model"], [id*="model"]');
|
|
11
|
-
for (const el of sel) {
|
|
12
|
-
const txt = (el.textContent || '').trim();
|
|
13
|
-
if (txt && /claude|gpt|gemini|sonnet|opus/i.test(txt)) {
|
|
14
|
-
if (txt.length < 50) {
|
|
15
|
-
models.push(txt);
|
|
16
|
-
if (!current) current = txt;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (models.length === 0) {
|
|
22
|
-
const btns = document.querySelectorAll('button');
|
|
23
|
-
for (const b of btns) {
|
|
24
|
-
const txt = (b.textContent || '').trim();
|
|
25
|
-
if (txt && /claude|gpt|gemini|sonnet/i.test(txt) && txt.length < 30) {
|
|
26
|
-
models.push(txt);
|
|
27
|
-
current = txt;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return JSON.stringify({
|
|
33
|
-
models: [...new Set(models)],
|
|
34
|
-
current: current || 'Default'
|
|
35
|
-
});
|
|
36
|
-
} catch (e) {
|
|
37
|
-
return JSON.stringify({ models: [], current: '', error: e.message });
|
|
38
|
-
}
|
|
39
|
-
})()
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic fallback — list_models
|
|
3
|
-
*/
|
|
4
|
-
(() => {
|
|
5
|
-
try {
|
|
6
|
-
const models = [];
|
|
7
|
-
let current = '';
|
|
8
|
-
|
|
9
|
-
// Try generic Model string from select/button
|
|
10
|
-
const sel = document.querySelectorAll('select, [class*="model"], [id*="model"]');
|
|
11
|
-
for (const el of sel) {
|
|
12
|
-
const txt = (el.textContent || '').trim();
|
|
13
|
-
if (txt && /claude|gpt|gemini|sonnet|opus/i.test(txt)) {
|
|
14
|
-
if (txt.length < 50) {
|
|
15
|
-
models.push(txt);
|
|
16
|
-
if (!current) current = txt;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (models.length === 0) {
|
|
22
|
-
const btns = document.querySelectorAll('button');
|
|
23
|
-
for (const b of btns) {
|
|
24
|
-
const txt = (b.textContent || '').trim();
|
|
25
|
-
if (txt && /claude|gpt|gemini|sonnet/i.test(txt) && txt.length < 30) {
|
|
26
|
-
models.push(txt);
|
|
27
|
-
current = txt;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return JSON.stringify({
|
|
33
|
-
models: [...new Set(models)],
|
|
34
|
-
current: current || 'Default'
|
|
35
|
-
});
|
|
36
|
-
} catch (e) {
|
|
37
|
-
return JSON.stringify({ models: [], current: '', error: e.message });
|
|
38
|
-
}
|
|
39
|
-
})()
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trae — new_session
|
|
3
|
-
*
|
|
4
|
-
* "New Task" create (⌃⌘N shortcut or button click).
|
|
5
|
-
* Trae from main DOM accessible.
|
|
6
|
-
*/
|
|
7
|
-
(() => {
|
|
8
|
-
try {
|
|
9
|
-
// button search
|
|
10
|
-
const buttons = document.querySelectorAll('button, [role="button"], .action-item a');
|
|
11
|
-
for (const btn of buttons) {
|
|
12
|
-
const text = (btn.textContent || '').trim();
|
|
13
|
-
const label = (btn.getAttribute('aria-label') || '').toLowerCase();
|
|
14
|
-
if (text.includes('New Task') || label.includes('new task') || label.includes('new chat')) {
|
|
15
|
-
btn.click();
|
|
16
|
-
return JSON.stringify({ created: true, method: 'button' });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// shortcut fallback: ⌃⌘N
|
|
21
|
-
document.dispatchEvent(new KeyboardEvent('keydown', {
|
|
22
|
-
key: 'n', code: 'KeyN', keyCode: 78,
|
|
23
|
-
metaKey: true, ctrlKey: true,
|
|
24
|
-
bubbles: true, cancelable: true,
|
|
25
|
-
}));
|
|
26
|
-
return JSON.stringify({ created: true, method: 'shortcut' });
|
|
27
|
-
} catch (e) {
|
|
28
|
-
return JSON.stringify({ created: false, error: e.message });
|
|
29
|
-
}
|
|
30
|
-
})()
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trae — open_panel
|
|
3
|
-
*
|
|
4
|
-
* Trae AI chat panel open.
|
|
5
|
-
* "TRAE" button or ⌘L via shortcut open.
|
|
6
|
-
*
|
|
7
|
-
* Return: 'visible' | 'opened' | 'error: ...'
|
|
8
|
-
*/
|
|
9
|
-
(() => {
|
|
10
|
-
try {
|
|
11
|
-
// 1. if already open Check
|
|
12
|
-
const sidebar = document.getElementById('workbench.parts.auxiliarybar');
|
|
13
|
-
if (sidebar && sidebar.offsetWidth > 0 && sidebar.offsetHeight > 0) {
|
|
14
|
-
return 'visible';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// 2. "TRAE" button click
|
|
18
|
-
const toggleBtns = Array.from(document.querySelectorAll('li.action-item a, button, [role="button"]'));
|
|
19
|
-
for (const btn of toggleBtns) {
|
|
20
|
-
const label = (btn.getAttribute('aria-label') || '');
|
|
21
|
-
if (label === 'TRAE' || label.toLowerCase().includes('toggle secondary') ||
|
|
22
|
-
label.toLowerCase().includes('toggle auxiliary')) {
|
|
23
|
-
btn.click();
|
|
24
|
-
return 'opened (toggle)';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// 3. Cmd+L shortcut fallback (Trae default shortcut)
|
|
29
|
-
document.dispatchEvent(new KeyboardEvent('keydown', {
|
|
30
|
-
key: 'l', code: 'KeyL', keyCode: 76,
|
|
31
|
-
metaKey: true, ctrlKey: false,
|
|
32
|
-
bubbles: true, cancelable: true,
|
|
33
|
-
}));
|
|
34
|
-
document.dispatchEvent(new KeyboardEvent('keyup', {
|
|
35
|
-
key: 'l', code: 'KeyL', keyCode: 76,
|
|
36
|
-
metaKey: true, ctrlKey: false,
|
|
37
|
-
bubbles: true, cancelable: true,
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
return 'opened (⌘L)';
|
|
41
|
-
} catch (e) {
|
|
42
|
-
return 'error: ' + e.message;
|
|
43
|
-
}
|
|
44
|
-
})()
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trae — read_chat
|
|
3
|
-
*
|
|
4
|
-
* Trae from main DOM chat content accessible.
|
|
5
|
-
* chat is .chat-turn element .
|
|
6
|
-
* : .user-chat-bubble-request__content-wrapper
|
|
7
|
-
* : .assistant-chat-turn-content .chat-markdown
|
|
8
|
-
*
|
|
9
|
-
* Return: ReadChatResult { id, status, messages, title?, inputContent?, activeModal? }
|
|
10
|
-
*/
|
|
11
|
-
(() => {
|
|
12
|
-
try {
|
|
13
|
-
const auxbar = document.getElementById('workbench.parts.auxiliarybar');
|
|
14
|
-
if (!auxbar || auxbar.offsetWidth === 0) {
|
|
15
|
-
return JSON.stringify({ id: '', status: 'idle', messages: [] });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// ─── 1. Collect messages ───
|
|
19
|
-
const messages = [];
|
|
20
|
-
const turns = auxbar.querySelectorAll('.chat-turn');
|
|
21
|
-
|
|
22
|
-
turns.forEach((turn, idx) => {
|
|
23
|
-
// User message
|
|
24
|
-
const userBubble = turn.querySelector('.user-chat-bubble-request__content-wrapper');
|
|
25
|
-
if (userBubble) {
|
|
26
|
-
messages.push({
|
|
27
|
-
role: 'user',
|
|
28
|
-
content: userBubble.textContent.trim(),
|
|
29
|
-
index: idx,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Assistant message
|
|
34
|
-
const assistantEl = turn.querySelector('.assistant-chat-turn-content');
|
|
35
|
-
if (assistantEl) {
|
|
36
|
-
const mdBlocks = assistantEl.querySelectorAll('.chat-markdown-p, .chat-markdown pre');
|
|
37
|
-
let content = '';
|
|
38
|
-
if (mdBlocks.length > 0) {
|
|
39
|
-
content = Array.from(mdBlocks).map(b => b.textContent.trim()).join('\n');
|
|
40
|
-
} else {
|
|
41
|
-
content = assistantEl.textContent.trim();
|
|
42
|
-
}
|
|
43
|
-
if (content) {
|
|
44
|
-
messages.push({
|
|
45
|
-
role: 'assistant',
|
|
46
|
-
content: content,
|
|
47
|
-
index: idx,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// ─── 2. status detection ───
|
|
54
|
-
let status = 'idle';
|
|
55
|
-
|
|
56
|
-
// Stop button exists → generating
|
|
57
|
-
const stopBtn = auxbar.querySelector('button[class*="stop"], [aria-label*="stop" i], [aria-label*="Stop"]');
|
|
58
|
-
if (stopBtn && stopBtn.offsetWidth > 0) {
|
|
59
|
-
status = 'generating';
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// progress bar → generating
|
|
63
|
-
const progress = auxbar.querySelector('.monaco-progress-container:not(.done)');
|
|
64
|
-
if (progress && progress.offsetWidth > 0) {
|
|
65
|
-
status = 'generating';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// latest-assistant-bar most accurate (final determination)
|
|
69
|
-
const latestBar = auxbar.querySelector('.latest-assistant-bar');
|
|
70
|
-
if (latestBar) {
|
|
71
|
-
const barText = latestBar.textContent.toLowerCase();
|
|
72
|
-
if (barText.includes('completed') || barText.includes('done')) {
|
|
73
|
-
status = 'idle';
|
|
74
|
-
} else if (barText.includes('thinking') || barText.includes('generating') || barText.includes('running') || barText.includes('searching')) {
|
|
75
|
-
status = 'generating';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ─── 3. approval wait modal ───
|
|
80
|
-
let activeModal = null;
|
|
81
|
-
const dialogs = auxbar.querySelectorAll('[role="dialog"], .monaco-dialog-box, [class*="approval"], [class*="confirm"]');
|
|
82
|
-
if (dialogs.length > 0) {
|
|
83
|
-
const dialog = dialogs[0];
|
|
84
|
-
const buttons = Array.from(dialog.querySelectorAll('button')).map(b => b.textContent.trim()).filter(Boolean);
|
|
85
|
-
if (buttons.length > 0) {
|
|
86
|
-
activeModal = {
|
|
87
|
-
message: dialog.textContent.trim().substring(0, 200),
|
|
88
|
-
buttons: buttons,
|
|
89
|
-
};
|
|
90
|
-
status = 'waiting_approval';
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// ─── 4. Input field content ───
|
|
95
|
-
const input = auxbar.querySelector('.chat-input-v2-input-box-editable, [contenteditable="true"]');
|
|
96
|
-
const inputContent = input ? input.textContent.trim() : '';
|
|
97
|
-
|
|
98
|
-
// ─── 5. Session ID / Title ───
|
|
99
|
-
const sessionTab = auxbar.querySelector('[class*="session-tab"], [class*="chat-title"]');
|
|
100
|
-
const title = sessionTab ? sessionTab.textContent.trim() : '';
|
|
101
|
-
|
|
102
|
-
return JSON.stringify({
|
|
103
|
-
id: title || 'trae-default',
|
|
104
|
-
status: status,
|
|
105
|
-
messages: messages,
|
|
106
|
-
title: title || undefined,
|
|
107
|
-
inputContent: inputContent || undefined,
|
|
108
|
-
activeModal: activeModal,
|
|
109
|
-
});
|
|
110
|
-
} catch (e) {
|
|
111
|
-
return JSON.stringify({ id: '', status: 'error', messages: [], error: e.message });
|
|
112
|
-
}
|
|
113
|
-
})()
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trae — resolve_action
|
|
3
|
-
*
|
|
4
|
-
* Find approve/reject buttons + coordinates Return.
|
|
5
|
-
* Traeapproval dialog is displayed in main DOM.
|
|
6
|
-
*
|
|
7
|
-
* Parameter: ${ BUTTON_TEXT }
|
|
8
|
-
*/
|
|
9
|
-
(() => {
|
|
10
|
-
const want = ${ BUTTON_TEXT };
|
|
11
|
-
const wantNorm = (want || '').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
12
|
-
|
|
13
|
-
function norm(t) { return (t || '').replace(/\s+/g, ' ').trim().toLowerCase(); }
|
|
14
|
-
|
|
15
|
-
function matches(el) {
|
|
16
|
-
const t = norm(el.textContent);
|
|
17
|
-
if (!t || t.length > 80) return false;
|
|
18
|
-
if (t === wantNorm) return true;
|
|
19
|
-
if (t.indexOf(wantNorm) === 0) return true;
|
|
20
|
-
if (wantNorm.indexOf(t) >= 0 && t.length > 2) return true;
|
|
21
|
-
if (/^(run|approve|allow|accept|yes)\b/.test(wantNorm)) {
|
|
22
|
-
if (/^(run|allow|accept|approve)\b/.test(t)) return true;
|
|
23
|
-
}
|
|
24
|
-
if (/^(reject|deny|no|abort)\b/.test(wantNorm)) {
|
|
25
|
-
if (/^(reject|deny)\b/.test(t)) return true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const sel = 'button, [role="button"], .monaco-button';
|
|
31
|
-
const allBtns = [...document.querySelectorAll(sel)].filter(b => {
|
|
32
|
-
if (!b.offsetWidth || !b.getBoundingClientRect().height) return false;
|
|
33
|
-
const rect = b.getBoundingClientRect();
|
|
34
|
-
return rect.y > 0 && rect.y < window.innerHeight;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
let found = null;
|
|
38
|
-
for (let i = allBtns.length - 1; i >= 0; i--) {
|
|
39
|
-
if (matches(allBtns[i])) { found = allBtns[i]; break; }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (found) {
|
|
43
|
-
const rect = found.getBoundingClientRect();
|
|
44
|
-
return JSON.stringify({
|
|
45
|
-
found: true,
|
|
46
|
-
text: found.textContent?.trim()?.substring(0, 40),
|
|
47
|
-
x: Math.round(rect.x + rect.width / 2),
|
|
48
|
-
y: Math.round(rect.y + rect.height / 2),
|
|
49
|
-
w: Math.round(rect.width),
|
|
50
|
-
h: Math.round(rect.height)
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return JSON.stringify({ found: false, want: wantNorm });
|
|
54
|
-
})()
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDP Scripts — Router
|
|
3
|
-
*
|
|
4
|
-
* Version routing is handled by ProviderLoader:
|
|
5
|
-
* Pattern:
|
|
6
|
-
* - Scripts WITHOUT params: loaded as-is (self-invoking IIFE)
|
|
7
|
-
* - Scripts WITH params: loaded as function expression, invoked with params JSON
|
|
8
|
-
* e.g. `(${script})(${JSON.stringify(params)})`
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const fs = require('fs');
|
|
14
|
-
const path = require('path');
|
|
15
|
-
|
|
16
|
-
function load(name) {
|
|
17
|
-
try { return fs.readFileSync(path.join(__dirname, name), 'utf-8'); }
|
|
18
|
-
catch { return null; }
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function withParams(name, params) {
|
|
22
|
-
let script = load(name);
|
|
23
|
-
if (!script) return null;
|
|
24
|
-
|
|
25
|
-
// For legacy scripts checking MESSAGE, interpolate them manually
|
|
26
|
-
if (script.includes('${ MESSAGE }')) {
|
|
27
|
-
const msg = params?.MESSAGE || params?.text || '';
|
|
28
|
-
return script.replace(/\$\{ MESSAGE \}/g, JSON.stringify(msg));
|
|
29
|
-
}
|
|
30
|
-
if (script.includes('${ BUTTON_TEXT }')) {
|
|
31
|
-
const btn = params?.BUTTON_TEXT || params?.buttonText || '';
|
|
32
|
-
return script.replace(/\$\{ BUTTON_TEXT \}/g, JSON.stringify(btn));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return `(${script})(${JSON.stringify(params)})`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ─── Core (no params — IIFE) ───
|
|
39
|
-
|
|
40
|
-
module.exports.readChat = () => load('read_chat.js') || load('webview_read_chat.js');
|
|
41
|
-
module.exports.sendMessage = (params) => {
|
|
42
|
-
let s = load('send_message.js');
|
|
43
|
-
if (!s) s = load('webview_send_message.js');
|
|
44
|
-
if (!s) return null;
|
|
45
|
-
// Legacy template substitution fallback
|
|
46
|
-
if (s.includes('${ MESSAGE }')) {
|
|
47
|
-
const msg = params?.MESSAGE || params?.text || params || '';
|
|
48
|
-
return s.replace(/\$\{ MESSAGE \}/g, JSON.stringify(msg));
|
|
49
|
-
}
|
|
50
|
-
return withParams('send_message.js', params) || withParams('webview_send_message.js', params);
|
|
51
|
-
};
|
|
52
|
-
module.exports.listSessions = () => load('list_sessions.js');
|
|
53
|
-
module.exports.newSession = () => load('new_session.js');
|
|
54
|
-
module.exports.focusEditor = () => load('focus_editor.js');
|
|
55
|
-
module.exports.openPanel = () => load('open_panel.js');
|
|
56
|
-
module.exports.listModels = () => load('list_models.js');
|
|
57
|
-
module.exports.listModes = () => load('list_modes.js');
|
|
58
|
-
|
|
59
|
-
// ─── With params (function expression) ───
|
|
60
|
-
|
|
61
|
-
module.exports.switchSession = (params) => {
|
|
62
|
-
const index = typeof params === 'number' ? params : params?.index ?? 0;
|
|
63
|
-
const title = typeof params === 'string' ? params : params?.title || null;
|
|
64
|
-
return withParams('switch_session.js', { index, title });
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
module.exports.resolveAction = (params) => {
|
|
68
|
-
const action = typeof params === 'string' ? params : params?.action || 'approve';
|
|
69
|
-
const buttonText = params?.button || params?.buttonText
|
|
70
|
-
|| (action === 'approve' ? 'Accept' : action === 'reject' ? 'Reject' : action);
|
|
71
|
-
return withParams('resolve_action.js', { buttonText, BUTTON_TEXT: buttonText });
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
module.exports.setModel = (params) => {
|
|
75
|
-
const model = typeof params === 'string' ? params : params?.model;
|
|
76
|
-
return withParams('set_model.js', { model });
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
module.exports.setMode = (params) => {
|
|
80
|
-
const mode = typeof params === 'string' ? params : params?.mode;
|
|
81
|
-
return withParams('set_mode.js', { mode });
|
|
82
|
-
};
|