feat(ai): add Cursor as an AI provider (API key or CLI sign-in)#1624
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c250cff705
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let reader = Task { | ||
| do { | ||
| for try await line in stdout.fileHandleForReading.bytes.lines { | ||
| if Task.isCancelled { break } | ||
| continuation.yield(line) | ||
| } | ||
| continuation.finish() |
There was a problem hiding this comment.
Surface non-zero Cursor CLI failures
When the CLI exits non-zero after launch (for example expired sign-in, invalid model, or quota/plan errors), Cursor's CLI output-format docs state failures write only to stderr and emit no well-formed JSON, but this reader ignores the termination status and finishes successfully as soon as stdout closes. In those cases CursorAgentProvider just sees no assistant JSON and TablePro shows an empty completed response instead of the actionable Cursor error.
Useful? React with 👍 / 👎.
| static func launchBody(prompt: String, model: String) -> [String: Any] { | ||
| var body: [String: Any] = ["prompt": ["text": prompt]] | ||
| if !model.isEmpty { | ||
| body["model"] = ["id": model] | ||
| } |
There was a problem hiding this comment.
Omit the model for Cursor Auto
When an API-key Cursor provider uses the curated auto option, this sends "model": {"id": "auto"} to the Cloud Agents API. Cursor's model docs describe Auto as the case where no model is supplied (and Cursor selects one), so selecting Auto will make the REST path fail with an invalid-model error instead of routing automatically.
Useful? React with 👍 / 👎.
…Cursor login, testable SSE parser, curated+fetched models) (#1627)
Adds Cursor as an AI provider, so users can run AI chat and inline SQL suggestions on their Cursor subscription. Two ways to authenticate, both officially supported by Cursor:
api.cursor.com).agentcommand (agent login,agent -p --output-format stream-json).The descriptor's
makeProviderpicks the REST provider when a key is set, otherwise the CLI provider. The settings UI is two grouped sections (API Key, Sign in with Cursor) with install/sign-in/sign-out states.How it works
CursorProvider(REST): launches a no-repo agent, streams the run, mapsassistantdeltas to text.CursorAgentProvider(CLI): spawnsagentin an isolated empty temp workspace, parses the JSON-lines stream, yields only the incrementalassistantdeltas (the stream also emits a consolidated final message, which is skipped to avoid duplication).CursorAgentCLI: locates the binary, runs login/status/logout, streams inference. stdin is/dev/null, PATH is widened, stderr is logged./v1/modelslist.Limits (documented in-app and in docs)
Cursor runs as an agent, not a chat-completions endpoint: the AI cannot call TablePro's database tools (chat answers from the schema context TablePro sends; Edit and Agent modes do not run queries through Cursor), and responses can be slower than the other providers.
Security
--trust(not-f/--yolo), so it trusts the isolated temp workspace without auto-approving arbitrary actions.--so attacker-influenceable content (schema/data in the prompt) cannot smuggle CLI flags. Covered by a regression test.Tests
Unit tests for the REST request encoding, the CLI argument building (including the
--guard and a flag-shaped prompt), JSON parsing, and registration (auth style, capabilities, key-vs-no-key provider selection, curated model set). Docs and CHANGELOG updated.Built and verified against a real Cursor login: chat streams a single clean reply, the model list populates, and sign-in works.