@adhdev/daemon-core 0.6.57 → 0.6.59
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 +18 -1
- package/dist/index.js +339 -167
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +223 -48
- package/src/commands/chat-commands.ts +7 -1
- package/src/config/chat-history.ts +53 -1
- package/src/daemon/dev-server.ts +7 -9
- package/src/detection/ide-detector.ts +1 -1
- package/src/providers/cli-provider-instance.ts +10 -23
- package/src/providers/provider-instance.ts +1 -0
- package/src/providers/provider-loader.ts +3 -6
- package/src/providers/version-archive.ts +4 -1
- 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 -49
- package/providers/_builtin/cli/aider-cli/scripts/1.0/scripts.js +0 -7
- package/providers/_builtin/cli/claude-cli/provider.json +0 -109
- package/providers/_builtin/cli/claude-cli/scripts/1.0/detect_status.js +0 -31
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_approval.js +0 -38
- package/providers/_builtin/cli/claude-cli/scripts/1.0/parse_output.js +0 -164
- package/providers/_builtin/cli/claude-cli/scripts/1.0/scripts.js +0 -42
- package/providers/_builtin/cli/codex-cli/provider.json +0 -88
- package/providers/_builtin/cli/codex-cli/scripts/1.0/detect_status.js +0 -20
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_approval.js +0 -15
- package/providers/_builtin/cli/codex-cli/scripts/1.0/parse_output.js +0 -68
- 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 -70
- 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,516 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex Extension — read_chat (v2 — rich content extraction)
|
|
3
|
-
*
|
|
4
|
-
* Structure (Codex — openai.chatgpt):
|
|
5
|
-
* - Root: #root (React app via ProseMirror)
|
|
6
|
-
* - Messages: data-content-search-turn-key="UUID" per turn
|
|
7
|
-
* - Unit: data-content-search-unit-key="UUID:index:role"
|
|
8
|
-
* - Thread: data-thread-find-target="conversation"
|
|
9
|
-
* - Input: .ProseMirror (contentEditable)
|
|
10
|
-
* - Model: footer button text (e.g. "GPT-5.4")
|
|
11
|
-
* - Status indicators: button aria-labels, presence of cancel button
|
|
12
|
-
*
|
|
13
|
-
* Rich content support:
|
|
14
|
-
* - Code blocks (PRE/CODE → ```lang\n...\n```)
|
|
15
|
-
* - Tables (TABLE → markdown table)
|
|
16
|
-
* - Lists (UL/OL → bullet/numbered items)
|
|
17
|
-
* - Inline code (CODE → `...`)
|
|
18
|
-
* - Block elements (P, DIV, H1-H6 → newlines)
|
|
19
|
-
* - Bold/Italic preservation
|
|
20
|
-
*
|
|
21
|
-
* Runs inside webview frame via evaluateInWebviewFrame.
|
|
22
|
-
*/
|
|
23
|
-
(() => {
|
|
24
|
-
try {
|
|
25
|
-
// When executed via evaluateInSession, we're in the outer vscode-webview
|
|
26
|
-
// iframe. The Codex React app lives in a child iframe. Try to access it.
|
|
27
|
-
let doc = document;
|
|
28
|
-
let root = doc.getElementById('root');
|
|
29
|
-
|
|
30
|
-
if (!root) {
|
|
31
|
-
// Traverse into inner iframe(s)
|
|
32
|
-
const iframes = doc.querySelectorAll('iframe');
|
|
33
|
-
for (const iframe of iframes) {
|
|
34
|
-
try {
|
|
35
|
-
const innerDoc = iframe.contentDocument || iframe.contentWindow?.document;
|
|
36
|
-
if (innerDoc) {
|
|
37
|
-
const innerRoot = innerDoc.getElementById('root');
|
|
38
|
-
if (innerRoot) {
|
|
39
|
-
doc = innerDoc;
|
|
40
|
-
root = innerRoot;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
} catch (e) { /* cross-origin, skip */ }
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (!root) return JSON.stringify({ error: 'no root element' });
|
|
49
|
-
|
|
50
|
-
const isVisible = root.offsetHeight > 0;
|
|
51
|
-
|
|
52
|
-
const headerEl = doc.querySelector('[style*="view-transition-name: header-title"]');
|
|
53
|
-
const headerText = (headerEl?.textContent || '').trim();
|
|
54
|
-
const isTaskList = headerText === 'Tasks' || headerText === 'Tasks';
|
|
55
|
-
|
|
56
|
-
// If we accidentally evaluated inside the Tasks webview instead of Chat, tell Daemon to try the next matching webview
|
|
57
|
-
if (isTaskList) {
|
|
58
|
-
return JSON.stringify({ __adhdev_skip_iframe: true, error: 'Found Tasks webview instead of Chat' });
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// ─── Rich content extractor ───
|
|
62
|
-
const BLOCK_TAGS = new Set(['DIV', 'P', 'BR', 'LI', 'TR', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'BLOCKQUOTE', 'HR', 'SECTION', 'ARTICLE']);
|
|
63
|
-
|
|
64
|
-
function extractRichContent(container) {
|
|
65
|
-
let out = '';
|
|
66
|
-
|
|
67
|
-
function extractCode(node) {
|
|
68
|
-
if (node.nodeType === 3) return node.textContent || '';
|
|
69
|
-
if (node.nodeType !== 1) return '';
|
|
70
|
-
if (node.tagName === 'BR') return '\n';
|
|
71
|
-
const parts = [];
|
|
72
|
-
for (const c of node.childNodes) {
|
|
73
|
-
const isBlock = c.nodeType === 1 && BLOCK_TAGS.has(c.tagName);
|
|
74
|
-
const tx = extractCode(c);
|
|
75
|
-
if (tx) {
|
|
76
|
-
if (isBlock && parts.length > 0) parts.push('\n');
|
|
77
|
-
parts.push(tx);
|
|
78
|
-
if (isBlock) parts.push('\n');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return parts.join('').replace(/\n{3,}/g, '\n\n');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function extractTable(table) {
|
|
85
|
-
const rows = [];
|
|
86
|
-
for (const tr of table.querySelectorAll('tr')) {
|
|
87
|
-
const cells = [];
|
|
88
|
-
for (const cell of tr.querySelectorAll('th, td')) {
|
|
89
|
-
cells.push((cell.textContent || '').trim().replace(/\|/g, '\\|'));
|
|
90
|
-
}
|
|
91
|
-
rows.push(cells);
|
|
92
|
-
}
|
|
93
|
-
if (rows.length === 0) return '';
|
|
94
|
-
|
|
95
|
-
const colCount = Math.max(...rows.map(r => r.length));
|
|
96
|
-
const lines = [];
|
|
97
|
-
|
|
98
|
-
// Header row
|
|
99
|
-
const header = rows[0] || [];
|
|
100
|
-
while (header.length < colCount) header.push('');
|
|
101
|
-
lines.push('| ' + header.join(' | ') + ' |');
|
|
102
|
-
lines.push('| ' + header.map(() => '---').join(' | ') + ' |');
|
|
103
|
-
|
|
104
|
-
// Data rows
|
|
105
|
-
for (let i = 1; i < rows.length; i++) {
|
|
106
|
-
const row = rows[i];
|
|
107
|
-
while (row.length < colCount) row.push('');
|
|
108
|
-
lines.push('| ' + row.join(' | ') + ' |');
|
|
109
|
-
}
|
|
110
|
-
return lines.join('\n');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function extractList(list) {
|
|
114
|
-
const items = [];
|
|
115
|
-
const isOrdered = list.tagName === 'OL';
|
|
116
|
-
let idx = 1;
|
|
117
|
-
for (const li of list.querySelectorAll(':scope > li')) {
|
|
118
|
-
const prefix = isOrdered ? `${idx++}. ` : '- ';
|
|
119
|
-
const text = (li.textContent || '').trim();
|
|
120
|
-
if (text) items.push(prefix + text);
|
|
121
|
-
}
|
|
122
|
-
return items.join('\n');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function walk(node) {
|
|
126
|
-
if (node.nodeType === 3) {
|
|
127
|
-
out += node.textContent;
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (node.nodeType !== 1) return;
|
|
131
|
-
const el = node;
|
|
132
|
-
const tag = el.tagName;
|
|
133
|
-
const cls = (el.className && typeof el.className === 'string') ? el.className : '';
|
|
134
|
-
|
|
135
|
-
// ─ Codex code block wrapper (div.bg-token-text-code-block-background)
|
|
136
|
-
if (tag === 'DIV' && cls.includes('bg-token-text-code-block-background')) {
|
|
137
|
-
const langLabel = el.querySelector('.sticky .truncate, .sticky div:first-child');
|
|
138
|
-
const lang = langLabel ? (langLabel.textContent || '').trim() : '';
|
|
139
|
-
const codeEl = el.querySelector('code');
|
|
140
|
-
const codeText = codeEl ? extractCode(codeEl).trim() : (el.textContent || '').trim();
|
|
141
|
-
const cleanCode = (lang && codeText.startsWith(lang))
|
|
142
|
-
? codeText.substring(lang.length).trim()
|
|
143
|
-
: codeText;
|
|
144
|
-
out += '\n```' + lang + '\n' + cleanCode + '\n```\n';
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// ─ Code block (PRE — standard fallback)
|
|
149
|
-
if (tag === 'PRE') {
|
|
150
|
-
const codeEl = el.querySelector('code');
|
|
151
|
-
const lang = codeEl
|
|
152
|
-
? (codeEl.className.match(/language-(\w+)/)?.[1] || '')
|
|
153
|
-
: '';
|
|
154
|
-
const codeText = extractCode(codeEl || el).trim();
|
|
155
|
-
out += '\n```' + lang + '\n' + codeText + '\n```\n';
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// ─ Codex inline code (span._inlineMarkdown.font-mono)
|
|
160
|
-
if (tag === 'SPAN' && cls.includes('font-mono') && cls.includes('inline-markdown')) {
|
|
161
|
-
out += '`' + (el.textContent || '') + '`';
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// ─ Inline code (CODE not inside PRE)
|
|
166
|
-
if (tag === 'CODE') {
|
|
167
|
-
out += '`' + (el.textContent || '') + '`';
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// ─ Table
|
|
172
|
-
if (tag === 'TABLE') {
|
|
173
|
-
const md = extractTable(el);
|
|
174
|
-
if (md) {
|
|
175
|
-
if (out && !out.endsWith('\n')) out += '\n';
|
|
176
|
-
out += md + '\n';
|
|
177
|
-
}
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// ─ Lists
|
|
182
|
-
if (tag === 'UL' || tag === 'OL') {
|
|
183
|
-
const md = extractList(el);
|
|
184
|
-
if (md) {
|
|
185
|
-
if (out && !out.endsWith('\n')) out += '\n';
|
|
186
|
-
out += md + '\n';
|
|
187
|
-
}
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// ─ Headings
|
|
192
|
-
if (/^H[1-6]$/.test(tag)) {
|
|
193
|
-
const level = parseInt(tag[1]);
|
|
194
|
-
if (out && !out.endsWith('\n')) out += '\n';
|
|
195
|
-
out += '#'.repeat(level) + ' ' + (el.textContent || '').trim() + '\n';
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// ─ Horizontal rule
|
|
200
|
-
if (tag === 'HR') {
|
|
201
|
-
out += '\n---\n';
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// ─ BR
|
|
206
|
-
if (tag === 'BR') {
|
|
207
|
-
out += '\n';
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// ─ Bold / Italic / Strong
|
|
212
|
-
if (tag === 'STRONG' || tag === 'B') {
|
|
213
|
-
out += '**' + (el.textContent || '') + '**';
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
if (tag === 'EM' || tag === 'I') {
|
|
217
|
-
out += '*' + (el.textContent || '') + '*';
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// ─ Block elements (P, DIV, BLOCKQUOTE, SECTION, etc.)
|
|
222
|
-
if (BLOCK_TAGS.has(tag)) {
|
|
223
|
-
if (out && !out.endsWith('\n')) out += '\n';
|
|
224
|
-
if (tag === 'BLOCKQUOTE') out += '> ';
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Recurse children
|
|
228
|
-
for (const child of el.childNodes) walk(child);
|
|
229
|
-
|
|
230
|
-
// After block element, ensure newline
|
|
231
|
-
if (BLOCK_TAGS.has(tag) && out && !out.endsWith('\n')) {
|
|
232
|
-
out += '\n';
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
walk(container);
|
|
237
|
-
return out
|
|
238
|
-
.replace(/\n{3,}/g, '\n\n') // collapse excessive newlines
|
|
239
|
-
.replace(/^\n+/, '') // trim leading
|
|
240
|
-
.replace(/\n+$/, '') // trim trailing
|
|
241
|
-
.trim();
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// ─── 1. Messages ───
|
|
245
|
-
const messages = [];
|
|
246
|
-
const turnEls = doc.querySelectorAll('[data-content-search-turn-key]');
|
|
247
|
-
|
|
248
|
-
for (const turnEl of turnEls) {
|
|
249
|
-
const turnKey = turnEl.getAttribute('data-content-search-turn-key');
|
|
250
|
-
const unitEls = turnEl.querySelectorAll('[data-content-search-unit-key]');
|
|
251
|
-
|
|
252
|
-
for (const unitEl of unitEls) {
|
|
253
|
-
const unitKey = unitEl.getAttribute('data-content-search-unit-key') || '';
|
|
254
|
-
const parts = unitKey.split(':');
|
|
255
|
-
const role = parts.length >= 3 ? parts[parts.length - 1] : 'assistant';
|
|
256
|
-
|
|
257
|
-
const content = extractRichContent(unitEl);
|
|
258
|
-
|
|
259
|
-
if (!content || content.length < 1) continue;
|
|
260
|
-
const trimmed = content.length > 3000 ? content.substring(0, 3000) + '…' : content;
|
|
261
|
-
|
|
262
|
-
messages.push({
|
|
263
|
-
role: role === 'user' ? 'user' : 'assistant',
|
|
264
|
-
content: trimmed,
|
|
265
|
-
timestamp: Date.now() - (turnEls.length - messages.length) * 1000,
|
|
266
|
-
_turnKey: turnKey,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Fallback
|
|
272
|
-
if (messages.length === 0 && !isTaskList) {
|
|
273
|
-
const threadArea = doc.querySelector('[data-thread-find-target="conversation"]');
|
|
274
|
-
if (threadArea) {
|
|
275
|
-
const text = extractRichContent(threadArea);
|
|
276
|
-
if (text.length > 0) {
|
|
277
|
-
messages.push({
|
|
278
|
-
role: 'assistant',
|
|
279
|
-
content: text.substring(0, 3000),
|
|
280
|
-
timestamp: Date.now(),
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// ─── 2. Input field ───
|
|
287
|
-
let inputContent = '';
|
|
288
|
-
const proseMirror = doc.querySelector('.ProseMirror');
|
|
289
|
-
if (proseMirror) {
|
|
290
|
-
const placeholder = proseMirror.querySelector('.placeholder');
|
|
291
|
-
const text = (proseMirror.textContent || '').trim();
|
|
292
|
-
if (text && (!placeholder || text !== (placeholder.textContent || '').trim())) {
|
|
293
|
-
inputContent = text;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// ─── 3. Status ───
|
|
298
|
-
let status = 'idle';
|
|
299
|
-
// Filter out disabled buttons to avoid matching old historical prompts
|
|
300
|
-
// Include roles, inputs, custom vscode tags, and generic interactive lists used by multiple-choice forms
|
|
301
|
-
const selectors = [
|
|
302
|
-
'button', '[role="radio"]', '[role="button"]', '[role="option"]', '[role="menuitem"]',
|
|
303
|
-
'input[type="radio"] + label', 'input[type="radio"] ~ span', 'input[type="checkbox"] + label',
|
|
304
|
-
'vscode-button', 'vscode-radio', 'vscode-checkbox', 'vscode-option', 'li'
|
|
305
|
-
].join(', ');
|
|
306
|
-
|
|
307
|
-
const buttons = Array.from(doc.querySelectorAll(selectors))
|
|
308
|
-
.filter(b => b.offsetWidth > 0 && !b.disabled && !b.closest('[inert]'));
|
|
309
|
-
|
|
310
|
-
const getBtnLabel = (b) => {
|
|
311
|
-
let t = (b.textContent || '').trim();
|
|
312
|
-
return t || (b.getAttribute('aria-label') || '').trim();
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
const buttonLabels = buttons.map(getBtnLabel).map(t => t.toLowerCase());
|
|
316
|
-
|
|
317
|
-
if (buttonLabels.some(l => l.includes('cancel') || l.includes('cancel') || l.includes('stop') || l.includes('stop'))) {
|
|
318
|
-
status = 'generating';
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// ─── 5. Universal Approval Modal Detection (Language-Agnostic) ───
|
|
322
|
-
// The approval/interaction panel in Codex is rendered OUTSIDE the chat scroll area,
|
|
323
|
-
// typically in a sibling "request-input-panel" region at the bottom.
|
|
324
|
-
// We must scan the ENTIRE document body to find it.
|
|
325
|
-
let activeModal = null;
|
|
326
|
-
|
|
327
|
-
// Look for the request-input-panel area first (contains radio options + submit/skip)
|
|
328
|
-
// The approval panel lives in the outer webview document, NOT inside the inner iframe (doc).
|
|
329
|
-
// Use `document` (the webview frame root) to find it, same as explore_dom.js does.
|
|
330
|
-
const searchDocs = [document, doc]; // outer first, then inner iframe
|
|
331
|
-
let requestPanel = null;
|
|
332
|
-
for (const d of searchDocs) {
|
|
333
|
-
requestPanel = d.querySelector('[class*="request-input-panel"]');
|
|
334
|
-
if (requestPanel) break;
|
|
335
|
-
// Also search all textareas for the class
|
|
336
|
-
const tas = d.querySelectorAll('textarea');
|
|
337
|
-
for (const ta of tas) {
|
|
338
|
-
if (ta.className && ta.className.includes('request-input-panel')) {
|
|
339
|
-
requestPanel = ta;
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if (requestPanel) break;
|
|
344
|
-
}
|
|
345
|
-
// Walk up from the request-input-panel to find the full approval card
|
|
346
|
-
let approvalArea = null;
|
|
347
|
-
if (requestPanel) {
|
|
348
|
-
let p = requestPanel;
|
|
349
|
-
for (let i = 0; i < 12 && p && p.parentElement; i++) {
|
|
350
|
-
p = p.parentElement;
|
|
351
|
-
const btns = p.querySelectorAll('button').length;
|
|
352
|
-
const radios = p.querySelectorAll('[role="radio"], [role="option"]').length;
|
|
353
|
-
const total = btns + radios;
|
|
354
|
-
if (btns >= 4) {
|
|
355
|
-
// Found the approval card with enough interactive elements
|
|
356
|
-
approvalArea = p;
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (approvalArea) {
|
|
366
|
-
// ─── Codex Approval Panel (request-input-panel based) ───
|
|
367
|
-
// The approval form has:
|
|
368
|
-
// - Option items as plain divs (e.g., "1.\nyes", "2.\nyes,...", "3.\nno,...")
|
|
369
|
-
// - Action buttons (e.g., "skip", "Submit⏎") as <button> elements
|
|
370
|
-
// We need to extract BOTH for the dashboard.
|
|
371
|
-
|
|
372
|
-
// Find parent container that has all options (level 3 from textarea, btns >= 4)
|
|
373
|
-
// approvalArea is already set to this level.
|
|
374
|
-
|
|
375
|
-
// Get the prompt message (from grandparent that starts with "Do you want...")
|
|
376
|
-
let messageText = '';
|
|
377
|
-
let msgParent = approvalArea.parentElement;
|
|
378
|
-
for (let i = 0; i < 5 && msgParent; i++) {
|
|
379
|
-
const t = (msgParent.innerText || '').trim();
|
|
380
|
-
if (t.length > 20 && /[??]/.test(t.substring(0, 200))) {
|
|
381
|
-
// Found a parent whose text starts with a question
|
|
382
|
-
messageText = t.split('\n')[0].trim();
|
|
383
|
-
break;
|
|
384
|
-
}
|
|
385
|
-
msgParent = msgParent.parentElement;
|
|
386
|
-
}
|
|
387
|
-
if (!messageText) {
|
|
388
|
-
// Fallback: use the approvalArea parent's text, first sentence
|
|
389
|
-
const parentText = (approvalArea.parentElement?.innerText || approvalArea.innerText || '').trim();
|
|
390
|
-
const firstLine = parentText.split('\n')[0].trim();
|
|
391
|
-
messageText = firstLine.length > 5 ? firstLine : 'Agent requires an interaction';
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Extract option labels from the panel's direct/nested children
|
|
395
|
-
const allBtns = Array.from(approvalArea.querySelectorAll('button'))
|
|
396
|
-
.filter(b => b.offsetWidth > 0 && !b.disabled)
|
|
397
|
-
.map(b => (b.textContent || '').trim())
|
|
398
|
-
.filter(t => t.length > 0 && t.length < 150);
|
|
399
|
-
|
|
400
|
-
// Extract numbered option text items (the entire panel text, split by option numbering)
|
|
401
|
-
const panelText = (approvalArea.innerText || '').trim();
|
|
402
|
-
// Parse "1.\nyes\n2.\nyes,...\n3.\nno,...\nskip\nSubmit⏎" format
|
|
403
|
-
const optionMatches = panelText.match(/\d+\.\n[^\n]+(?:\n[^\d][^\n]*)*/g) || [];
|
|
404
|
-
let options = optionMatches.map(o => o.replace(/\n/g, '').trim()).filter(o => o.length > 0);
|
|
405
|
-
|
|
406
|
-
// Clean: remove any trailing button labels that got captured in the last option
|
|
407
|
-
const btnLabelsSet = new Set(allBtns);
|
|
408
|
-
options = options.map(opt => {
|
|
409
|
-
let changed = true;
|
|
410
|
-
while (changed) {
|
|
411
|
-
changed = false;
|
|
412
|
-
for (const bl of btnLabelsSet) {
|
|
413
|
-
if (opt.endsWith(bl)) {
|
|
414
|
-
opt = opt.slice(0, -bl.length).trim();
|
|
415
|
-
changed = true;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
return opt;
|
|
420
|
-
}).filter(o => o.length > 0);
|
|
421
|
-
|
|
422
|
-
// Merge numbered options from both sources (buttons + text parsing)
|
|
423
|
-
const allNumbered = [...new Set([...allBtns.filter(b => /^\d+\./.test(b)), ...options])];
|
|
424
|
-
allNumbered.sort((a, b) => (parseInt(a) || 999) - (parseInt(b) || 999));
|
|
425
|
-
const actionBtns = allBtns.filter(b => !/^\d+\./.test(b));
|
|
426
|
-
|
|
427
|
-
// Combine: sorted numbered options first, then action buttons (deduped)
|
|
428
|
-
const uniqueActions = [...new Set([...allNumbered, ...actionBtns])];
|
|
429
|
-
|
|
430
|
-
if (uniqueActions.length > 0) {
|
|
431
|
-
status = 'waiting_approval';
|
|
432
|
-
activeModal = {
|
|
433
|
-
message: messageText,
|
|
434
|
-
buttons: uniqueActions
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
} // end if (approvalArea)
|
|
438
|
-
|
|
439
|
-
if (isTaskList) {
|
|
440
|
-
status = messages.length === 0 ? 'idle' : status;
|
|
441
|
-
}
|
|
442
|
-
if (!isVisible && messages.length === 0) status = 'panel_hidden';
|
|
443
|
-
|
|
444
|
-
// ─── 4. Model / Mode ───
|
|
445
|
-
// Language-agnostic detection via DOM structure.
|
|
446
|
-
// Model: button text matching model name patterns (GPT-*, o1-*, claude-* — always English).
|
|
447
|
-
// Mode: non-model aria-haspopup="menu" button in composer area (language-agnostic).
|
|
448
|
-
let model = '';
|
|
449
|
-
let mode = '';
|
|
450
|
-
for (const d of [doc, document]) {
|
|
451
|
-
// Search in composer area, or common footer containers
|
|
452
|
-
const searchRoots = [
|
|
453
|
-
d.querySelector('[class*="thread-composer-max-width"]'),
|
|
454
|
-
d.querySelector('[class*="thread-composer"]'),
|
|
455
|
-
d.querySelector('[class*="pb-2"]'),
|
|
456
|
-
d.body,
|
|
457
|
-
].filter(Boolean);
|
|
458
|
-
|
|
459
|
-
for (const searchRoot of searchRoots) {
|
|
460
|
-
if (model && mode) break;
|
|
461
|
-
|
|
462
|
-
// aria-haspopup="menu" buttons — dropdown triggers for model/mode
|
|
463
|
-
if (!model || !mode) {
|
|
464
|
-
const menuBtns = Array.from(searchRoot.querySelectorAll('button[aria-haspopup="menu"]'))
|
|
465
|
-
.filter(b => b.offsetWidth > 0);
|
|
466
|
-
for (const btn of menuBtns) {
|
|
467
|
-
const text = (btn.textContent || '').trim();
|
|
468
|
-
if (!model && /^(GPT-|gpt-|o\d|claude-|sonnet|opus)/i.test(text)) {
|
|
469
|
-
model = text;
|
|
470
|
-
} else if (!mode && text.length > 0 && text.length < 30) {
|
|
471
|
-
mode = text;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// Fallback: any visible button with model-like text
|
|
477
|
-
if (!model) {
|
|
478
|
-
const allBtns = Array.from(searchRoot.querySelectorAll('button'))
|
|
479
|
-
.filter(b => b.offsetWidth > 0);
|
|
480
|
-
for (const btn of allBtns) {
|
|
481
|
-
const text = (btn.textContent || '').trim();
|
|
482
|
-
if (/^(GPT-|gpt-|o\d|claude-|sonnet|opus)/i.test(text)) {
|
|
483
|
-
model = text;
|
|
484
|
-
break;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
if (model) break; // found model, no need to keep searching this scope
|
|
490
|
-
}
|
|
491
|
-
if (model) break; // found in this frame
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
// ─── 6. Task info ───
|
|
495
|
-
const taskBtn = doc.querySelector('[aria-label*="Tasks"], [aria-label*="task" i]');
|
|
496
|
-
const taskInfo = taskBtn ? (taskBtn.textContent || '').trim() : '';
|
|
497
|
-
|
|
498
|
-
return JSON.stringify({
|
|
499
|
-
agentType: 'codex',
|
|
500
|
-
agentName: 'Codex',
|
|
501
|
-
extensionId: 'openai.chatgpt',
|
|
502
|
-
status,
|
|
503
|
-
isVisible,
|
|
504
|
-
isTaskList,
|
|
505
|
-
title: headerText || 'Codex',
|
|
506
|
-
messages: messages.slice(-30),
|
|
507
|
-
inputContent,
|
|
508
|
-
model,
|
|
509
|
-
mode,
|
|
510
|
-
taskInfo,
|
|
511
|
-
activeModal,
|
|
512
|
-
});
|
|
513
|
-
} catch (e) {
|
|
514
|
-
return JSON.stringify({ error: e.message || String(e) });
|
|
515
|
-
}
|
|
516
|
-
})()
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex Extension — resolve_action
|
|
3
|
-
*
|
|
4
|
-
* Clicks approval/denial buttons in the Codex UI.
|
|
5
|
-
* Actions: "approve", "deny", "cancel", or raw button text
|
|
6
|
-
*
|
|
7
|
-
* Placeholders: ${action}, ${button}
|
|
8
|
-
*/
|
|
9
|
-
(() => {
|
|
10
|
-
try {
|
|
11
|
-
const action = ${action};
|
|
12
|
-
const buttonText = ${button};
|
|
13
|
-
|
|
14
|
-
// Search in document (outer webview frame where Codex approval panel lives)
|
|
15
|
-
const buttons = Array.from(document.querySelectorAll('button, [role="radio"], [role="button"], input[type="radio"] + label'))
|
|
16
|
-
.filter(b => b.offsetWidth > 0 && !b.disabled && !b.closest('[inert]'));
|
|
17
|
-
|
|
18
|
-
const actionLower = (action || '').toLowerCase();
|
|
19
|
-
const patterns = {
|
|
20
|
-
approve: /^(approve|accept|allow|confirm|run|proceed|yes|approval|허용|execute|Check)/i,
|
|
21
|
-
deny: /^(deny|reject|no|거부|아니오)/i,
|
|
22
|
-
cancel: /^(cancel|stop|cancel|stop)/i,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Determine what to search for: use buttonText if provided, otherwise match action pattern
|
|
26
|
-
const searchText = buttonText || action || '';
|
|
27
|
-
let targetBtn = null;
|
|
28
|
-
|
|
29
|
-
const getBtnLabel = (b) => {
|
|
30
|
-
let t = (b.textContent || '').trim();
|
|
31
|
-
return t || (b.getAttribute('aria-label') || '').trim();
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// 1. Try exact match on buttonText first
|
|
35
|
-
if (buttonText) {
|
|
36
|
-
targetBtn = buttons.find(b => getBtnLabel(b) === buttonText);
|
|
37
|
-
// 2. Try startsWith match (for cases where button text has extra chars like ⏎)
|
|
38
|
-
if (!targetBtn) {
|
|
39
|
-
targetBtn = buttons.find(b => getBtnLabel(b).startsWith(buttonText));
|
|
40
|
-
}
|
|
41
|
-
// 3. Try includes match
|
|
42
|
-
if (!targetBtn) {
|
|
43
|
-
targetBtn = buttons.find(b => getBtnLabel(b).includes(buttonText));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// 4. Fall back to pattern-based matching
|
|
48
|
-
if (!targetBtn && patterns[actionLower]) {
|
|
49
|
-
targetBtn = buttons.find(b => patterns[actionLower].test(getBtnLabel(b)));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 5. Fall back to regex on raw action text
|
|
53
|
-
if (!targetBtn) {
|
|
54
|
-
const escapedAction = searchText.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
55
|
-
const pattern = new RegExp(escapedAction, 'i');
|
|
56
|
-
targetBtn = buttons.find(b => pattern.test(getBtnLabel(b)));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (targetBtn) {
|
|
60
|
-
targetBtn.click();
|
|
61
|
-
|
|
62
|
-
// If this is a numbered option (1., 2., 3.), also click Submit after a short delay
|
|
63
|
-
const clickedText = getBtnLabel(targetBtn);
|
|
64
|
-
if (/^\d+\./.test(clickedText)) {
|
|
65
|
-
setTimeout(() => {
|
|
66
|
-
const submitBtn = buttons.find(b => /^(Submit|submit)/i.test(getBtnLabel(b)));
|
|
67
|
-
if (submitBtn && submitBtn !== targetBtn) submitBtn.click();
|
|
68
|
-
}, 150);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return JSON.stringify({ success: true, action, clicked: clickedText });
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return JSON.stringify({
|
|
75
|
-
success: false,
|
|
76
|
-
error: `No button matching '${searchText}' found`,
|
|
77
|
-
available: buttons.map(b => getBtnLabel(b)).filter(t => t.length > 0 && t.length < 80),
|
|
78
|
-
});
|
|
79
|
-
} catch (e) {
|
|
80
|
-
return JSON.stringify({ error: e.message || String(e) });
|
|
81
|
-
}
|
|
82
|
-
})()
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codex Extension — send_message
|
|
3
|
-
*
|
|
4
|
-
* Types a message into the ProseMirror input and submits it.
|
|
5
|
-
* Uses InputEvent dispatch for ProseMirror compatibility.
|
|
6
|
-
*
|
|
7
|
-
* Placeholder: ${MESSAGE}
|
|
8
|
-
*/
|
|
9
|
-
(() => {
|
|
10
|
-
try {
|
|
11
|
-
const message = ${MESSAGE};
|
|
12
|
-
|
|
13
|
-
// Find ProseMirror editor
|
|
14
|
-
const editor = document.querySelector('.ProseMirror');
|
|
15
|
-
if (!editor) return JSON.stringify({ error: 'Editor not found' });
|
|
16
|
-
|
|
17
|
-
// Focus the editor
|
|
18
|
-
editor.focus();
|
|
19
|
-
|
|
20
|
-
// Use execCommand to safely insert text. This avoids TrustedHTML errors
|
|
21
|
-
// and naturally triggers ProseMirror's state updates and Keyboard/Input events.
|
|
22
|
-
document.execCommand('selectAll', false, null);
|
|
23
|
-
document.execCommand('insertText', false, message);
|
|
24
|
-
|
|
25
|
-
// Wait a tick then submit via Enter key
|
|
26
|
-
setTimeout(() => {
|
|
27
|
-
const enterEvent = new KeyboardEvent('keydown', {
|
|
28
|
-
key: 'Enter',
|
|
29
|
-
code: 'Enter',
|
|
30
|
-
keyCode: 13,
|
|
31
|
-
which: 13,
|
|
32
|
-
bubbles: true,
|
|
33
|
-
cancelable: true,
|
|
34
|
-
});
|
|
35
|
-
editor.dispatchEvent(enterEvent);
|
|
36
|
-
}, 100);
|
|
37
|
-
|
|
38
|
-
return JSON.stringify({ sent: true, success: true, message: message.substring(0, 100) });
|
|
39
|
-
} catch (e) {
|
|
40
|
-
return JSON.stringify({ error: e.message || String(e) });
|
|
41
|
-
}
|
|
42
|
-
})()
|