cursor

package
v2026.1105.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	APIBase = "https://api2.cursor.sh"
)

Variables

This section is empty.

Functions

func AccessTokenExpiry

func AccessTokenExpiry(token string) time.Time

func AgentToolResultMessageForTest added in v2026.1030.0

func AgentToolResultMessageForTest(call AgentToolCall, content string, isError bool, images []AgentImage) []byte

AgentToolResultMessageForTest exposes the encoded result without opening a session.

func AgentWireModel added in v2026.1105.0

func AgentWireModel(id string) string

func AssistantTextFromMessage

func AssistantTextFromMessage(data []byte) (string, bool)

AssistantTextFromMessage extracts displayable text from a Cursor KV message blob. Reasoning and non-text parts are intentionally excluded.

func CanonicalCursorModelID

func CanonicalCursorModelID(id string) string

func DedupeVariantIDs

func DedupeVariantIDs(ids []string) []string

func DefaultModelIDs

func DefaultModelIDs() []string

func DesktopAccessToken

func DesktopAccessToken() string

func EncodeRequestedModel added in v2026.1105.0

func EncodeRequestedModel(model string, params []AgentModelParam) []byte

func FastModelIDs

func FastModelIDs() []string

func ListAvailableModels

func ListAvailableModels(ctx context.Context, accessToken string) ([]string, error)

func MintUserAPIKey

func MintUserAPIKey(ctx context.Context, accessToken string) (string, error)

func ModelSupportsFast

func ModelSupportsFast(id string) bool

func ResolveAgentModelID added in v2026.1009.0

func ResolveAgentModelID(model string) string

ResolveAgentModelID converts Solomon's catalog ID to the Agent service slug, preserving variant suffixes. The catalog prefixes Grok IDs with "cursor-".

func ResolveChatModelID

func ResolveChatModelID(id, effort string, fast bool) string

func SetChatEndpointForTest

func SetChatEndpointForTest(url string) func()

func SetEndpointsForTest

func SetEndpointsForTest(poll, refresh, mint string) func()

func SetModelCaps

func SetModelCaps(caps ModelCaps)

func SetModelsEndpointForTest

func SetModelsEndpointForTest(url string) func()

func StreamChat

func StreamChat(ctx context.Context, accessToken, model string, turns []ChatTurn, out io.Writer) (string, error)

func ThinkingLevelIDs

func ThinkingLevelIDs() []string

func ThinkingMode

func ThinkingMode(id string) string

func ThinkingToggleIDs

func ThinkingToggleIDs() []string

Types

type AgentEvent

type AgentEvent struct {
	Text, Thinking string
	Unknown        string
	Ended          bool
	Tool           *AgentToolCall
	Context        *AgentExecRequest
	MCPState       *AgentExecRequest
	KV             *AgentKVRequest
	Native         *AgentNativeRequest
	Query          *AgentQueryRequest
	Usage          ChatUsage
	Err            error
}

func DecodeAgentServerMessage

func DecodeAgentServerMessage(data []byte) AgentEvent

type AgentExecRequest

type AgentExecRequest struct {
	ID     uint32
	ExecID string
}

type AgentImage

type AgentImage struct {
	Data           []byte
	Mime, Filename string
}

type AgentKVRequest

type AgentKVRequest struct {
	ID               uint32
	BlobID, BlobData []byte
	Set              bool
}

type AgentModelParam added in v2026.1105.0

type AgentModelParam struct {
	ID    string
	Value string
}

OpenAgentSession uses Cursor's subscription Agent Connect endpoint directly. The API key is exchanged for a short-lived access token; no local Cursor process, CLI config or sidecar participates in the request.

type AgentNativeRequest

type AgentNativeRequest struct {
	AgentExecRequest
	Kind                                    string
	ResultField, RejectedField, ReasonField int
}

type AgentQueryRequest

type AgentQueryRequest struct {
	ID   uint32
	Kind int
}

type AgentSession

type AgentSession struct {
	// contains filtered or unexported fields
}

func OpenAgentSession

func OpenAgentSession(ctx context.Context, apiKey, model, system, user string, params []AgentModelParam, tools []AgentTool, history [][]byte, images []AgentImage) (*AgentSession, error)

func (*AgentSession) Close

func (s *AgentSession) Close()

func (*AgentSession) ContextResult

func (s *AgentSession) ContextResult(id uint32, execID, system string, tools []AgentTool) error

func (*AgentSession) KVResult

func (s *AgentSession) KVResult(request AgentKVRequest) error

func (*AgentSession) LatestAssistantText

func (s *AgentSession) LatestAssistantText() (string, bool)

LatestAssistantText returns the text in the newest assistant message Cursor persisted during this session. Some Agent responses persist their final message in the KV store without sending a text-delta event.

func (*AgentSession) MCPStateResult

func (s *AgentSession) MCPStateResult(request AgentExecRequest, tools []AgentTool) error

func (*AgentSession) Next

func (s *AgentSession) Next(ctx context.Context) (AgentEvent, bool)

func (*AgentSession) RejectNative

func (s *AgentSession) RejectNative(request AgentNativeRequest) error

func (*AgentSession) RejectQuery

func (s *AgentSession) RejectQuery(query AgentQueryRequest) error

func (*AgentSession) ToolResult

func (s *AgentSession) ToolResult(call AgentToolCall, content string, isError bool, images ...AgentImage) error

func (*AgentSession) Write

func (s *AgentSession) Write(payload []byte) error

type AgentTool

type AgentTool struct {
	Name, Description string
	Schema            []byte
}

AgentTool is a tool made available to Cursor's Agent service by Solomon.

type AgentToolCall

type AgentToolCall struct {
	ID, Name, Arguments, ExecID string
	ExecNumber                  uint32
}

type AuthParams

type AuthParams struct {
	Verifier  string
	Challenge string
	UUID      string
	LoginURL  string
}

func GenerateAuthParams

func GenerateAuthParams() (AuthParams, error)

type ChatResult

type ChatResult struct {
	Content      string
	ToolCalls    []ChatToolCall
	FinishReason string
	Usage        ChatUsage
}

func StreamChatWithTools

func StreamChatWithTools(ctx context.Context, accessToken, model string, turns []ChatTurn, tools []ChatTool, out io.Writer) (ChatResult, error)

type ChatTool

type ChatTool struct {
	Name        string
	Description string
	Parameters  map[string]any
}

ChatTool is the provider-neutral tool description used by the Go Cursor client. Cursor's current inference API receives these as protobuf Structs.

type ChatToolCall

type ChatToolCall struct {
	ID        string
	Name      string
	Arguments string
}

type ChatTurn

type ChatTurn struct {
	Role       string
	Content    string
	ToolCalls  []ChatToolCall
	ToolCallID string
	ToolName   string
	ToolError  bool
}

type ChatUsage

type ChatUsage struct {
	PromptTokens       int64
	CompletionTokens   int64
	TotalTokens        int64
	CachedPromptTokens int64
	CacheWriteTokens   int64
	ReasoningTokens    int64
}

type ModelCaps

type ModelCaps struct {
	IDs            []string
	Fast           []string
	ThinkingToggle []string
	ThinkingLevels []string
	Variants       []string
}

func DedupeVariantFlags

func DedupeVariantFlags(items []ModelFlag) ModelCaps

type ModelFlag

type ModelFlag struct {
	ID             string
	Raw            string
	Fast           bool
	Thinking       bool
	ThinkingLevels bool
}

func ListAvailableModelFlags

func ListAvailableModelFlags(ctx context.Context, accessToken string) ([]ModelFlag, error)

type TokenSet

type TokenSet struct {
	AccessToken  string
	RefreshToken string
	APIKey       string
	ExpiresAt    time.Time
}

func Login

func Login(ctx context.Context, out io.Writer) (ts TokenSet, err error)

func PollForAuth

func PollForAuth(ctx context.Context, uuid, verifier string) (TokenSet, error)

func Refresh

func Refresh(ctx context.Context, refreshToken string) (TokenSet, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL