Open History to see the last commit
1/**
2 * Optional integration check against a real `cursor-agent acp` install.
3 * Enable with: T3_CURSOR_ACP_PROBE=1 bun run test --filter CursorAcpCliProbe
4 */
5import * as NodeServices from "@effect/platform-node/NodeServices";
6import { it } from "@effect/vitest";
7import * as Console from "effect/Console";
8import * as Effect from "effect/Effect";
9import { describe, expect } from "vite-plus/test";
10import type * as EffectAcpSchema from "effect-acp/schema";
11
12import * as AcpSessionRuntime from "./AcpSessionRuntime.ts";
13
14describe.runIf(process.env.T3_CURSOR_ACP_PROBE === "1")("Cursor ACP CLI probe", () => {
15 it.effect("initialize and authenticate against real cursor-agent acp", () =>
16 Effect.gen(function* () {
17 const runtime = yield* AcpSessionRuntime.AcpSessionRuntime;
18 const started = yield* runtime.start();
19 expect(started.initializeResult).toBeDefined();
20 }).pipe(
21 Effect.provide(
22 AcpSessionRuntime.layer({
23 spawn: {
24 command: "cursor-agent",
25 args: ["acp"],
26 cwd: process.cwd(),
27 },
28 cwd: process.cwd(),
29 clientCapabilities: {
30 _meta: {
31 parameterizedModelPicker: true,
32 },
33 },
34 clientInfo: { name: "t3-probe", version: "0.0.0" },
35 authMethodId: "cursor_login",
36 }),
37 ),
38 Effect.scoped,
39 Effect.provide(NodeServices.layer),
40 ),
41 );
42
43 it.effect("session/new returns configOptions with a model selector", () =>
44 Effect.gen(function* () {
45 const runtime = yield* AcpSessionRuntime.AcpSessionRuntime;
46 const started = yield* runtime.start();
47 const result = started.sessionSetupResult;
48 // @effect-diagnostics-next-line preferSchemaOverJson:off
49 yield* Console.log("session/new result:", JSON.stringify(result, null, 2));
50
51 expect(typeof started.sessionId).toBe("string");
52
53 const configOptions = result.configOptions;
54 // @effect-diagnostics-next-line preferSchemaOverJson:off
55 yield* Console.log("session/new configOptions:", JSON.stringify(configOptions, null, 2));
56
57 if (Array.isArray(configOptions)) {
58 const modelConfig = configOptions.find((opt) => opt.category === "model");
59 const parameterizedOptions = configOptions.filter(
60 (opt) =>
61 opt.category === "thought_level" ||
62 opt.category === "model_option" ||
63 opt.category === "model_config",
64 );
65 // @effect-diagnostics-next-line preferSchemaOverJson:off
66 yield* Console.log("Model config option:", JSON.stringify(modelConfig, null, 2));
67 yield* Console.log(
68 "Parameterized model config options:",
69 // @effect-diagnostics-next-line preferSchemaOverJson:off
70 JSON.stringify(parameterizedOptions, null, 2),
71 );
72 expect(modelConfig).toBeDefined();
73 expect(typeof modelConfig?.id).toBe("string");
74 }
75 }).pipe(
76 Effect.provide(
77 AcpSessionRuntime.layer({
78 authMethodId: "cursor_login",
79 spawn: {
80 command: "cursor-agent",
81 args: ["acp"],
82 cwd: process.cwd(),
83 },
84 cwd: process.cwd(),
85 clientCapabilities: {
86 _meta: {
87 parameterizedModelPicker: true,
88 },
89 },
90 clientInfo: { name: "t3-probe", version: "0.0.0" },
91 }),
92 ),
93 Effect.scoped,
94 Effect.provide(NodeServices.layer),
95 ),
96 );
97
98 it.effect("session/set_config_option switches the model in-session", () =>
99 Effect.gen(function* () {
100 const runtime = yield* AcpSessionRuntime.AcpSessionRuntime;
101 const started = yield* runtime.start();
102 const newResult = started.sessionSetupResult;
103
104 const configOptions = newResult.configOptions;
105 let modelConfigId = "model";
106 if (Array.isArray(configOptions)) {
107 const modelConfig = configOptions.find((opt) => opt.category === "model");
108 if (typeof modelConfig?.id === "string") {
109 modelConfigId = modelConfig.id;
110 }
111 }
112
113 const setResult: EffectAcpSchema.SetSessionConfigOptionResponse =
114 yield* runtime.setConfigOption(modelConfigId, "gpt-5.4");
115 // @effect-diagnostics-next-line preferSchemaOverJson:off
116 yield* Console.log("session/set_config_option result:", JSON.stringify(setResult, null, 2));
117
118 if (Array.isArray(setResult.configOptions)) {
119 const modelConfig = setResult.configOptions.find((opt) => opt.category === "model");
120 const parameterizedOptions = setResult.configOptions.filter(
121 (opt) =>
122 opt.category === "thought_level" ||
123 opt.category === "model_option" ||
124 opt.category === "model_config",
125 );
126 if (modelConfig?.type === "select") {
127 expect(modelConfig.currentValue).toBe("gpt-5.4");
128 }
129 expect(parameterizedOptions.length).toBeGreaterThan(0);
130 }
131 }).pipe(
132 Effect.provide(
133 AcpSessionRuntime.layer({
134 authMethodId: "cursor_login",
135 spawn: {
136 command: "cursor-agent",
137 args: ["acp"],
138 cwd: process.cwd(),
139 },
140 cwd: process.cwd(),
141 clientCapabilities: {
142 _meta: {
143 parameterizedModelPicker: true,
144 },
145 },
146 clientInfo: { name: "t3-probe", version: "0.0.0" },
147 }),
148 ),
149 Effect.scoped,
150 Effect.provide(NodeServices.layer),
151 ),
152 );
153});