Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions packages/provider-cursor/src/server/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
nestedToolCallFromEnvelope,
} from "./adapter.ts";
import * as CursorAgentSdk from "./CursorAgentSdk.ts";
import * as CursorSdk from "./CursorSdk.ts";
import { loadCursorSdk } from "./sdk.ts";
import { cursorWorkspaceMcpServers } from "./workspaceMcpServers.ts";

Expand Down Expand Up @@ -2388,6 +2389,53 @@ describe("CursorAdapterV2", () => {
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);

it.live("opens a model added to the account after its workspace already ran an agent", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-new-model-" });
const backend = yield* fakeCursorBackend;
yield* scopedProcessEnv({
HOME: home,
USERPROFILE: home,
CURSOR_CONFIG_DIR: path.join(home, ".cursor"),
});
const runner = yield* CursorAgentSdk.makeCursorAgentSdkRunner(() => undefined).pipe(
Effect.provide(CursorSdk.layer),
);
const open = (model: string) =>
Effect.acquireRelease(
runner.open({
operation: "create",
options: makeCursorAgentOptions({
apiKey: "synthetic-cursor-api-key",
modelSelection: { instanceId: ProviderInstanceId.make("cursor"), model },
runtimePolicy: {
runtimeMode: "full-access",
interactionMode: "default",
cwd: home,
},
threadId: ThreadId.make(`cursor-new-model-${model}`),
mcpSession: undefined,
platform: "linux",
}),
threadId: ThreadId.make(`cursor-new-model-${model}`),
providerSessionId: ProviderSessionId.make(`cursor-new-model-${model}`),
}),
(session) => Effect.ignore(session.close),
);

yield* open("composer-2");
backend.models.push("composer-2.5");

const exit = yield* Effect.exit(open("composer-2.5"));
assert.isTrue(
Exit.isSuccess(exit),
Exit.isFailure(exit) ? Cause.pretty(exit.cause) : "opened",
);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);

it("maps runtime modes to the SDK sandbox and auto-review controls", () => {
const base = {
interactionMode: "default" as const,
Expand Down Expand Up @@ -3263,6 +3311,7 @@ const fakeCursorBackend = Effect.gen(function* () {
2,
Buffer.concat([Buffer.from([0x08, 0x01]), protoField(15, Buffer.from("ctx")), protoField(10)]),
);
const models = ["composer-2"];
const runFrame = Buffer.alloc(5 + requestContextExec.length);
runFrame.writeUInt32BE(requestContextExec.length, 1);
requestContextExec.copy(runFrame, 5);
Expand All @@ -3277,7 +3326,7 @@ const fakeCursorBackend = Effect.gen(function* () {
return;
case "/v1/models":
response.setHeader("content-type", "application/json");
response.end(JSON.stringify({ items: [{ id: "composer-2" }] }));
response.end(JSON.stringify({ items: models.map((id) => ({ id })) }));
return;
case "/agent.v1.AgentService/RunSSE":
response.writeHead(200, { "content-type": "application/connect+proto" });
Expand Down Expand Up @@ -3319,7 +3368,7 @@ const fakeCursorBackend = Effect.gen(function* () {
server.close(() => resume(Effect.void));
}),
);
return { requestContext };
return { requestContext, models };
});

function protoVarint(value: number): Buffer {
Expand Down
12 changes: 6 additions & 6 deletions patches/@cursor__sdk@1.3.1.patch

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading