forked from farhoodlabs/paperclip
0fe39a2d5c
> _Stacked on top of #5685 (Harden remote sandbox runtime). Diff against master includes commits from earlier PRs in the stack — review focuses on the new commit only._ ## Thinking Path > - Paperclip orchestrates AI agents for zero-human companies > - The cursor-local adapter wraps the Cursor Agent CLI so a Paperclip workflow can drive it inside a sandbox > - When the adapter runs in a remote sandbox, the Cursor Agent CLI installs under `$HOME/.local/bin/cursor-agent` (or wherever `$XDG_BIN_HOME` points), not on the global PATH > - The existing post-install resolution assumed `cursor-agent` would resolve via the sandbox's login shell PATH after `npm install -g`, which fails on sandboxes where the install lands in a user-prefixed directory that isn't on PATH at probe time > - This pull request resolves the agent CLI from the cursor binary's own directory (`dirname "$(command -v cursor)"`) so the install probe and execute path agree on a real binary location > - The benefit is that cursor-local works correctly on any sandbox provider where `npm install` lands in a user-prefixed directory ## What Changed - `packages/adapters/cursor-local/src/server/remote-command.ts`: resolve the cursor-agent binary from the cursor bin directory after install, instead of relying on PATH. - `packages/adapters/cursor-local/src/server/test.ts`: corresponding probe tweak. - `packages/adapters/cursor-local/src/server/test.test.ts` (new) + `remote-command.test.ts`: focused coverage that exercises the install + resolve path against a sandbox runner that places the binary in a user-prefixed directory. ## Verification - `pnpm exec vitest run --no-coverage packages/adapters/cursor-local/src/server/test.test.ts packages/adapters/cursor-local/src/server/remote-command.test.ts packages/adapters/cursor-local/src/server/execute.test.ts` All passing locally. ## Risks - Local cursor-local runs are unaffected — the resolution change only kicks in for the sandbox install path. - Low risk; isolated to one adapter. ## Model Used - Provider: Anthropic - Model: Claude Opus 4.7 (1M context) - Capabilities used: tool use (Read/Edit/Bash), no code execution beyond local repo commands ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] If this change affects the UI, I have included before/after screenshots — N/A, no UI change - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] I will address all Greptile and reviewer comments before requesting merge Co-authored-by: Paperclip <noreply@paperclip.ing>
109 lines
4.0 KiB
TypeScript
109 lines
4.0 KiB
TypeScript
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
|
|
|
export const type = "cursor";
|
|
export const label = "Cursor CLI (local)";
|
|
|
|
// Cursor CLI is not distributed as an npm package — the official install
|
|
// path is the upstream installer script at cursor.com/install. Other adapters
|
|
// in this repo prefer `npm install -g <pkg>` which is content-addressed by the
|
|
// registry; cursor must use `curl | bash` until upstream publishes a registry
|
|
// artifact. Pinning a commit/version here would require shipping our own
|
|
// mirror of the installer; revisit if Cursor adds an npm/release-asset
|
|
// equivalent.
|
|
export const SANDBOX_INSTALL_COMMAND = "curl https://cursor.com/install -fsS | bash";
|
|
|
|
export const DEFAULT_CURSOR_LOCAL_MODEL = "auto";
|
|
|
|
const CURSOR_FALLBACK_MODEL_IDS = [
|
|
"auto",
|
|
"composer-1.5",
|
|
"composer-1",
|
|
"gpt-5.3-codex-low",
|
|
"gpt-5.3-codex-low-fast",
|
|
"gpt-5.3-codex",
|
|
"gpt-5.3-codex-fast",
|
|
"gpt-5.3-codex-high",
|
|
"gpt-5.3-codex-high-fast",
|
|
"gpt-5.3-codex-xhigh",
|
|
"gpt-5.3-codex-xhigh-fast",
|
|
"gpt-5.3-codex-spark-preview",
|
|
"gpt-5.2",
|
|
"gpt-5.2-codex-low",
|
|
"gpt-5.2-codex-low-fast",
|
|
"gpt-5.2-codex",
|
|
"gpt-5.2-codex-fast",
|
|
"gpt-5.2-codex-high",
|
|
"gpt-5.2-codex-high-fast",
|
|
"gpt-5.2-codex-xhigh",
|
|
"gpt-5.2-codex-xhigh-fast",
|
|
"gpt-5.1-codex-max",
|
|
"gpt-5.1-codex-max-high",
|
|
"gpt-5.2-high",
|
|
"gpt-5.1-high",
|
|
"gpt-5.1-codex-mini",
|
|
"opus-4.6-thinking",
|
|
"opus-4.6",
|
|
"opus-4.5",
|
|
"opus-4.5-thinking",
|
|
"sonnet-4.6",
|
|
"sonnet-4.6-thinking",
|
|
"sonnet-4.5",
|
|
"sonnet-4.5-thinking",
|
|
"gemini-3.1-pro",
|
|
"gemini-3-pro",
|
|
"gemini-3-flash",
|
|
"grok",
|
|
"kimi-k2.5",
|
|
];
|
|
|
|
export const models = CURSOR_FALLBACK_MODEL_IDS.map((id) => ({ id, label: id }));
|
|
|
|
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
|
{
|
|
key: "cheap",
|
|
label: "Cheap",
|
|
description: "Use Cursor's known Codex mini model as the budget lane instead of assuming auto is cheap.",
|
|
adapterConfig: {
|
|
model: "gpt-5.1-codex-mini",
|
|
},
|
|
source: "adapter_default",
|
|
},
|
|
];
|
|
|
|
export const agentConfigurationDoc = `# cursor agent configuration
|
|
|
|
Adapter: cursor
|
|
|
|
Use when:
|
|
- You want Paperclip to run Cursor Agent CLI locally as the agent runtime
|
|
- You want Cursor chat session resume across heartbeats via --resume
|
|
- You want structured stream output in run logs via --output-format stream-json
|
|
|
|
Don't use when:
|
|
- You need webhook-style external invocation (use openclaw_gateway or http)
|
|
- You only need one-shot shell commands (use process)
|
|
- Cursor Agent CLI is not installed on the machine
|
|
|
|
Core fields:
|
|
- cwd (string, optional): default absolute working directory fallback for the agent process (created if missing when possible)
|
|
- instructionsFilePath (string, optional): absolute path to a markdown instructions file prepended to the run prompt
|
|
- promptTemplate (string, optional): run prompt template
|
|
- model (string, optional): Cursor model id (for example auto or gpt-5.3-codex)
|
|
- mode (string, optional): Cursor execution mode passed as --mode (plan|ask). Leave unset for normal autonomous runs.
|
|
- command (string, optional): defaults to "agent"
|
|
- extraArgs (string[], optional): additional CLI args
|
|
- env (object, optional): KEY=VALUE environment variables
|
|
|
|
Operational fields:
|
|
- timeoutSec (number, optional): run timeout in seconds
|
|
- graceSec (number, optional): SIGTERM grace period in seconds
|
|
|
|
Notes:
|
|
- Runs are executed with: agent -p --output-format stream-json ...
|
|
- Prompts are piped to Cursor via stdin.
|
|
- Sessions are resumed with --resume when stored session cwd matches current cwd.
|
|
- Paperclip auto-injects local skills into "~/.cursor/skills" when missing, so Cursor can discover "$paperclip" and related skills on local runs.
|
|
- Paperclip auto-adds --yolo unless one of --trust/--yolo/-f is already present in extraArgs.
|
|
- Remote sandbox runs prepend "~/.cursor/bin" and "~/.local/bin" to PATH and prefer the installed absolute entrypoint from one of those directories when the default Cursor command is requested, so installer-managed sandbox leases do not need hardcoded command paths.
|
|
`;
|