(url: string)
| 187 | |
| 188 | // Handle deep link |
| 189 | function handleDeepLink(url: string): void { |
| 190 | console.log("[DeepLink] Received:", url) |
| 191 | |
| 192 | try { |
| 193 | const parsed = new URL(url) |
| 194 | |
| 195 | // Handle auth callback: twentyfirst-agents://auth?code=xxx |
| 196 | if (parsed.pathname === "/auth" || parsed.host === "auth") { |
| 197 | const code = parsed.searchParams.get("code") |
| 198 | if (code) { |
| 199 | handleAuthCode(code) |
| 200 | return |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // Handle MCP OAuth callback: twentyfirst-agents://mcp-oauth?code=xxx&state=yyy |
| 205 | if (parsed.pathname === "/mcp-oauth" || parsed.host === "mcp-oauth") { |
| 206 | const code = parsed.searchParams.get("code") |
| 207 | const state = parsed.searchParams.get("state") |
| 208 | if (code && state) { |
| 209 | handleMcpOAuthCallback(code, state) |
| 210 | return |
| 211 | } |
| 212 | } |
| 213 | } catch (e) { |
| 214 | console.error("[DeepLink] Failed to parse:", e) |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | // Register protocol BEFORE app is ready |
| 219 | console.log("[Protocol] ========== PROTOCOL REGISTRATION ==========") |
no test coverage detected