@hanzo/browser-extension 1.7.2
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/.github/workflows/docs.yml +44 -0
- package/.github/workflows/release.yml +55 -0
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/browser-extension/README.md +43 -0
- package/dist/browser-extension/ai-worker.js +30 -0
- package/dist/browser-extension/background-firefox.js +617 -0
- package/dist/browser-extension/background.js +2737 -0
- package/dist/browser-extension/browser-control.js +683 -0
- package/dist/browser-extension/cdp-bridge-server.js +444 -0
- package/dist/browser-extension/chrome/ai-worker.js +571 -0
- package/dist/browser-extension/chrome/background.js +2737 -0
- package/dist/browser-extension/chrome/callback.html +17 -0
- package/dist/browser-extension/chrome/content-script.js +1270 -0
- package/dist/browser-extension/chrome/icon128.png +0 -0
- package/dist/browser-extension/chrome/icon16.png +0 -0
- package/dist/browser-extension/chrome/icon32.png +0 -0
- package/dist/browser-extension/chrome/icon48.png +0 -0
- package/dist/browser-extension/chrome/manifest.json +57 -0
- package/dist/browser-extension/chrome/popup.css +519 -0
- package/dist/browser-extension/chrome/popup.html +242 -0
- package/dist/browser-extension/chrome/popup.js +267 -0
- package/dist/browser-extension/chrome/sidebar.css +1176 -0
- package/dist/browser-extension/chrome/sidebar.html +280 -0
- package/dist/browser-extension/chrome/sidebar.js +778 -0
- package/dist/browser-extension/cli.js +233 -0
- package/dist/browser-extension/content-script.js +1270 -0
- package/dist/browser-extension/firefox/ai-worker.js +571 -0
- package/dist/browser-extension/firefox/background.js +617 -0
- package/dist/browser-extension/firefox/callback.html +17 -0
- package/dist/browser-extension/firefox/content-script.js +1270 -0
- package/dist/browser-extension/firefox/icon128.png +0 -0
- package/dist/browser-extension/firefox/icon16.png +0 -0
- package/dist/browser-extension/firefox/icon32.png +0 -0
- package/dist/browser-extension/firefox/icon48.png +0 -0
- package/dist/browser-extension/firefox/manifest.json +66 -0
- package/dist/browser-extension/firefox/popup.css +519 -0
- package/dist/browser-extension/firefox/popup.html +242 -0
- package/dist/browser-extension/firefox/popup.js +267 -0
- package/dist/browser-extension/firefox/sidebar.css +1176 -0
- package/dist/browser-extension/firefox/sidebar.html +280 -0
- package/dist/browser-extension/firefox/sidebar.js +778 -0
- package/dist/browser-extension/hanzo-browser-extension-firefox-1.1.0.zip +0 -0
- package/dist/browser-extension/icon128.png +0 -0
- package/dist/browser-extension/icon16.png +0 -0
- package/dist/browser-extension/icon32.png +0 -0
- package/dist/browser-extension/icon48.png +0 -0
- package/dist/browser-extension/manifest.json +57 -0
- package/dist/browser-extension/package.json +41 -0
- package/dist/browser-extension/popup.css +468 -0
- package/dist/browser-extension/popup.html +191 -0
- package/dist/browser-extension/popup.js +267 -0
- package/dist/browser-extension/safari/Info.plist +21 -0
- package/dist/browser-extension/safari/ai-worker.js +571 -0
- package/dist/browser-extension/safari/background.js +2737 -0
- package/dist/browser-extension/safari/callback.html +17 -0
- package/dist/browser-extension/safari/content-script.js +1270 -0
- package/dist/browser-extension/safari/icon128.png +0 -0
- package/dist/browser-extension/safari/icon16.png +0 -0
- package/dist/browser-extension/safari/icon32.png +0 -0
- package/dist/browser-extension/safari/icon48.png +0 -0
- package/dist/browser-extension/safari/popup.css +519 -0
- package/dist/browser-extension/safari/popup.html +242 -0
- package/dist/browser-extension/safari/popup.js +267 -0
- package/dist/browser-extension/safari/sidebar.css +1176 -0
- package/dist/browser-extension/safari/sidebar.html +280 -0
- package/dist/browser-extension/safari/sidebar.js +778 -0
- package/dist/browser-extension/sidebar.css +718 -0
- package/dist/browser-extension/sidebar.html +184 -0
- package/dist/browser-extension/sidebar.js +778 -0
- package/dist/browser-extension/webgpu-ai.js +495 -0
- package/dist/cdp-bridge-server.js +411 -0
- package/dist/safari/Hanzo AI/Hanzo AI.xcodeproj/project.pbxproj +1047 -0
- package/dist/safari/Hanzo AI/Hanzo AI.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-128@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-128@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-16@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-16@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-256@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-256@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-32@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-32@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-512@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-512@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/universal-icon-1024@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/Contents.json +6 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/LargeIcon.imageset/Contents.json +21 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/LargeIcon.imageset/icon128.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Resources/Base.lproj/Main.html +20 -0
- package/dist/safari/Hanzo AI/Shared (App)/Resources/Icon.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Resources/Script.js +24 -0
- package/dist/safari/Hanzo AI/Shared (App)/Resources/Style.css +61 -0
- package/dist/safari/Hanzo AI/Shared (App)/ViewController.swift +81 -0
- package/dist/safari/Hanzo AI/Shared (Extension)/SafariWebExtensionHandler.swift +42 -0
- package/dist/safari/Hanzo AI/iOS (App)/AppDelegate.swift +24 -0
- package/dist/safari/Hanzo AI/iOS (App)/Base.lproj/LaunchScreen.storyboard +36 -0
- package/dist/safari/Hanzo AI/iOS (App)/Base.lproj/Main.storyboard +38 -0
- package/dist/safari/Hanzo AI/iOS (App)/Info.plist +27 -0
- package/dist/safari/Hanzo AI/iOS (App)/SceneDelegate.swift +18 -0
- package/dist/safari/Hanzo AI/iOS (Extension)/Info.plist +13 -0
- package/dist/safari/Hanzo AI/macOS (App)/AppDelegate.swift +21 -0
- package/dist/safari/Hanzo AI/macOS (App)/Base.lproj/Main.storyboard +124 -0
- package/dist/safari/Hanzo AI/macOS (App)/Info.plist +8 -0
- package/dist/safari/Hanzo AI/macOS (Extension)/Info.plist +13 -0
- package/docs/_config.yml +13 -0
- package/docs/_layouts/default.html +435 -0
- package/docs/index.md +54 -0
- package/install-extension.sh +75 -0
- package/manifest.json +29 -0
- package/package.json +32 -0
- package/src/ai-worker.js +571 -0
- package/src/callback.html +17 -0
- package/src/chat-widget.tsx +93 -0
- package/src/icon128.png +0 -0
- package/src/icon16.png +0 -0
- package/src/icon32.png +0 -0
- package/src/icon48.png +0 -0
- package/src/manifest-firefox.json +66 -0
- package/src/manifest.json +57 -0
- package/src/package.json +41 -0
- package/src/popup.css +519 -0
- package/src/popup.html +242 -0
- package/src/popup.js +192 -0
- package/src/sidebar.css +1176 -0
- package/src/sidebar.html +280 -0
- package/src/sidebar.js +884 -0
- package/src/webgpu.d.ts +131 -0
- package/test/claude-integration.test.ts +251 -0
- package/test/server-frameworks-edge-cases.test.ts +145 -0
- package/test/server-frameworks.test.ts +395 -0
- package/test-cdp-connection.js +140 -0
- package/tsconfig.json +19 -0
package/src/popup.html
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Hanzo AI</title>
|
|
7
|
+
<link rel="stylesheet" href="popup.css">
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div class="container">
|
|
11
|
+
<header>
|
|
12
|
+
<svg class="logo" viewBox="0 0 67 67" xmlns="http://www.w3.org/2000/svg">
|
|
13
|
+
<path d="M22.21 67V44.6369H0V67H22.21Z" fill="currentColor"/>
|
|
14
|
+
<path d="M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z" fill="currentColor"/>
|
|
15
|
+
<path d="M22.21 0H0V22.3184H22.21V0Z" fill="currentColor"/>
|
|
16
|
+
<path d="M66.7198 0H44.5098V22.3184H66.7198V0Z" fill="currentColor"/>
|
|
17
|
+
<path d="M66.7198 67V44.6369H44.5098V67H66.7198Z" fill="currentColor"/>
|
|
18
|
+
</svg>
|
|
19
|
+
<h1>Hanzo AI</h1>
|
|
20
|
+
</header>
|
|
21
|
+
|
|
22
|
+
<!-- Login Section -->
|
|
23
|
+
<div id="login-section" class="section">
|
|
24
|
+
<h2>Sign In</h2>
|
|
25
|
+
<p class="subtitle">Connect to your Hanzo AI account</p>
|
|
26
|
+
<button id="login-btn" class="btn btn-primary">Sign in with Hanzo</button>
|
|
27
|
+
<p class="help-text">
|
|
28
|
+
<a href="https://hanzo.id/register" target="_blank">Create account</a> •
|
|
29
|
+
<a href="https://hanzo.id/forgot" target="_blank">Forgot password?</a>
|
|
30
|
+
</p>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<!-- Main Section (shown after login) -->
|
|
34
|
+
<div id="main-section" class="section hidden">
|
|
35
|
+
<div class="user-info">
|
|
36
|
+
<img id="user-avatar" class="avatar" src="" alt="">
|
|
37
|
+
<div>
|
|
38
|
+
<div id="user-name" class="user-name"></div>
|
|
39
|
+
<div id="user-email" class="user-email"></div>
|
|
40
|
+
</div>
|
|
41
|
+
<button id="logout-btn" class="btn-icon" title="Sign out">
|
|
42
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
|
43
|
+
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"/>
|
|
44
|
+
</svg>
|
|
45
|
+
</button>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div class="divider"></div>
|
|
49
|
+
|
|
50
|
+
<!-- Open Chat Panel -->
|
|
51
|
+
<button id="open-panel" class="btn btn-primary" style="margin-bottom: 16px;">
|
|
52
|
+
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
|
53
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
|
|
54
|
+
</svg>
|
|
55
|
+
Open Chat Panel
|
|
56
|
+
</button>
|
|
57
|
+
<button id="open-page-overlay" class="btn btn-secondary" style="margin-bottom: 16px;">
|
|
58
|
+
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
|
59
|
+
<path d="M4 4h16v12H8l-4 4V4z"/>
|
|
60
|
+
</svg>
|
|
61
|
+
Toggle On-Page Overlay
|
|
62
|
+
</button>
|
|
63
|
+
|
|
64
|
+
<!-- Features -->
|
|
65
|
+
<div class="features">
|
|
66
|
+
<div class="feature-toggle">
|
|
67
|
+
<label>
|
|
68
|
+
<input type="checkbox" id="source-maps" checked>
|
|
69
|
+
<span class="toggle"></span>
|
|
70
|
+
<div class="feature-info">
|
|
71
|
+
<strong>Source Maps</strong>
|
|
72
|
+
<small>Click-to-code navigation</small>
|
|
73
|
+
</div>
|
|
74
|
+
</label>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div class="feature-toggle">
|
|
78
|
+
<label>
|
|
79
|
+
<input type="checkbox" id="webgpu-ai" checked>
|
|
80
|
+
<span class="toggle"></span>
|
|
81
|
+
<div class="feature-info">
|
|
82
|
+
<strong>WebGPU AI</strong>
|
|
83
|
+
<small>Local AI inference</small>
|
|
84
|
+
</div>
|
|
85
|
+
</label>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div class="feature-toggle">
|
|
89
|
+
<label>
|
|
90
|
+
<input type="checkbox" id="browser-control">
|
|
91
|
+
<span class="toggle"></span>
|
|
92
|
+
<div class="feature-info">
|
|
93
|
+
<strong>Browser Control</strong>
|
|
94
|
+
<small>AI browser automation</small>
|
|
95
|
+
</div>
|
|
96
|
+
</label>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div class="feature-toggle">
|
|
100
|
+
<label>
|
|
101
|
+
<input type="checkbox" id="tab-filesystem">
|
|
102
|
+
<span class="toggle"></span>
|
|
103
|
+
<div class="feature-info">
|
|
104
|
+
<strong>Tab Filesystem</strong>
|
|
105
|
+
<small>Mount tabs as files</small>
|
|
106
|
+
</div>
|
|
107
|
+
</label>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<div class="divider"></div>
|
|
112
|
+
|
|
113
|
+
<!-- Browser Backend -->
|
|
114
|
+
<div class="setting-group backend-picker">
|
|
115
|
+
<h3>Browser Backend</h3>
|
|
116
|
+
<div class="backend-select-wrapper">
|
|
117
|
+
<select id="browser-backend">
|
|
118
|
+
<option value="auto">Auto (default)</option>
|
|
119
|
+
<option value="this">This Browser</option>
|
|
120
|
+
<option value="firefox">Firefox</option>
|
|
121
|
+
<option value="chrome">Chrome</option>
|
|
122
|
+
<option value="playwright">Playwright Only</option>
|
|
123
|
+
</select>
|
|
124
|
+
</div>
|
|
125
|
+
<div class="backend-status">
|
|
126
|
+
<span class="status-dot" id="bridge-status"></span>
|
|
127
|
+
<span id="bridge-detail" class="status-detail">Checking bridge...</span>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div class="divider"></div>
|
|
132
|
+
|
|
133
|
+
<!-- Connection Status -->
|
|
134
|
+
<div class="status">
|
|
135
|
+
<div class="status-item">
|
|
136
|
+
<span class="status-dot" id="zap-status"></span>
|
|
137
|
+
<span>ZAP Protocol</span>
|
|
138
|
+
<span id="zap-detail" class="status-detail">Discovering...</span>
|
|
139
|
+
</div>
|
|
140
|
+
<div class="status-item">
|
|
141
|
+
<span class="status-dot" id="mcp-status"></span>
|
|
142
|
+
<span>MCP Server</span>
|
|
143
|
+
<span id="mcp-port" class="status-detail">Fallback</span>
|
|
144
|
+
</div>
|
|
145
|
+
<div class="status-item">
|
|
146
|
+
<span class="status-dot" id="cdp-status"></span>
|
|
147
|
+
<span>CDP Bridge</span>
|
|
148
|
+
<span id="cdp-detail" class="status-detail">Checking...</span>
|
|
149
|
+
</div>
|
|
150
|
+
<div class="status-item">
|
|
151
|
+
<span class="status-dot" id="gpu-status"></span>
|
|
152
|
+
<span>WebGPU</span>
|
|
153
|
+
<span id="gpu-detail" class="status-detail">Checking...</span>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<div class="divider"></div>
|
|
158
|
+
|
|
159
|
+
<!-- Actions -->
|
|
160
|
+
<div class="actions">
|
|
161
|
+
<button id="test-connection" class="btn btn-secondary">Test Connection</button>
|
|
162
|
+
<button id="open-settings" class="btn btn-secondary">Settings</button>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<!-- Quick Guide -->
|
|
166
|
+
<div class="guide" style="margin-top: 16px;">
|
|
167
|
+
<h3>Quick Guide</h3>
|
|
168
|
+
<p><kbd>Alt</kbd> + <kbd>Click</kbd> any element to navigate to source</p>
|
|
169
|
+
<p><kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>H</kbd> to open Hanzo AI panel</p>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
<!-- Settings Section -->
|
|
174
|
+
<div id="settings-section" class="section hidden">
|
|
175
|
+
<div class="settings-header">
|
|
176
|
+
<button id="back-btn" class="btn-icon">
|
|
177
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
|
178
|
+
<path d="M19 12H5M12 19l-7-7 7-7"/>
|
|
179
|
+
</svg>
|
|
180
|
+
</button>
|
|
181
|
+
<h2>Settings</h2>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
<div class="settings-content">
|
|
185
|
+
<div class="setting-group">
|
|
186
|
+
<h3>Connection</h3>
|
|
187
|
+
<label>
|
|
188
|
+
MCP Port
|
|
189
|
+
<input type="number" id="mcp-port-setting" value="3001" min="1024" max="65535">
|
|
190
|
+
</label>
|
|
191
|
+
<label>
|
|
192
|
+
CDP Bridge Port
|
|
193
|
+
<input type="number" id="cdp-port-setting" value="9223" min="1024" max="65535">
|
|
194
|
+
</label>
|
|
195
|
+
<label>
|
|
196
|
+
ZAP Discovery Ports
|
|
197
|
+
<input type="text" id="zap-ports-setting" value="9999,9998,9997,9996,9995" placeholder="Comma-separated ports">
|
|
198
|
+
</label>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<div class="setting-group">
|
|
202
|
+
<h3>AI Models</h3>
|
|
203
|
+
<label>
|
|
204
|
+
Local Model Path
|
|
205
|
+
<input type="text" id="model-path" placeholder="/models/browser-control-4bit.bin">
|
|
206
|
+
</label>
|
|
207
|
+
<label>
|
|
208
|
+
Model Quantization
|
|
209
|
+
<select id="model-quant">
|
|
210
|
+
<option value="4bit">4-bit (Fastest)</option>
|
|
211
|
+
<option value="8bit">8-bit (Balanced)</option>
|
|
212
|
+
<option value="fp16">FP16 (Best Quality)</option>
|
|
213
|
+
</select>
|
|
214
|
+
</label>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
<div class="setting-group">
|
|
218
|
+
<h3>Browser Control</h3>
|
|
219
|
+
<label>
|
|
220
|
+
<input type="checkbox" id="safe-mode" checked>
|
|
221
|
+
Safe Mode (require confirmation for actions)
|
|
222
|
+
</label>
|
|
223
|
+
<label>
|
|
224
|
+
Max Workers
|
|
225
|
+
<input type="number" id="max-workers" value="3" min="1" max="10">
|
|
226
|
+
</label>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
<button id="save-settings" class="btn btn-primary">Save Settings</button>
|
|
230
|
+
|
|
231
|
+
<p class="help-text" style="margin-top: 16px;">
|
|
232
|
+
<a href="https://console.hanzo.ai" target="_blank">Console</a> •
|
|
233
|
+
<a href="https://billing.hanzo.ai" target="_blank">Billing</a> •
|
|
234
|
+
<a href="https://docs.hanzo.ai" target="_blank">Docs</a>
|
|
235
|
+
</p>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<script src="popup.js"></script>
|
|
241
|
+
</body>
|
|
242
|
+
</html>
|
package/src/popup.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// Hanzo AI — Popup Script
|
|
2
|
+
// Uses background message passing for auth (not direct storage access).
|
|
3
|
+
|
|
4
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
5
|
+
const loginSection = document.getElementById('login-section');
|
|
6
|
+
const mainSection = document.getElementById('main-section');
|
|
7
|
+
const settingsSection = document.getElementById('settings-section');
|
|
8
|
+
|
|
9
|
+
// Auth
|
|
10
|
+
const loginBtn = document.getElementById('login-btn');
|
|
11
|
+
const logoutBtn = document.getElementById('logout-btn');
|
|
12
|
+
|
|
13
|
+
// Open panel
|
|
14
|
+
const openPanel = document.getElementById('open-panel');
|
|
15
|
+
|
|
16
|
+
// Status dots
|
|
17
|
+
const zapStatus = document.getElementById('zap-status');
|
|
18
|
+
const zapDetail = document.getElementById('zap-detail');
|
|
19
|
+
const mcpStatus = document.getElementById('mcp-status');
|
|
20
|
+
const mcpPort = document.getElementById('mcp-port');
|
|
21
|
+
const cdpStatus = document.getElementById('cdp-status');
|
|
22
|
+
const cdpDetail = document.getElementById('cdp-detail');
|
|
23
|
+
const gpuStatus = document.getElementById('gpu-status');
|
|
24
|
+
const gpuDetail = document.getElementById('gpu-detail');
|
|
25
|
+
|
|
26
|
+
// Settings
|
|
27
|
+
const openSettings = document.getElementById('open-settings');
|
|
28
|
+
const backBtn = document.getElementById('back-btn');
|
|
29
|
+
const saveSettings = document.getElementById('save-settings');
|
|
30
|
+
const testConnection = document.getElementById('test-connection');
|
|
31
|
+
|
|
32
|
+
// --- Auth via background ---
|
|
33
|
+
function checkAuth() {
|
|
34
|
+
// Always show main section and status (tools work without login)
|
|
35
|
+
mainSection.classList.remove('hidden');
|
|
36
|
+
refreshStatus();
|
|
37
|
+
|
|
38
|
+
chrome.runtime.sendMessage({ action: 'auth.status' }, (response) => {
|
|
39
|
+
if (chrome.runtime.lastError) return;
|
|
40
|
+
if (response?.success && response.authenticated) {
|
|
41
|
+
loginSection.classList.add('hidden');
|
|
42
|
+
if (response.user) {
|
|
43
|
+
const avatar = document.getElementById('user-avatar');
|
|
44
|
+
const name = document.getElementById('user-name');
|
|
45
|
+
const email = document.getElementById('user-email');
|
|
46
|
+
avatar.src = response.user.picture || response.user.avatar || 'icon48.png';
|
|
47
|
+
name.textContent = response.user.name || response.user.displayName || 'Hanzo User';
|
|
48
|
+
email.textContent = response.user.email || '';
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
loginSection.classList.remove('hidden');
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
loginBtn?.addEventListener('click', () => {
|
|
57
|
+
loginBtn.disabled = true;
|
|
58
|
+
loginBtn.textContent = 'Signing in...';
|
|
59
|
+
chrome.runtime.sendMessage({ action: 'auth.login' }, (response) => {
|
|
60
|
+
loginBtn.disabled = false;
|
|
61
|
+
loginBtn.innerHTML = '<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4M10 17l5-5-5-5M15 12H3"/></svg> Sign in with Hanzo';
|
|
62
|
+
if (response?.success) {
|
|
63
|
+
checkAuth();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
logoutBtn?.addEventListener('click', () => {
|
|
69
|
+
chrome.runtime.sendMessage({ action: 'auth.logout' }, () => {
|
|
70
|
+
mainSection.classList.add('hidden');
|
|
71
|
+
loginSection.classList.remove('hidden');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// --- Open side panel ---
|
|
76
|
+
openPanel?.addEventListener('click', () => {
|
|
77
|
+
if (chrome.sidePanel) {
|
|
78
|
+
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
|
79
|
+
if (tabs[0]?.id) {
|
|
80
|
+
chrome.sidePanel.open({ tabId: tabs[0].id });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
// Firefox: sidebar_action is automatic
|
|
85
|
+
window.close();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// --- Status ---
|
|
90
|
+
function refreshStatus() {
|
|
91
|
+
// ZAP status
|
|
92
|
+
chrome.runtime.sendMessage({ action: 'zap.status' }, (response) => {
|
|
93
|
+
if (chrome.runtime.lastError) return;
|
|
94
|
+
if (response?.success) {
|
|
95
|
+
const zap = response.zap;
|
|
96
|
+
if (zap.connected) {
|
|
97
|
+
zapStatus.classList.add('connected');
|
|
98
|
+
zapStatus.classList.remove('disconnected');
|
|
99
|
+
const mcpCount = zap.mcps?.length || 0;
|
|
100
|
+
const toolCount = zap.mcps?.reduce((sum, m) => sum + (m.tools?.length || 0), 0) || 0;
|
|
101
|
+
zapDetail.textContent = `${mcpCount} MCP(s), ${toolCount} tools`;
|
|
102
|
+
} else {
|
|
103
|
+
zapStatus.classList.remove('connected');
|
|
104
|
+
zapStatus.classList.add('disconnected');
|
|
105
|
+
zapDetail.textContent = 'Not connected';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// GPU status
|
|
111
|
+
chrome.runtime.sendMessage({ action: 'runLocalAI', prompt: '' }, (response) => {
|
|
112
|
+
if (chrome.runtime.lastError) return;
|
|
113
|
+
gpuStatus.classList.add(response?.success ? 'connected' : 'disconnected');
|
|
114
|
+
gpuStatus.classList.remove(response?.success ? 'disconnected' : 'connected');
|
|
115
|
+
gpuDetail.textContent = response?.success ? 'Available' : 'Not available';
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// MCP/CDP — set as active for now (checked via ZAP)
|
|
119
|
+
mcpStatus.classList.add('connected');
|
|
120
|
+
mcpPort.textContent = 'Fallback';
|
|
121
|
+
cdpStatus.classList.add('connected');
|
|
122
|
+
cdpDetail.textContent = 'Active';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// --- Settings ---
|
|
126
|
+
openSettings?.addEventListener('click', () => {
|
|
127
|
+
mainSection.classList.add('hidden');
|
|
128
|
+
settingsSection.classList.remove('hidden');
|
|
129
|
+
loadSettings();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
backBtn?.addEventListener('click', () => {
|
|
133
|
+
settingsSection.classList.add('hidden');
|
|
134
|
+
mainSection.classList.remove('hidden');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
function loadSettings() {
|
|
138
|
+
chrome.storage.local.get(['mcpPort', 'cdpPort', 'zapPorts'], (result) => {
|
|
139
|
+
const mcpPortInput = document.getElementById('mcp-port-setting');
|
|
140
|
+
const cdpPortInput = document.getElementById('cdp-port-setting');
|
|
141
|
+
const zapPortsInput = document.getElementById('zap-ports-setting');
|
|
142
|
+
|
|
143
|
+
if (mcpPortInput) mcpPortInput.value = result.mcpPort || 3001;
|
|
144
|
+
if (cdpPortInput) cdpPortInput.value = result.cdpPort || 9223;
|
|
145
|
+
if (zapPortsInput) zapPortsInput.value = (result.zapPorts || [9999, 9998, 9997, 9996, 9995]).join(',');
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
saveSettings?.addEventListener('click', () => {
|
|
150
|
+
const mcpPortVal = parseInt(document.getElementById('mcp-port-setting')?.value) || 3001;
|
|
151
|
+
const cdpPortVal = parseInt(document.getElementById('cdp-port-setting')?.value) || 9223;
|
|
152
|
+
const zapPortsVal = (document.getElementById('zap-ports-setting')?.value || '')
|
|
153
|
+
.split(',').map(p => parseInt(p.trim())).filter(p => p > 0 && p < 65536);
|
|
154
|
+
|
|
155
|
+
chrome.storage.local.set({
|
|
156
|
+
mcpPort: mcpPortVal,
|
|
157
|
+
cdpPort: cdpPortVal,
|
|
158
|
+
zapPorts: zapPortsVal.length ? zapPortsVal : [9999, 9998, 9997, 9996, 9995],
|
|
159
|
+
}, () => {
|
|
160
|
+
saveSettings.textContent = 'Saved!';
|
|
161
|
+
setTimeout(() => { saveSettings.textContent = 'Save Settings'; }, 1500);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// --- Test Connection ---
|
|
166
|
+
testConnection?.addEventListener('click', () => {
|
|
167
|
+
testConnection.textContent = 'Testing...';
|
|
168
|
+
testConnection.disabled = true;
|
|
169
|
+
|
|
170
|
+
chrome.runtime.sendMessage({ action: 'zap.discover' }, () => {
|
|
171
|
+
refreshStatus();
|
|
172
|
+
testConnection.textContent = 'Test Connection';
|
|
173
|
+
testConnection.disabled = false;
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Feature toggles
|
|
178
|
+
['source-maps', 'webgpu-ai', 'browser-control', 'tab-filesystem'].forEach(id => {
|
|
179
|
+
const checkbox = document.getElementById(id);
|
|
180
|
+
if (checkbox) {
|
|
181
|
+
chrome.storage.local.get([id], (result) => {
|
|
182
|
+
checkbox.checked = result[id] !== false; // default on
|
|
183
|
+
});
|
|
184
|
+
checkbox.addEventListener('change', () => {
|
|
185
|
+
chrome.storage.local.set({ [id]: checkbox.checked });
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Init
|
|
191
|
+
checkAuth();
|
|
192
|
+
});
|