Skip to content

Commit c032450

Browse files
authored
Merge pull request #98 from triggerdotdev/cursor-cli-demo-improvements
Remove unnecessary /tmp copy + chmod workaround for cursor-agent
2 parents be1f8fa + 91b3f00 commit c032450

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

cursor-cli-demo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ https://github.com/user-attachments/assets/459aa160-6659-478e-868f-32e74f79d21a
5050
- **Long-running tasks** – cursor-agent runs for minutes; Trigger.dev handles lifecycle, timeouts, and retries
5151
- **Machine selection**`medium-2x` preset for resource-intensive CLI tools
5252
- **Model picker** – Switch between Claude models from the UI before triggering a run
53-
- **Container binary workaround**Demonstrates the `/tmp` copy + `chmod` pattern needed when the runtime strips execute permissions
53+
- **Bundled binary support**Spawns cursor-agent's own node binary for native module ABI compatibility
5454

5555
## Relevant files
5656

cursor-cli-demo/extensions/cursor-cli.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { BuildExtension } from "@trigger.dev/build";
22
import { spawn } from "child_process";
3-
import { chmodSync, copyFileSync, existsSync, readdirSync } from "fs";
3+
import { existsSync, readdirSync } from "fs";
44
import type { CursorEvent } from "@/lib/cursor-events";
55
import { logger } from "@trigger.dev/sdk";
66

@@ -49,20 +49,15 @@ type SpawnCursorAgentOptions = {
4949
/**
5050
* Spawn cursor-agent at runtime inside the Trigger.dev container.
5151
*
52-
* Returns a NDJSON ReadableStream of CursorEvents and a waitUntilExit()
53-
* that resolves with the exit code and stderr.
54-
*
55-
* Handles the /tmp copy + chmod workaround needed because the runtime
56-
* strips execute permissions, and cursor-agent's native .node modules
57-
* require its bundled node (ABI mismatch with container node).
52+
* Uses cursor-agent's bundled node (not process.execPath) because its
53+
* native .node modules require ABI compatibility.
5854
*/
5955
export function spawnCursorAgent(
6056
args: string[],
6157
options: SpawnCursorAgentOptions,
6258
): CursorAgent {
6359
const entryPoint = `${CURSOR_AGENT_DIR}/index.js`;
6460
const bundledNode = `${CURSOR_AGENT_DIR}/node`;
65-
const tmpNode = "/tmp/cursor-node";
6661

6762
if (!existsSync(entryPoint)) {
6863
const dirExists = existsSync(CURSOR_AGENT_DIR);
@@ -71,17 +66,7 @@ export function spawnCursorAgent(
7166
);
7267
}
7368

74-
try {
75-
copyFileSync(bundledNode, tmpNode);
76-
chmodSync(tmpNode, 0o755);
77-
} catch (err: unknown) {
78-
// ETXTBSY = file is being executed by another run on this machine — safe to skip
79-
if (!(err instanceof Error && "code" in err && err.code === "ETXTBSY")) {
80-
throw err;
81-
}
82-
}
83-
84-
const child = spawn(tmpNode, [entryPoint, ...args], {
69+
const child = spawn(bundledNode, [entryPoint, ...args], {
8570
stdio: ["ignore", "pipe", "pipe"],
8671
env: {
8772
...process.env,

0 commit comments

Comments
 (0)