Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(marketplace): repair plugin connect flows
rubenluetke10-beep67545ae05eb8
diff --git a/jarvis/marketplace/catalog_data.py b/jarvis/marketplace/catalog_data.pyindex f580d871b5..feac900e7a 100644--- a/jarvis/marketplace/catalog_data.py+++ b/jarvis/marketplace/catalog_data.py@@ -68,6 +68,30 @@ _PORTABLE_MCP_MIGRATIONS: dict[str, tuple[dict[str, object], dict[str, object]]]),}+# Exact shipped discovery URLs that pointed at authorization-server metadata+# instead of the RFC 9728 protected-resource document. Existing installations+# may have copied these entries into data/plugin_catalog.json, whose auth block+# is intentionally user-owned. Upgrade only the known bad built-in value so a+# genuinely custom endpoint remains untouched.+_OAUTH_DISCOVERY_MIGRATIONS: dict[str, tuple[str, str]] = {+ "clickup": (+ "https://mcp.clickup.com/.well-known/oauth-authorization-server",+ "https://mcp.clickup.com/.well-known/oauth-protected-resource",+ ),+ "canva": (+ "https://mcp.canva.com/.well-known/oauth-authorization-server",+ "https://mcp.canva.com/.well-known/oauth-protected-resource",+ ),+ "airtable": (+ "https://airtable.com/.well-known/oauth-authorization-server/oauth2/v1",+ "https://mcp.airtable.com/.well-known/oauth-protected-resource",+ ),+ "cal_com": (+ "https://mcp.cal.com/.well-known/oauth-authorization-server",+ "https://mcp.cal.com/.well-known/oauth-protected-resource",+ ),+}+def _migrate_obsolete_mcp_transports(raw: object) -> object:"""Upgrade exact built-in launcher specs without changing user variants.@@ -92,6 +116,23 @@ def _migrate_obsolete_mcp_transports(raw: object) -> object:return raw+def _migrate_obsolete_oauth_discovery(raw: object) -> object:+ """Upgrade exact broken built-in discovery URLs in a local override."""+ if not isinstance(raw, dict) or not isinstance(raw.get("plugins"), list):+ return raw+ for plugin in raw["plugins"]:+ if not isinstance(plugin, dict):+ continue+ migration = _OAUTH_DISCOVERY_MIGRATIONS.get(str(plugin.get("id", "")))+ auth = plugin.get("auth")+ if migration is None or not isinstance(auth, dict):+ continue+ obsolete, current = migration+ if auth.get("discovery_url") == obsolete:+ auth["discovery_url"] = current+ return raw++# What a user's `data/` override is allowed to keep when the package seed also# knows the plugin: the connection details they may genuinely have customized# (their own OAuth client id, a self-hosted MCP endpoint). Everything else —@@ -165,6 +206,7 @@ def _read(path: Path) -> PluginCatalog:raw = _read_raw(path)if path.resolve() == _DEFAULT_CATALOG_PATH.resolve():raw = _migrate_obsolete_mcp_transports(raw)+ raw = _migrate_obsolete_oauth_discovery(raw)return PluginCatalog.model_validate(raw)@@ -177,6 +219,7 @@ def load_catalog(path: Path | None = None) -> PluginCatalog:if not _DEFAULT_CATALOG_PATH.exists():return _read(_PACKAGE_SEED_PATH)raw = _migrate_obsolete_mcp_transports(_read_raw(_DEFAULT_CATALOG_PATH))+ raw = _migrate_obsolete_oauth_discovery(raw)try:seed_raw = _read_raw(_PACKAGE_SEED_PATH)except (OSError, ValueError):diff --git a/jarvis/marketplace/seed_catalog.json b/jarvis/marketplace/seed_catalog.jsonindex 5420bce48f..4ff789fe19 100644--- a/jarvis/marketplace/seed_catalog.json+++ b/jarvis/marketplace/seed_catalog.json@@ -407,7 +407,7 @@"longevity_note": "ClickUp states its access token does not expire, so this connection needs no renewal. That is a policy rather than a guarantee, so Jarvis still asks you to reconnect if it is ever rejected.","auth": {"mode": "hosted_mcp_oauth_dcr",- "discovery_url": "https://mcp.clickup.com/.well-known/oauth-authorization-server",+ "discovery_url": "https://mcp.clickup.com/.well-known/oauth-protected-resource","mcp_url": "https://mcp.clickup.com/mcp","refresh_supported": false},@@ -449,7 +449,7 @@"longevity": "self_renewing","auth": {"mode": "hosted_mcp_oauth_dcr",- "discovery_url": "https://mcp.canva.com/.well-known/oauth-authorization-server",+ "discovery_url": "https://mcp.canva.com/.well-known/oauth-protected-resource","mcp_url": "https://mcp.canva.com/mcp","refresh_supported": true},@@ -472,7 +472,7 @@"longevity_note": "Airtable ends a connection after 60 days without use. Jarvis renews it in the background every 12 hours, so it stays open as long as this machine runs from time to time.","auth": {"mode": "hosted_mcp_oauth_dcr",- "discovery_url": "https://airtable.com/.well-known/oauth-authorization-server/oauth2/v1",+ "discovery_url": "https://mcp.airtable.com/.well-known/oauth-protected-resource","mcp_url": "https://mcp.airtable.com","refresh_supported": true},@@ -494,7 +494,7 @@"longevity_note": "Cal.com publishes no token lifetime, so how long this stays connected has not been confirmed. Jarvis renews it in the background and will ask you to reconnect if that ever fails.","auth": {"mode": "hosted_mcp_oauth_dcr",- "discovery_url": "https://mcp.cal.com/.well-known/oauth-authorization-server",+ "discovery_url": "https://mcp.cal.com/.well-known/oauth-protected-resource","mcp_url": "https://mcp.cal.com/mcp","refresh_supported": true},diff --git a/jarvis/ui/web/frontend/index.html b/jarvis/ui/web/frontend/index.htmlindex 611b6ecf72..a39c085eb7 100644--- a/jarvis/ui/web/frontend/index.html+++ b/jarvis/ui/web/frontend/index.html@@ -7,6 +7,7 @@<head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <link rel="icon" href="/jarvis.ico" sizes="any" /><link rel="icon" type="image/png" sizes="256x256" href="/jarvis-gigi-256.png" /><link rel="icon" type="image/x-icon" href="/jarvis-gigi.ico" /><!-- Neutral, trademark-free fallback title. The inline boot script belowdiff --git a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsxindex 9c1730f942..567066b31a 100644--- a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx@@ -220,6 +220,7 @@ describe("PkceConnectDialog own-client + production hint", () => {authMode: "oauth_pkce_loopback",authConfig: { mode: "oauth_pkce_loopback" },status: "not_connected",+ oauthClientConfigured: true,} as unknown as Parameters<typeof PkceConnectDialog>[0]["plugin"];it("shows the Google production hint with a console link", () => {@@ -272,6 +273,26 @@ describe("PkceConnectDialog own-client + production hint", () => {expect(calls).toContain("/api/secrets/google_oauth_client_secret");expect(onProceed).toHaveBeenCalledTimes(1);});++ it("blocks a placeholder-only provider until a client id is entered", () => {+ const slack = {+ ...gmail,+ id: "slack",+ name: "Slack",+ oauthClientFamily: "slack",+ oauthClientConfigured: false,+ };+ render(+ <PkceConnectDialog plugin={slack} onClose={() => {}} onProceed={() => {}} />,+ );++ expect(screen.getByText(/has no Slack OAuth client yet/i)).toBeDefined();+ expect(+ (screen.getByRole("button", { name: /^continue$/i }) as HTMLButtonElement)+ .disabled,+ ).toBe(true);+ expect(screen.getByLabelText(/client id/i)).toBeDefined();+ });});describe("PluginsView opens the PKCE pre-connect dialog", () => {diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.tsxindex 516c6b3214..a582ca159f 100644--- a/jarvis/ui/web/frontend/src/views/PluginsView.tsx+++ b/jarvis/ui/web/frontend/src/views/PluginsView.tsx@@ -447,7 +447,7 @@ export function PluginsView() {// Kick off the real OAuth handshake: /connect/start, open the URL, then the// dialog long-polls /connect/poll. Shared by the DCR/device path (called// directly) and the PKCE path (called by the pre-connect dialog's Continue).- const startOAuthFlow = async (p: Plugin) => {+ const startOAuthFlow = async (p: Plugin): Promise<boolean> => {try {const r = await oauthStart.mutateAsync(p.id);if (r.kind === "device_flow") {@@ -461,7 +461,7 @@ export function PluginsView() {const userCode = (r as unknown as { user_code?: string }).user_code;if (!verifyUrl || !userCode) {alert("Backend returned an incomplete device-flow session.");- return;+ return false;}// Auto-open the pre-filled verify URL if available; user lands// on the consent page with the code already typed in.@@ -477,11 +477,11 @@ export function PluginsView() {verificationUriComplete: verifyUrlComplete ?? null,expiresAtMs: r.expires_at_ms,});- return;+ return true;}if (!r.open_url) {alert("Backend returned no open_url — connect aborted.");- return;+ return false;}void openExternalUrl(r.open_url);setOauthSession({@@ -490,15 +490,31 @@ export function PluginsView() {pluginName: p.name,openUrl: r.open_url,});+ return true;} catch (e) {alert(`Could not start ${p.name} connect flow: ${e instanceof Error ? e.message : String(e)}`,);+ return false;}};+ const cancelOAuthSession = (session: {+ flowId: string;+ pluginId: string;+ }) => {+ void fetch(+ `/api/marketplace/plugins/${session.pluginId}/connect/${session.flowId}`,+ { method: "DELETE" },+ )+ .catch(() => undefined)+ .finally(() => {+ qc.invalidateQueries({ queryKey: ["marketplace-plugins"] });+ });+ };+const handleConnect = async (p: Plugin) => {if (p.authMode === "pat_paste") {setConnectingPlugin(p);@@ -742,7 +758,10 @@ export function PluginsView() {pluginId={oauthSession.pluginId}pluginName={oauthSession.pluginName}openUrl={oauthSession.openUrl}- onClose={() => setOauthSession(null)}+ onClose={() => {+ cancelOAuthSession(oauthSession);+ setOauthSession(null);+ }}onSuccess={() => {setOauthSession(null);qc.invalidateQueries({ queryKey: ["marketplace-plugins"] });@@ -759,7 +778,10 @@ export function PluginsView() {verificationUri={deviceSession.verificationUri}verificationUriComplete={deviceSession.verificationUriComplete}expiresAtMs={deviceSession.expiresAtMs}- onClose={() => setDeviceSession(null)}+ onClose={() => {+ cancelOAuthSession(deviceSession);+ setDeviceSession(null);+ }}onSuccess={() => {setDeviceSession(null);qc.invalidateQueries({ queryKey: ["marketplace-plugins"] });@@ -2017,11 +2039,12 @@ export function PkceConnectDialog({}: {plugin: Plugin;onClose: () => void;- onProceed: () => void | Promise<void>;+ onProceed: () => boolean | void | Promise<boolean | void>;}) {const fam = oauthClientFamily(plugin);const isGoogle = fam?.family === "google";- const [showClient, setShowClient] = useState(false);+ const clientRequired = Boolean(fam && !plugin.oauthClientConfigured);+ const [showClient, setShowClient] = useState(clientRequired);const [clientId, setClientId] = useState("");const [clientSecret, setClientSecret] = useState("");const [busy, setBusy] = useState(false);@@ -2062,8 +2085,8 @@ export function PkceConnectDialog({await writeSecret(`${fam.family}_oauth_client_id`, cid);if (csec) await writeSecret(`${fam.family}_oauth_client_secret`, csec);}- await onProceed();- onClose();+ const proceeded = await onProceed();+ if (proceeded !== false) onClose();} catch (e) {setErr(e instanceof Error ? e.message : String(e));} finally {@@ -2129,17 +2152,26 @@ export function PkceConnectDialog({{fam && (<div>+ {clientRequired && (+ <p className="mb-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] leading-relaxed text-amber-200">+ This installation has no {fam.label} OAuth client yet. Add+ your own Client ID below before browser sign-in can start.+ </p>+ )}<buttontype="button"onClick={() => setShowClient((v) => !v)}className="text-[11px] font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground">- Use your own OAuth client (advanced)+ {clientRequired+ ? "OAuth client setup required"+ : "Use your own OAuth client (advanced)"}</button>{showClient && (<div className="mt-2 space-y-2"><p className="text-[10px] leading-relaxed text-muted-foreground">- Optional. Paste a client from your own {fam.label}{" "}+ {clientRequired ? "Required. " : "Optional. "}Paste a client+ from your own {fam.label}{" "}{OAUTH_CLIENT_CONSOLE[fam.family] && (<ahref={OAUTH_CLIENT_CONSOLE[fam.family]}@@ -2209,7 +2241,7 @@ export function PkceConnectDialog({<buttontype="button"onClick={handleContinue}- disabled={busy}+ disabled={busy || (clientRequired && !clientId.trim())}className="inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-semibold text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-60">{busy && <Loader2 className="h-3 w-3 animate-spin" />}diff --git a/jarvis/ui/web/server.py b/jarvis/ui/web/server.pyindex c13aafa808..2973b2ba81 100644--- a/jarvis/ui/web/server.py+++ b/jarvis/ui/web/server.py@@ -23,7 +23,7 @@ from uuid import uuid4from fastapi import FastAPI, WebSocket, WebSocketDisconnectfrom fastapi.middleware.cors import CORSMiddleware-from fastapi.responses import FileResponse, HTMLResponse, JSONResponse+from fastapi.responses import FileResponse, HTMLResponse, JSONResponse, Responsefrom fastapi.staticfiles import StaticFilesfrom loguru import loggerfrom pydantic import ValidationError@@ -911,6 +911,14 @@ class WebServer:async def health() -> dict[str, Any]:return {"ok": True, "version": __version__}+ @app.post("/api/ui/shell-painted", status_code=204, response_model=None)+ async def shell_painted() -> Response:+ # FastBootstrap consumes this acknowledgement during warm-up. A+ # browser can paint after the full FastAPI app has already taken+ # over, so the live app must accept the same POST as an idempotent+ # no-op instead of returning FastAPI's 405 Method Not Allowed.+ return Response(status_code=204)+@app.get("/api/config")async def get_config() -> dict[str, Any]:# Read-only snapshot — secrets are, by design, never in the config.diff --git a/tests/unit/marketplace/test_catalog_seed.py b/tests/unit/marketplace/test_catalog_seed.pyindex 0698be8547..243d243dfa 100644--- a/tests/unit/marketplace/test_catalog_seed.py+++ b/tests/unit/marketplace/test_catalog_seed.py@@ -177,6 +177,50 @@ def test_default_override_migrates_only_exact_obsolete_mcp_launchers(clear_cache()+def test_default_override_migrates_only_exact_obsolete_oauth_discovery(+ monkeypatch, tmp_path+) -> None:+ clear_cache()+ seed = json.loads(catalog_data._PACKAGE_SEED_PATH.read_text(encoding="utf-8"))+ clickup = next(item for item in seed["plugins"] if item["id"] == "clickup")+ canva = next(item for item in seed["plugins"] if item["id"] == "canva")+ clickup["auth"]["discovery_url"] = (+ "https://mcp.clickup.com/.well-known/oauth-authorization-server"+ )+ custom = "https://oauth.example.test/custom-protected-resource"+ canva["auth"]["discovery_url"] = custom+ override = tmp_path / "plugin_catalog.json"+ override.write_text(+ json.dumps(+ {"version": 1, "schema_version": "old", "plugins": [clickup, canva]}+ ),+ encoding="utf-8",+ )+ monkeypatch.setattr(catalog_data, "_DEFAULT_CATALOG_PATH", override)++ catalog = load_catalog()++ assert catalog.by_id("clickup").auth.discovery_url == (+ "https://mcp.clickup.com/.well-known/oauth-protected-resource"+ )+ assert catalog.by_id("canva").auth.discovery_url == custom+ clear_cache()+++def test_seed_dcr_connectors_begin_at_protected_resource_metadata() -> None:+ catalog = _seed()+ expected = {+ "clickup": "https://mcp.clickup.com/.well-known/oauth-protected-resource",+ "canva": "https://mcp.canva.com/.well-known/oauth-protected-resource",+ "airtable": "https://mcp.airtable.com/.well-known/oauth-protected-resource",+ "cal_com": "https://mcp.cal.com/.well-known/oauth-protected-resource",+ }+ assert {+ plugin_id: catalog.by_id(plugin_id).auth.discovery_url+ for plugin_id in expected+ } == expected++def _seed():"""Load the tracked package seed directly (independent of any data/ override)."""clear_cache()diff --git a/tests/unit/marketplace/test_connect_token_save_failure.py b/tests/unit/marketplace/test_connect_token_save_failure.pyindex 5d366fa75e..f5839171d3 100644--- a/tests/unit/marketplace/test_connect_token_save_failure.py+++ b/tests/unit/marketplace/test_connect_token_save_failure.py@@ -118,3 +118,42 @@ async def test_connect_poll_reports_connected_when_save_succeeds(result = await mr.connect_poll(plugin_id, flow_id)assert result["state"] == "connected"assert saved # the token was actually persisted before the state flipped+++async def test_cancelled_reconnect_does_not_replace_needs_reauth_grant(+ monkeypatch, _capture_background_tasks+) -> None:+ release = asyncio.Event()++ class _DelayedPkceHandler(_StubPkceHandler):+ async def await_completion(self, session: AuthSession) -> FlowResult:+ await release.wait()+ return FlowResult(tokens=Tokens(access="replacement"), error=None)++ spec = _pkce_spec("real-client-id.apps.example")+ store: dict[str, Tokens] = {+ spec.id: Tokens(access="expired", needs_reauth=True)+ }++ class _Store:+ def save(self, plugin_id: str, tokens: Tokens) -> None:+ store[plugin_id] = tokens++ monkeypatch.setattr(mr, "load_catalog", lambda: _Catalog([spec]))+ monkeypatch.setattr(+ "jarvis.marketplace.connect_helpers.resolve_pkce_client",+ lambda pid, cid, csec: ("real-client-id.apps.example", None),+ )+ monkeypatch.setattr(mr, "PkceLoopbackHandler", _DelayedPkceHandler)+ monkeypatch.setattr(mr, "TokenStore", _Store)++ session = await mr.connect_start(spec.id, BackgroundTasks())+ result = await mr.cancel_connect(spec.id, session["flow_id"])+ release.set()+ for task in _capture_background_tasks:+ await task++ assert result["state"] == "cancelled"+ assert store[spec.id].access == "expired"+ assert store[spec.id].needs_reauth is Truediff --git a/tests/unit/marketplace/test_plugin_status.py b/tests/unit/marketplace/test_plugin_status.pyindex 9c126e8ece..da73973b39 100644--- a/tests/unit/marketplace/test_plugin_status.py+++ b/tests/unit/marketplace/test_plugin_status.py@@ -80,6 +80,28 @@ async def test_list_plugins_marks_native_tool_as_live_callable(monkeypatch):assert payload["plugins"][0]["live_callable"] is True+async def test_list_plugins_exposes_only_pkce_client_configuration_state(monkeypatch):+ """The UI may learn that a client exists, but never its id or secret."""+ from fastapi import Response++ from jarvis.ui.web import marketplace_routes++ catalog = _gmail_catalog()+ monkeypatch.setattr(marketplace_routes, "load_catalog", lambda: catalog)+ monkeypatch.setattr(marketplace_routes, "TokenStore", lambda: TokenStore(InMemoryBackend()))+ monkeypatch.setattr(+ "jarvis.marketplace.connect_helpers.resolve_pkce_client",+ lambda plugin_id, client_id, client_secret: ("configured-client", "private"),+ )++ item = (await marketplace_routes.list_plugins(Response()))["plugins"][0]++ assert item["oauth_client_configured"] is True+ assert "configured-client" not in repr(item)+ assert "private" not in repr(item)++def _gmail_catalog():from jarvis.marketplace.catalog import PluginCatalog, PluginSpecdiff --git a/tests/unit/ui/web/test_fast_bootstrap.py b/tests/unit/ui/web/test_fast_bootstrap.pyindex fd722dd800..0e312557ec 100644--- a/tests/unit/ui/web/test_fast_bootstrap.py+++ b/tests/unit/ui/web/test_fast_bootstrap.py@@ -290,6 +290,7 @@ def test_boot_page_acknowledges_after_two_frames() -> None:html = page.read_text(encoding="utf-8")assert "/api/ui/shell-painted" in htmlassert html.count("requestAnimationFrame") >= 2+ assert '<link rel="icon" href="/jarvis.ico"' in html# --- listener self-healing (the lock-zombie root cause) ---------------------diff --git a/tests/unit/ui/web/test_shell_painted_route.py b/tests/unit/ui/web/test_shell_painted_route.pynew file mode 100644index 0000000000..ff65709901--- /dev/null+++ b/tests/unit/ui/web/test_shell_painted_route.py@@ -0,0 +1,21 @@+"""The shell-paint acknowledgement is valid before and after full-app handoff."""++from fastapi.testclient import TestClient++from jarvis.core.bus import EventBus+from jarvis.core.config import JarvisConfig+from jarvis.ui.web.server import WebServer+++def test_full_app_accepts_shell_painted_acknowledgement() -> None:+ server = WebServer(JarvisConfig(), bus=EventBus())+ origin = "http://localhost:47821"++ with TestClient(server.app, base_url=origin) as client:+ response = client.post(+ "/api/ui/shell-painted",+ headers={"Origin": origin},+ )++ assert response.status_code == 204+ assert response.content == b""