A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
add cursor agent and auth flow (#8645)
Shahmir Varqhad7352323cc44
diff --git a/frontend/src/components/ai/ai-provider-icon.tsx b/frontend/src/components/ai/ai-provider-icon.tsxindex e09f52ae4a..62a6fb5562 100644--- a/frontend/src/components/ai/ai-provider-icon.tsx+++ b/frontend/src/components/ai/ai-provider-icon.tsx@@ -3,6 +3,7 @@import AnthropicIcon from "@marimo-team/llm-info/icons/anthropic.svg?inline";import BedrockIcon from "@marimo-team/llm-info/icons/aws.svg?inline";import AzureIcon from "@marimo-team/llm-info/icons/azure.svg?inline";+import CursorIcon from "@marimo-team/llm-info/icons/cursor.svg?inline";import DeepseekIcon from "@marimo-team/llm-info/icons/deepseek.svg?inline";import GitHubIcon from "@marimo-team/llm-info/icons/github.svg?inline";import GeminiIcon from "@marimo-team/llm-info/icons/googlegemini.svg?inline";@@ -34,6 +35,7 @@ const icons: Record<ProviderId | ExternalAgentId, string> = {wandb: WandbIcon,marimo: marimoIcon,opencode: OpencodeIcon,+ cursor: CursorIcon,};export interface AiProviderIconProps extends React.HTMLAttributes<HTMLImageElement> {diff --git a/frontend/src/components/chat/acp/agent-docs.tsx b/frontend/src/components/chat/acp/agent-docs.tsxindex eacc91e8c5..2aa02c19af 100644--- a/frontend/src/components/chat/acp/agent-docs.tsx+++ b/frontend/src/components/chat/acp/agent-docs.tsx@@ -50,11 +50,11 @@ const AgentDocItem = memo<AgentDocItemProps>(</div><div className="bg-muted/50 rounded-md p-2 border"><div className="flex items-start gap-2 text-xs">- <TerminalIcon className="h-4 w-4 mt-0.5 text-muted-foreground flex-shrink-0" />- <code className="text-xs font-mono break-words flex-1 whitespace-pre-wrap">+ <TerminalIcon className="h-4 w-4 mt-0.5 text-muted-foreground shrink-0" />+ <code className="text-xs font-mono wrap-break-word flex-1 whitespace-pre-wrap">{command}</code>- <div className="flex items-center gap-1 flex-shrink-0">+ <div className="flex items-center gap-1 shrink-0">{showCopy && (<Button size="xs" variant="outline" className="border"><CopyClipboardIcon value={command} className="h-3 w-3" />diff --git a/frontend/src/components/chat/acp/agent-panel.tsx b/frontend/src/components/chat/acp/agent-panel.tsxindex d19ac18005..44ed36b6c1 100644--- a/frontend/src/components/chat/acp/agent-panel.tsx+++ b/frontend/src/components/chat/acp/agent-panel.tsx@@ -1,6 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */-import { useAtom, useAtomValue } from "jotai";+import { useAtom } from "jotai";import {BotMessageSquareIcon,RefreshCwIcon,@@ -8,7 +8,7 @@ import {} from "lucide-react";import React, { memo, useEffect, useMemo, useRef, useState } from "react";import useEvent from "react-use-event-hook";-import { useAcpClient } from "use-acp";+import { JsonRpcError, useAcpClient } from "use-acp";import {ConnectionStatus,PermissionRequest,@@ -207,7 +207,6 @@ interface EmptyStateProps {const EmptyState = memo<EmptyStateProps>(({ currentAgentId, connectionState, onConnect, onDisconnect }) => {- const filename = useAtomValue(filenameAtom);return (<div className="flex flex-col h-full"><AgentPanelHeader@@ -223,7 +222,7 @@ const EmptyState = memo<EmptyStateProps>(<PanelEmptyStatetitle="No Agent Sessions"description="Create a new session to start a conversation"- action={<AgentSelector className="border-y-1 rounded" />}+ action={<AgentSelector className="border-y rounded" />}icon={<BotMessageSquareIcon />}/>{connectionState.status === "disconnected" && (@@ -232,10 +231,13 @@ const EmptyState = memo<EmptyStateProps>(title="Connect to an agent"description={<>- Start agents by running these commands in your terminal:+ <span>+ Start agents by running these commands in your terminal.+ </span><br />- Note: This must be in the directory{" "}- {Paths.dirname(filename ?? "")}+ <span>+ Authenticate with the agent before starting a session.+ </span></>}/>@@ -615,6 +617,15 @@ const ChatContent = memo<ChatContentProps>(ChatContent.displayName = "ChatContent";const NO_WS_SET = "_skip_auto_connect_";+const AUTH_REQUIRED_CODE = -32_000;++function getDataMessage(data: unknown): string | undefined {+ if (data != null && typeof data === "object" && "message" in data) {+ const msg = (data as Record<string, unknown>).message;+ return typeof msg === "string" ? msg : undefined;+ }+ return undefined;+}function getCwd(): string {const cwd = store.get(cwdAtom);@@ -705,14 +716,31 @@ const AgentPanel: React.FC = () => {} = acpClient;useEffect(() => {- agent?.initialize({- protocolVersion: 1,- clientCapabilities: {- fs: {- readTextFile: true,- writeTextFile: true,+ if (!agent) {+ return;+ }++ const initAndAuth = async () => {+ const response = await agent.initialize({+ protocolVersion: 1,+ clientCapabilities: {+ fs: {+ readTextFile: true,+ writeTextFile: true,+ },},- },+ });++ // We try to authenticate with the agent if it supports it.+ // The user must then restart the session+ const authMethods = response?.authMethods;+ if (authMethods && authMethods.length > 0) {+ await agent.authenticate({ methodId: authMethods[0].id });+ }+ };++ initAndAuth().catch((error) => {+ logger.error("Failed to initialize/authenticate agent", { error });});}, [agent]);@@ -1041,18 +1069,37 @@ const AgentPanel: React.FC = () => {const renderBody = () => {if (error) {+ const isAuthError =+ error instanceof JsonRpcError && error.code === AUTH_REQUIRED_CODE;+ const dataMessage =+ error instanceof JsonRpcError ? getDataMessage(error.data) : undefined;+ const displayError = dataMessage ? new Error(dataMessage) : error;+return (<ErrorBannerclassName="w-3/4 mx-auto mt-10"- error={error}+ error={displayError}action={- <Button- variant="linkDestructive"- size="sm"- onClick={() => setError(null)}- >- Dismiss- </Button>+ isAuthError ? (+ <Button+ variant="linkDestructive"+ size="sm"+ onClick={() => {+ setError(null);+ handleNewSession();+ }}+ >+ Restart session+ </Button>+ ) : (+ <Button+ variant="linkDestructive"+ size="sm"+ onClick={() => setError(null)}+ >+ Dismiss+ </Button>+ )}/>);diff --git a/frontend/src/components/chat/acp/agent-selector.tsx b/frontend/src/components/chat/acp/agent-selector.tsxindex eaf794b378..7b3f1ced67 100644--- a/frontend/src/components/chat/acp/agent-selector.tsx+++ b/frontend/src/components/chat/acp/agent-selector.tsx@@ -16,9 +16,7 @@ import {DropdownMenuSubTrigger,DropdownMenuTrigger,} from "@/components/ui/dropdown-menu";-import { useFilename } from "@/core/saving/filename";import { cn } from "@/utils/cn";-import { Paths } from "@/utils/paths";import { AgentDocs } from "./agent-docs";import {type AgentSession,@@ -55,17 +53,17 @@ const AVAILABLE_AGENTS = [displayName: "OpenCode",iconId: "opencode",},+ { id: "cursor", displayName: "Cursor", iconId: "cursor" },] as const;interface AgentMenuItemProps {agent: (typeof AVAILABLE_AGENTS)[number];onSelect: (agentId: ExternalAgentId) => void;existingSessions: AgentSession[];- filename: string | null;}const AgentMenuItem = memo<AgentMenuItemProps>(- ({ agent, onSelect, existingSessions, filename }) => {+ ({ agent, onSelect, existingSessions }) => {const sessionSupport = getAgentSessionSupport(agent.id);const hasExistingSession = existingSessions.some((s) => s.agentId === agent.id,@@ -108,11 +106,6 @@ const AgentMenuItem = memo<AgentMenuItemProps>(<div className="text-xs font-medium text-muted-foreground mb-3">To start a {agent.displayName} agent, run the following commandin your terminal.- <br />- Note: This must be in the directory{" "}- <code className="bg-muted font-mono">- {Paths.dirname(filename ?? "")}- </code></div><AgentDocs agents={[agent.id]} showCopy={true} /></div>@@ -126,7 +119,6 @@ AgentMenuItem.displayName = "AgentMenuItem";export const AgentSelector: React.FC<AgentSelectorProps> = memo(({ onSessionCreated, className }) => {- const filename = useFilename();const [sessionState, setSessionState] = useAtom(agentSessionStateAtom);const setActiveTab = useSetAtom(selectedTabAtom);const [isOpen, setIsOpen] = useState(false);@@ -165,7 +157,6 @@ export const AgentSelector: React.FC<AgentSelectorProps> = memo(agent={agent}onSelect={handleCreateSession}existingSessions={sessionState.sessions}- filename={filename}/>))}</DropdownMenuContent>diff --git a/frontend/src/components/chat/acp/state.ts b/frontend/src/components/chat/acp/state.tsindex 3199636127..6233d9c0c3 100644--- a/frontend/src/components/chat/acp/state.ts+++ b/frontend/src/components/chat/acp/state.ts@@ -11,7 +11,12 @@ import type { ExternalAgentSessionId, SessionSupportType } from "./types";// Typesexport type TabId = TypedString<"TabId">;-export type ExternalAgentId = "claude" | "gemini" | "codex" | "opencode";+export type ExternalAgentId =+ | "claude"+ | "gemini"+ | "codex"+ | "opencode"+ | "cursor";// No agents support loading sessions, so we limit to 1, otherwise// this is confusing to the user when switching between sessions@@ -225,7 +230,7 @@ export function getSessionsByAgent(}export function getAllAgentIds(): ExternalAgentId[] {- return ["claude", "gemini", "codex", "opencode"];+ return ["claude", "gemini", "codex", "opencode", "cursor"];}export function getAgentDisplayName(agentId: ExternalAgentId): string {@@ -245,6 +250,8 @@ interface AgentConfig {port: number;command: string;sessionSupport: SessionSupportType;+ /** One-time setup command the user must run before starting the agent. */+ loginHint?: string;}const AGENT_CONFIG: Record<ExternalAgentId, AgentConfig> = {@@ -268,6 +275,11 @@ const AGENT_CONFIG: Record<ExternalAgentId, AgentConfig> = {command: "npx opencode-ai acp",sessionSupport: "single",},+ cursor: {+ port: 3025,+ command: "agent acp",+ sessionSupport: "single",+ },};export function getAgentSessionSupport(diff --git a/packages/llm-info/icons/cursor.svg b/packages/llm-info/icons/cursor.svgnew file mode 100644index 0000000000..635d3ccdc6--- /dev/null+++ b/packages/llm-info/icons/cursor.svg@@ -0,0 +1,12 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg id="Ebene_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 466.73 532.09">+ <!-- Generator: Adobe Illustrator 29.6.1, SVG Export Plug-In . SVG Version: 2.1.1 Build 9) -->+ <defs>+ <style>+ .st0 {+ fill: #26251e;+ }+ </style>+ </defs>+ <path class="st0" d="M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"/>+</svg>\ No newline at end of file