Documentation
¶
Index ¶
- Constants
- func AccessTokenExpiry(token string) time.Time
- func AssistantTextFromMessage(data []byte) (string, bool)
- func CanonicalCursorModelID(id string) string
- func DedupeVariantIDs(ids []string) []string
- func DefaultModelIDs() []string
- func DesktopAccessToken() string
- func FastModelIDs() []string
- func ListAvailableModels(ctx context.Context, accessToken string) ([]string, error)
- func MintUserAPIKey(ctx context.Context, accessToken string) (string, error)
- func ModelSupportsFast(id string) bool
- func ResolveAgentModelID(model string) string
- func ResolveChatModelID(id, effort string, fast bool) string
- func SetChatEndpointForTest(url string) func()
- func SetEndpointsForTest(poll, refresh, mint string) func()
- func SetModelCaps(caps ModelCaps)
- func SetModelsEndpointForTest(url string) func()
- func StreamChat(ctx context.Context, accessToken, model string, turns []ChatTurn, ...) (string, error)
- func ThinkingLevelIDs() []string
- func ThinkingMode(id string) string
- func ThinkingToggleIDs() []string
- type AgentEvent
- type AgentExecRequest
- type AgentImage
- type AgentKVRequest
- type AgentNativeRequest
- type AgentQueryRequest
- type AgentSession
- func (s *AgentSession) Close()
- func (s *AgentSession) ContextResult(id uint32, execID, system string, tools []AgentTool) error
- func (s *AgentSession) KVResult(request AgentKVRequest) error
- func (s *AgentSession) LatestAssistantText() (string, bool)
- func (s *AgentSession) MCPStateResult(request AgentExecRequest, tools []AgentTool) error
- func (s *AgentSession) Next(ctx context.Context) (AgentEvent, bool)
- func (s *AgentSession) RejectNative(request AgentNativeRequest) error
- func (s *AgentSession) RejectQuery(query AgentQueryRequest) error
- func (s *AgentSession) ToolResult(call AgentToolCall, content string, isError bool) error
- func (s *AgentSession) Write(payload []byte) error
- type AgentTool
- type AgentToolCall
- type AuthParams
- type ChatResult
- type ChatTool
- type ChatToolCall
- type ChatTurn
- type ChatUsage
- type ModelCaps
- type ModelFlag
- type TokenSet
Constants ¶
const (
APIBase = "https://api2.cursor.sh"
)
Variables ¶
This section is empty.
Functions ¶
func AccessTokenExpiry ¶
func AssistantTextFromMessage ¶
AssistantTextFromMessage extracts displayable text from a Cursor KV message blob. Reasoning and non-text parts are intentionally excluded.
func CanonicalCursorModelID ¶
func DedupeVariantIDs ¶
func DefaultModelIDs ¶
func DefaultModelIDs() []string
func DesktopAccessToken ¶
func DesktopAccessToken() string
func FastModelIDs ¶
func FastModelIDs() []string
func ListAvailableModels ¶
func ModelSupportsFast ¶
func ResolveAgentModelID ¶ added in v2026.1009.0
ResolveAgentModelID converts Solomon's catalog ID to the Agent service slug, preserving variant suffixes. The catalog prefixes Grok IDs with "cursor-".
func ResolveChatModelID ¶
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 ThinkingLevelIDs ¶
func ThinkingLevelIDs() []string
func ThinkingMode ¶
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 AgentImage ¶
type AgentKVRequest ¶
type AgentNativeRequest ¶
type AgentNativeRequest struct {
AgentExecRequest
Kind string
ResultField, RejectedField, ReasonField int
}
type AgentQueryRequest ¶
type AgentSession ¶
type AgentSession struct {
// contains filtered or unexported fields
}
func OpenAgentSession ¶
func OpenAgentSession(ctx context.Context, apiKey, model, system, user string, tools []AgentTool, history [][]byte, images []AgentImage) (*AgentSession, error)
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.
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) error
func (*AgentSession) Write ¶
func (s *AgentSession) Write(payload []byte) error
type AgentToolCall ¶
type AuthParams ¶
func GenerateAuthParams ¶
func GenerateAuthParams() (AuthParams, error)
type ChatResult ¶
type ChatResult struct {
Content string
ToolCalls []ChatToolCall
FinishReason string
Usage ChatUsage
}
type ChatTool ¶
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 ModelCaps ¶
type ModelCaps struct {
IDs []string
Fast []string
ThinkingToggle []string
ThinkingLevels []string
Variants []string
}