Documentation
¶
Overview ¶
Package cursor provides an ACP client for Cursor CLI via its `agent acp` subprocess (https://cursor.com/docs/cli/acp).
Index ¶
Constants ¶
const ACPSubcommand = "acp"
ACPSubcommand is the subcommand that puts Cursor CLI into ACP mode.
const BinaryName = "cursor-agent"
BinaryName is the preferred name of the Cursor CLI binary. Cursor's documentation calls the binary `agent`; we prefer the disambiguated `cursor-agent` name and fall back to `agent`.
Variables ¶
var DefaultBinaryPaths = []string{
"cursor-agent",
"agent",
".local/bin/cursor-agent",
".local/bin/agent",
"/usr/local/bin/cursor-agent",
"/usr/local/bin/agent",
"/usr/bin/cursor-agent",
"/usr/bin/agent",
}
DefaultBinaryPaths lists common installation locations for the Cursor CLI binary. The Cursor installer places the binary at ~/.local/bin/agent; we also look for a disambiguated `cursor-agent` in the same locations.
Functions ¶
This section is empty.
Types ¶
type RunRequest ¶
type RunRequest struct {
Prompt string // Prompt to send to Cursor CLI
SessionID string // Optional session ID to resume
CWD string // Working directory
Env []string // Additional environment variables
Command []string // Optional command override for testing (defaults to cursor-agent acp)
// Cursor-specific options
APIKey string // Optional; if set, passed as --api-key. Prefer CURSOR_API_KEY env var.
AuthToken string // Optional; if set, passed as --auth-token. Prefer CURSOR_AUTH_TOKEN env var.
Endpoint string // Optional API endpoint override (e.g. https://api2.cursor.sh).
Model string // Optional model hint (informational; Cursor picks per-task).
Debug bool // Enable verbose/debug output if supported by the CLI.
}
RunRequest describes a Cursor CLI prompt turn.
type Runner ¶
type Runner struct {
// ClientInfo identifies this client to the agent.
ClientInfo acp.Implementation
// Binary is the path to the cursor-agent (or `agent`) binary.
// If empty, uses the first found in DefaultBinaryPaths.
Binary string
// Logger for connection debugging.
Logger *slog.Logger
// ExtraEnv is additional environment variables to pass to the subprocess.
ExtraEnv []string
}
Runner launches Cursor CLI in ACP mode and manages the client-side connection. Authentication is taken from the environment (CURSOR_API_KEY / CURSOR_AUTH_TOKEN) unless explicitly overridden.
func (Runner) Start ¶
func (r Runner) Start(ctx context.Context, req RunRequest) (*RunningSession, error)
Start launches the Cursor CLI subprocess and begins the ACP flow.
type RunningSession ¶
type RunningSession struct {
// contains filtered or unexported fields
}
RunningSession represents one in-flight Cursor CLI prompt turn.
func (*RunningSession) Cancel ¶
func (s *RunningSession) Cancel() error
Cancel terminates the running subprocess.
func (*RunningSession) Done ¶
func (s *RunningSession) Done() <-chan struct{}
Done is closed when the prompt turn finishes.
func (*RunningSession) Events ¶
func (s *RunningSession) Events() <-chan shared.Event
Events returns the translated local ACP event stream.
func (*RunningSession) Wait ¶
func (s *RunningSession) Wait() shared.RunResult
Wait blocks until the turn completes and returns the final result.