Class: AgentHarness::Providers::Cursor
- Inherits:
-
Base
- Object
- Base
- AgentHarness::Providers::Cursor
show all
- Defined in:
- lib/agent_harness/providers/cursor.rb
Overview
Cursor AI CLI provider
Provides integration with the Cursor AI coding assistant via its CLI tool.
Constant Summary
Constants inherited
from Base
Base::COMMON_ERROR_PATTERNS, Base::DEFAULT_SMOKE_TEST_CONTRACT
Instance Attribute Summary
Attributes inherited from Base
#config, #executor, #logger
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#configure, #initialize, #sandboxed_environment?
Methods included from Adapter
#build_mcp_flags, #dangerous_mode_flags, #health_status, included, #parse_rate_limit_reset, #session_flags, #smoke_test, #smoke_test_contract, #supports_dangerous_mode?, #supports_sessions?, #validate_config, #validate_mcp_servers!
Class Method Details
.binary_name ⇒ Object
20
21
22
|
# File 'lib/agent_harness/providers/cursor.rb', line 20
def binary_name
"cursor-agent"
end
|
.discover_models ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/agent_harness/providers/cursor.rb', line 57
def discover_models
return [] unless available?
[
{name: "claude-3.5-sonnet", family: "claude-3-5-sonnet", tier: "standard", provider: "cursor"},
{name: "claude-3.5-haiku", family: "claude-3-5-haiku", tier: "mini", provider: "cursor"},
{name: "gpt-4o", family: "gpt-4o", tier: "standard", provider: "cursor"},
{name: "cursor-small", family: "cursor-small", tier: "mini", provider: "cursor"}
]
end
|
.firewall_requirements ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/agent_harness/providers/cursor.rb', line 29
def firewall_requirements
{
domains: [
"cursor.com",
"www.cursor.com",
"downloads.cursor.com",
"api.cursor.sh",
"cursor.sh",
"app.cursor.sh",
"www.cursor.sh",
"auth.cursor.sh",
"auth0.com",
"*.auth0.com"
],
ip_ranges: []
}
end
|
.instruction_file_paths ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/agent_harness/providers/cursor.rb', line 47
def instruction_file_paths
[
{
path: ".cursorrules",
description: "Cursor AI agent instructions",
symlink: true
}
]
end
|
.model_family(provider_model_name) ⇒ Object
Normalize Cursor’s model name to family name
71
72
73
74
|
# File 'lib/agent_harness/providers/cursor.rb', line 71
def model_family(provider_model_name)
provider_model_name.gsub(/(\d)\.(\d)/, '\1-\2')
end
|
.provider_model_name(family_name) ⇒ Object
Convert family name to Cursor’s naming convention
77
78
79
80
|
# File 'lib/agent_harness/providers/cursor.rb', line 77
def provider_model_name(family_name)
family_name.gsub(/(\d)-(\d)/, '\1.\2')
end
|
.provider_name ⇒ Object
16
17
18
|
# File 'lib/agent_harness/providers/cursor.rb', line 16
def provider_name
:cursor
end
|
.smoke_test_contract ⇒ Object
.supports_model_family?(family_name) ⇒ Boolean
Check if this provider supports a given model family
83
84
85
|
# File 'lib/agent_harness/providers/cursor.rb', line 83
def supports_model_family?(family_name)
family_name.match?(/^(claude|gpt|cursor)-/)
end
|
Instance Method Details
#auth_type ⇒ Object
137
138
139
|
# File 'lib/agent_harness/providers/cursor.rb', line 137
def auth_type
:oauth
end
|
#capabilities ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/agent_harness/providers/cursor.rb', line 108
def capabilities
{
streaming: false,
file_upload: true,
vision: false,
tool_use: true,
json_mode: false,
mcp: true,
dangerous_mode: false
}
end
|
#configuration_schema ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/agent_harness/providers/cursor.rb', line 100
def configuration_schema
{
fields: [],
auth_modes: [:oauth],
openai_compatible: false
}
end
|
#display_name ⇒ Object
96
97
98
|
# File 'lib/agent_harness/providers/cursor.rb', line 96
def display_name
"Cursor AI"
end
|
#error_patterns ⇒ Object
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/agent_harness/providers/cursor.rb', line 154
def error_patterns
{
rate_limited: [
/rate.?limit/i,
/too.?many.?requests/i,
/429/
],
auth_expired: [
/authentication.*error/i,
/invalid.*credentials/i,
/unauthorized/i
],
transient: [
/timeout/i,
/connection.*error/i,
/temporary/i
]
}
end
|
#execution_semantics ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/agent_harness/providers/cursor.rb', line 141
def execution_semantics
{
prompt_delivery: :stdin,
output_format: :text,
sandbox_aware: false,
uses_subcommand: false,
non_interactive_flag: "-p",
legitimate_exit_codes: [0],
stderr_is_diagnostic: true,
parses_rate_limit_reset: false
}
end
|
#fetch_mcp_servers ⇒ Object
132
133
134
135
|
# File 'lib/agent_harness/providers/cursor.rb', line 132
def fetch_mcp_servers
fetch_mcp_servers_cli || fetch_mcp_servers_config
end
|
#name ⇒ Object
92
93
94
|
# File 'lib/agent_harness/providers/cursor.rb', line 92
def name
"cursor"
end
|
#send_message(prompt:, **options) ⇒ Object
Override send_message to send prompt via stdin
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
# File 'lib/agent_harness/providers/cursor.rb', line 175
def send_message(prompt:, **options)
log_debug("send_message_start", prompt_length: prompt.length, options: options.keys)
options = normalize_provider_runtime(options)
runtime = options[:provider_runtime]
options = normalize_mcp_servers(options)
validate_mcp_servers!(options[:mcp_servers]) if options[:mcp_servers]&.any?
command = [self.class.binary_name, "-p"]
command.concat(runtime.flags) if runtime&.flags&.any?
timeout = options[:timeout] || @config.timeout || default_timeout
env = build_env(options)
start_time = Time.now
result = execute_with_timeout(
command,
timeout: timeout,
env: env,
stdin_data: prompt,
**command_execution_options(options)
)
duration = Time.now - start_time
response = parse_response(result, duration: duration)
if runtime&.model
response = Response.new(
output: response.output,
exit_code: response.exit_code,
duration: response.duration,
provider: response.provider,
model: runtime.model,
tokens: response.tokens,
metadata: response.metadata,
error: response.error
)
end
track_tokens(response) if response.tokens
log_debug("send_message_complete", duration: duration)
response
rescue McpConfigurationError, McpUnsupportedError, McpTransportUnsupportedError
raise
rescue => e
handle_error(e, prompt: prompt, options: options)
end
|
#supported_mcp_transports ⇒ Object
Cursor supports MCP for fetching existing server configurations (via fetch_mcp_servers) but does not support injecting request-time MCP servers into CLI invocations. Returning an empty list causes validate_mcp_servers! to raise McpUnsupportedError with a clear message.
128
129
130
|
# File 'lib/agent_harness/providers/cursor.rb', line 128
def supported_mcp_transports
[]
end
|
#supports_mcp? ⇒ Boolean
120
121
122
|
# File 'lib/agent_harness/providers/cursor.rb', line 120
def supports_mcp?
true
end
|