The best way to control Claude Code, Codex and more from any computer or phone
refactor(provider-cursor): move Cursor into its own provider package (#17349)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 8, 2026 at 18:30 UTC
b5e4f1e0b0c2c06f183ab6a89072bec21c8334c4
64 files changed
+429
-357
apps/mobile/package.json
+1
@@ -70,6 +70,7 @@
70
"@t3tools/mobile-review-diff-native": "file:./modules/t3-review-diff",
71
"@t3tools/mobile-terminal-native": "file:./modules/t3-terminal",
72
"@t3tools/provider-core": "workspace:*",
73
+ "@t3tools/provider-cursor": "workspace:*",
74
"@t3tools/provider-muse": "workspace:*",
75
"@t3tools/provider-opencode": "workspace:*",
76
"@t3tools/provider-pi": "workspace:*",
apps/mobile/src/components/ProviderIcon.tsx
-11
@@ -109,17 +109,6 @@ export function ProviderIcon(props: ProviderIconProps) {
109
);
110
}
111
112
- if (props.provider === "cursor") {
113
- return (
114
- <Svg width={size} height={size} viewBox="0 0 466.73 532.09" fill="none">
115
- <Path
116
- fill={isDarkMode ? "#EDECEC" : "#26251E"}
117
- d="M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"
118
- />
119
- </Svg>
120
- );
121
- }
122
-
112
const packageIcon = getProviderClient(props.provider)?.icon;
113
if (packageIcon) {
114
const themeFill = (fill: { readonly light: string; readonly dark: string }) =>
apps/mobile/src/lib/providerClients.ts
+7
-1
@@ -1,11 +1,17 @@
1
import { isProviderDriverKind } from "@t3tools/contracts";
2
import { makeProviderClientRegistry } from "@t3tools/provider-core/client";
3
+import { cursorClient } from "@t3tools/provider-cursor/client";
4
import { museClient } from "@t3tools/provider-muse/client";
5
import { openCodeClient } from "@t3tools/provider-opencode/client";
6
import { piClient } from "@t3tools/provider-pi/client";
7
8
/** The provider client definitions this mobile build ships. */
8
-const providerClients = makeProviderClientRegistry([museClient, openCodeClient, piClient]);
9
+const providerClients = makeProviderClientRegistry([
10
+ cursorClient,
11
+ museClient,
12
+ openCodeClient,
13
+ piClient,
14
+]);
15
16
/** The client definition for a driver kind, or `undefined` for drivers drawn by hand. */
17
export function getProviderClient(driver: string | null | undefined) {
apps/server/package.json
+1
@@ -39,6 +39,7 @@
39
"@noble/hashes": "catalog:",
40
"@opencode-ai/sdk": "^1.3.15",
41
"@t3tools/provider-core": "workspace:*",
42
+ "@t3tools/provider-cursor": "workspace:*",
43
"@t3tools/provider-muse": "workspace:*",
44
"@t3tools/provider-opencode": "workspace:*",
45
"@t3tools/provider-pi": "workspace:*",
apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.testkit.ts
+5
-98
@@ -1,6 +1,4 @@
1
import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";
2
-import * as OtelEnvironment from "@t3tools/shared/otelEnvironment";
3
-import { DEFAULT_SIGNAL_EXPORT } from "@t3tools/shared/observability";
2
import type { InteractionUpdate, RunResult } from "@cursor/sdk";
3
import * as NodeServices from "@effect/platform-node/NodeServices";
4
import {
@@ -15,23 +13,21 @@ import * as Effect from "effect/Effect";
13
import * as Fiber from "effect/Fiber";
14
import * as FileSystem from "effect/FileSystem";
15
import * as Layer from "effect/Layer";
18
-import * as Path from "effect/Path";
19
-import * as PlatformError from "effect/PlatformError";
16
import * as Schema from "effect/Schema";
17
22
-import * as ServerConfig from "../../config.ts";
18
+import { layerTestProviderHost } from "@t3tools/provider-testing/host";
19
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
20
import { ProviderAdapterDriverCreateError } from "@t3tools/provider-core/server/adapterDriver";
21
import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
22
import type { OrchestratorV2ProviderReplayHarness } from "../testkit/ProviderReplayHarness.ts";
27
-import * as CursorAgentSdk from "./CursorAgentSdk.ts";
23
+import { CursorAdapterV2Driver } from "@t3tools/provider-cursor/server";
24
+import * as CursorAgentSdk from "@t3tools/provider-cursor/server/CursorAgentSdk";
25
import {
26
CURSOR_DEFAULT_INSTANCE_ID,
27
CURSOR_DRIVER_KIND,
31
- CursorAdapterV2Driver,
28
cursorSdkModelSelection,
29
makeCursorAgentOptions,
34
-} from "./CursorAdapterV2.ts";
30
+} from "@t3tools/provider-cursor/testing";
31
import type { ProviderAdapterV2RuntimePolicy } from "@t3tools/provider-core/server/ProviderAdapter";
32
import type { RuntimePolicyV2Override } from "../RuntimePolicy.ts";
33
@@ -513,91 +509,6 @@ function layerCursorAgentSdkReplay(
509
);
510
}
511
516
-function makeReplayServerConfig(
517
- scenario: string,
518
-): Effect.Effect<
519
- ServerConfig.ServerConfig["Service"],
520
- PlatformError.PlatformError,
521
- FileSystem.FileSystem | Path.Path
522
-> {
523
- return Effect.gen(function* () {
524
- const fs = yield* FileSystem.FileSystem;
525
- const path = yield* Path.Path;
526
- const baseDir = yield* fs.makeTempDirectory({
527
- prefix: `t3-orchestration-v2-cursor-${scenario}-`,
528
- });
529
- const stateDir = path.join(baseDir, "userdata");
530
- const logsDir = path.join(stateDir, "logs");
531
- const providerLogsDir = path.join(logsDir, "provider");
532
- const terminalLogsDir = path.join(logsDir, "terminals");
533
- const attachmentsDir = path.join(stateDir, "attachments");
534
- const environmentThemesDir = path.join(stateDir, "themes");
535
- const worktreesDir = path.join(baseDir, "worktrees");
536
- const providerStatusCacheDir = path.join(baseDir, "caches");
537
- for (const directory of [
538
- stateDir,
539
- logsDir,
540
- providerLogsDir,
541
- terminalLogsDir,
542
- attachmentsDir,
543
- environmentThemesDir,
544
- worktreesDir,
545
- providerStatusCacheDir,
546
- ]) {
547
- yield* fs.makeDirectory(directory, { recursive: true });
548
- }
549
- return {
550
- logLevel: "Error",
551
- traceMinLevel: "Info",
552
- traceTimingEnabled: true,
553
- traceBatchWindowMs: 200,
554
- traceMaxBytes: 10 * 1024 * 1024,
555
- traceMaxFiles: 10,
556
- otelEnvironment: OtelEnvironment.none,
557
- otlpTracesUrl: undefined,
558
- otlpMetricsUrl: undefined,
559
- otlpLogsUrl: undefined,
560
- otlpTracesExport: DEFAULT_SIGNAL_EXPORT,
561
- otlpMetricsExport: DEFAULT_SIGNAL_EXPORT,
562
- otlpLogsExport: DEFAULT_SIGNAL_EXPORT,
563
- mode: "web",
564
- port: 0,
565
- host: undefined,
566
- cwd: process.cwd(),
567
- baseDir,
568
- staticDir: undefined,
569
- devUrl: undefined,
570
- devAllowedOrigins: [],
571
- noBrowser: false,
572
- startupPresentation: "browser",
573
- tailscaleServeEnabled: false,
574
- tailscaleServePort: 443,
575
- desktopBootstrapToken: undefined,
576
- autoBootstrapProjectFromCwd: false,
577
- logWebSocketEvents: false,
578
- stateDir,
579
- dbPath: path.join(stateDir, "state.sqlite"),
580
- keybindingsConfigPath: path.join(stateDir, "keybindings.json"),
581
- settingsPath: path.join(stateDir, "settings.json"),
582
- providerStatusCacheDir,
583
- worktreesDir,
584
- attachmentsDir,
585
- browserArtifactsDir: path.join(stateDir, "browser-artifacts"),
586
- environmentThemesDir,
587
- logsDir,
588
- serverLogPath: path.join(logsDir, "server.log"),
589
- serverTracePath: path.join(logsDir, "server.trace.ndjson"),
590
- providerLogsDir,
591
- providerEventLogPath: path.join(providerLogsDir, "events.log"),
592
- terminalLogsDir,
593
- anonymousIdPath: path.join(stateDir, "anonymous-id"),
594
- environmentIdPath: path.join(stateDir, "environment-id"),
595
- serverRuntimeStatePath: path.join(stateDir, "server-runtime.json"),
596
- secretsDir: path.join(stateDir, "secrets"),
597
- };
598
- });
599
-}
600
-
512
export function layer(
513
transcript: CursorAgentSdkReplayTranscript,
514
options?: {
@@ -605,10 +516,6 @@ export function layer(
516
readonly assertCompleteOnFinalize?: boolean;
517
},
518
) {
608
- const layerServerConfig = Layer.effect(
609
- ServerConfig.ServerConfig,
610
- makeReplayServerConfig(transcript.scenario).pipe(Effect.orDie),
611
- ).pipe(Layer.provide(NodeServices.layer));
519
// Skill discovery also scans user roots under HOME; an empty HOME keeps
520
// replays from picking up the host's own skills.
521
const layerHostEnvironment = Layer.effect(
@@ -630,7 +537,7 @@ export function layer(
537
Layer.provide(
538
Layer.mergeAll(
539
layerCursorAgentSdkReplay(transcript, options),
633
- layerServerConfig,
540
+ layerTestProviderHost().pipe(Layer.provide(NodeServices.layer)),
541
layerHostEnvironment,
542
NodeServices.layer,
543
IdAllocator.layer,
apps/server/src/orchestration-v2/CommandPolicy.test.ts
+1
-1
@@ -12,7 +12,7 @@ import {
12
import * as Effect from "effect/Effect";
13
14
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
15
-import { CursorProviderCapabilitiesV2 } from "./Adapters/CursorAdapterV2.ts";
15
+import { CursorProviderCapabilitiesV2 } from "@t3tools/provider-cursor/testing";
16
import { GrokProviderCapabilitiesV2 } from "./Adapters/GrokAdapterV2.ts";
17
import * as CommandPolicy from "./CommandPolicy.ts";
18
apps/server/src/orchestration-v2/builtInProviderAdapterDrivers.ts
+1
-1
@@ -12,7 +12,7 @@ import { CodexAdapterV2Driver, type CodexAdapterV2DriverEnv } from "./Adapters/C
12
import {
13
CursorAdapterV2Driver,
14
type CursorAdapterV2DriverEnv,
15
-} from "./Adapters/CursorAdapterV2.ts";
15
+} from "@t3tools/provider-cursor/server";
16
import { GrokAdapterV2Driver, type GrokAdapterV2DriverEnv } from "./Adapters/GrokAdapterV2.ts";
17
import {
18
OpenCodeAdapterV2Driver,
apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
+1
-1
@@ -43,7 +43,7 @@ import {
43
canReuseCodexContextUsage,
44
} from "../Adapters/CodexAdapterV2.ts";
45
import { AcpProviderCapabilitiesV2 } from "../Adapters/AcpAdapterV2.ts";
46
-import { CursorProviderCapabilitiesV2 } from "../Adapters/CursorAdapterV2.ts";
46
+import { CursorProviderCapabilitiesV2 } from "@t3tools/provider-cursor/testing";
47
import * as EventSink from "../EventSink.ts";
48
import * as EventStore from "../EventStore.ts";
49
import * as LegacyV1ThreadImporter from "../legacy/LegacyV1ThreadImporter.ts";
apps/server/src/provider/AntigravityProvider.test.ts
+3
-1
@@ -22,6 +22,7 @@ import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
22
import * as ServerConfig from "../config.ts";
23
import * as ServerSettings from "../serverSettings.ts";
24
import * as ProviderHostLive from "./ProviderHostLive.ts";
25
+import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
26
import type { AcpSessionRuntimeStartResult } from "./acp/AcpSessionRuntime.ts";
27
import {
28
buildAntigravityModelsFromSession,
@@ -116,9 +117,10 @@ const layerTest = ProviderHostLive.layer.pipe(
117
}),
118
),
119
Layer.provideMerge(ServerSettings.layerTest()),
120
+ Layer.provideMerge(ServerSecretStore.layer),
121
Layer.provide(
122
ServerConfig.layerTest(process.cwd(), { prefix: "t3-antigravity-provider-test-" }).pipe(
121
- Layer.provide(NodeServices.layer),
123
+ Layer.provideMerge(NodeServices.layer),
124
),
125
),
126
);
apps/server/src/provider/Drivers/AntigravityDriver.test.ts
+5
-1
@@ -34,6 +34,7 @@ import * as ModelManifest from "../ModelManifest.ts";
34
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
35
import { AntigravityDriver } from "./AntigravityDriver.ts";
36
import * as ProviderHostLive from "../ProviderHostLive.ts";
37
+import * as ServerSecretStore from "../../auth/ServerSecretStore.ts";
38
39
const hostPlatform = HostProcessPlatform.defaultValue();
40
const windowsHost = hostPlatform === "win32";
@@ -264,7 +265,10 @@ const layerDeps = ServerConfig.layerTest(process.cwd(), {
265
Layer.provideMerge(ModelManifest.layerTest),
266
Layer.provideMerge(IdAllocator.layer),
267
);
267
-const layerTest = ProviderHostLive.layer.pipe(Layer.provideMerge(layerDeps));
268
+const layerTest = ProviderHostLive.layer.pipe(
269
+ Layer.provideMerge(ServerSecretStore.layer),
270
+ Layer.provideMerge(layerDeps),
271
+);
272
273
it.layer(layerTest)("AntigravityDriver", (it) => {
274
it.effect.skipIf(windowsHost)(
apps/server/src/provider/Drivers/GrokDriver.test.ts
+5
-1
@@ -17,6 +17,7 @@ import { GrokDriver } from "./GrokDriver.ts";
17
18
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
19
import * as ProviderHostLive from "../ProviderHostLive.ts";
20
+import * as ServerSecretStore from "../../auth/ServerSecretStore.ts";
21
22
const layerDeps = ServerConfig.layerTest(process.cwd(), {
23
prefix: "t3-grok-driver-update-",
@@ -42,7 +43,10 @@ const layerDeps = ServerConfig.layerTest(process.cwd(), {
43
),
44
),
45
);
45
-const layerTest = ProviderHostLive.layer.pipe(Layer.provideMerge(layerDeps));
46
+const layerTest = ProviderHostLive.layer.pipe(
47
+ Layer.provideMerge(ServerSecretStore.layer),
48
+ Layer.provideMerge(layerDeps),
49
+);
50
51
const noSpawner = ChildProcessSpawner.make(() =>
52
Effect.die("Disabled Grok must not spawn a process"),
apps/server/src/provider/ProviderHostLive.ts
+30
@@ -5,13 +5,17 @@
5
* @module provider/ProviderHostLive
6
*/
7
import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
8
+import { ProviderCredentialError } from "@t3tools/provider-core/server/errors";
9
+import * as Crypto from "effect/Crypto";
10
import * as Effect from "effect/Effect";
11
import * as Layer from "effect/Layer";
12
13
import { resolveAttachmentPath } from "../attachmentStore.ts";
14
+import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
15
import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
16
import * as ServerConfig from "../config.ts";
17
import * as ServerSettings from "../serverSettings.ts";
18
+import * as ProviderCredentialStore from "./ProviderCredentialStore.ts";
19
20
export const layer = Layer.effect(
21
ProviderHost,
@@ -19,6 +23,8 @@ export const layer = Layer.effect(
23
const config = yield* ServerConfig.ServerConfig;
24
const serverSettings = yield* ServerSettings.ServerSettingsService;
25
const backgroundPolicy = yield* BackgroundPolicy.BackgroundPolicy;
26
+ const secrets = yield* ServerSecretStore.ServerSecretStore;
27
+ const crypto = yield* Crypto.Crypto;
28
return ProviderHost.of({
29
paths: {
30
cwd: config.cwd,
@@ -34,6 +40,30 @@ export const layer = Layer.effect(
40
shouldRunBackgroundWork: backgroundPolicy.shouldRunScopeWork,
41
resolveAttachmentPath: (attachment) =>
42
resolveAttachmentPath({ attachmentsDir: config.attachmentsDir, attachment }),
43
+ credentials: (namespace, bindingId) =>
44
+ ProviderCredentialStore.make(namespace, bindingId).pipe(
45
+ Effect.map((store) => ({
46
+ binding: store.binding,
47
+ get: store.get.pipe(
48
+ Effect.mapError((cause) => new ProviderCredentialError({ operation: "get", cause })),
49
+ ),
50
+ set: (credentials: Uint8Array) =>
51
+ store
52
+ .set(credentials)
53
+ .pipe(
54
+ Effect.mapError(
55
+ (cause) => new ProviderCredentialError({ operation: "set", cause }),
56
+ ),
57
+ ),
58
+ remove: store.remove.pipe(
59
+ Effect.mapError(
60
+ (cause) => new ProviderCredentialError({ operation: "remove", cause }),
61
+ ),
62
+ ),
63
+ })),
64
+ Effect.provideService(ServerSecretStore.ServerSecretStore, secrets),
65
+ Effect.provideService(Crypto.Crypto, crypto),
66
+ ),
67
});
68
}),
69
);
apps/server/src/provider/ProviderInstanceRegistry.test.ts
+2
-2
@@ -31,12 +31,12 @@ import {
31
EnvironmentId,
32
type ClaudeSettings,
33
type CodexSettings,
34
- type CursorSettings,
34
type GrokSettings,
35
ProviderDriverKind,
36
type ProviderInstanceConfigMap,
37
ProviderInstanceId,
38
} from "@t3tools/contracts";
39
+import type { CursorSettings } from "@t3tools/provider-cursor/settings";
40
import { HostProcessPlatform, isHostWindows } from "@t3tools/shared/hostProcess";
41
import * as DateTime from "effect/DateTime";
42
import * as Effect from "effect/Effect";
@@ -53,7 +53,7 @@ import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
53
import * as ServerSettings from "../serverSettings.ts";
54
import { ClaudeDriver, type ClaudeDriverEnv } from "./Drivers/ClaudeDriver.ts";
55
import { CodexDriver, type CodexDriverEnv } from "./Drivers/CodexDriver.ts";
56
-import { CursorDriver, type CursorDriverEnv } from "./Drivers/CursorDriver.ts";
56
+import { CursorDriver, type CursorDriverEnv } from "@t3tools/provider-cursor/server";
57
import { GrokDriver, type GrokDriverEnv } from "./Drivers/GrokDriver.ts";
58
import { OpenCodeDriver, type OpenCodeDriverEnv } from "@t3tools/provider-opencode/server";
59
import type { OpenCodeSettings } from "@t3tools/provider-opencode/settings";
apps/server/src/provider/ProviderOrchestrationAdapterInfrastructure.ts
+1
-1
@@ -2,7 +2,7 @@ import * as Layer from "effect/Layer";
2
3
import * as ClaudeAdapterV2 from "../orchestration-v2/Adapters/ClaudeAdapterV2.ts";
4
import * as CodexAdapterV2 from "../orchestration-v2/Adapters/CodexAdapterV2.ts";
5
-import * as CursorAgentSdk from "../orchestration-v2/Adapters/CursorAgentSdk.ts";
5
+import * as CursorAgentSdk from "@t3tools/provider-cursor/server/CursorAgentSdk";
6
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
7
import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
8
apps/server/src/provider/builtInDrivers.ts
+1
-1
@@ -24,7 +24,7 @@ import { AcpRegistryDriver, type AcpRegistryDriverEnv } from "./Drivers/AcpRegis
24
import { AntigravityDriver, type AntigravityDriverEnv } from "./Drivers/AntigravityDriver.ts";
25
import { ClaudeDriver, type ClaudeDriverEnv } from "./Drivers/ClaudeDriver.ts";
26
import { CodexDriver, type CodexDriverEnv } from "./Drivers/CodexDriver.ts";
27
-import { CursorDriver, type CursorDriverEnv } from "./Drivers/CursorDriver.ts";
27
+import { CursorDriver, type CursorDriverEnv } from "@t3tools/provider-cursor/server";
28
import { GrokDriver, type GrokDriverEnv } from "./Drivers/GrokDriver.ts";
29
import { OpenCodeDriver, type OpenCodeDriverEnv } from "@t3tools/provider-opencode/server";
30
import { MuseDriver, type MuseDriverEnv } from "@t3tools/provider-muse/server";
apps/server/src/usage/cursorUsageReader.test.ts
+1
-1
@@ -1,6 +1,6 @@
1
import { assert, describe, it } from "@effect/vitest";
2
3
-import { CursorKeychainTimeoutError } from "../provider/cursorKeychainToken.ts";
3
+import { CursorKeychainTimeoutError } from "@t3tools/provider-cursor/server";
4
import { readCursorAccountUsage } from "./cursorUsageReader.ts";
5
6
describe("readCursorAccountUsage", () => {
apps/server/src/usage/cursorUsageReader.ts
+1
-1
@@ -12,7 +12,7 @@ import type { UsageRecord } from "./usageTranscripts.ts";
12
import {
13
CursorKeychainTimeoutError,
14
readMacCursorAccessToken,
15
-} from "../provider/cursorKeychainToken.ts";
15
+} from "@t3tools/provider-cursor/server";
16
17
function object(value: unknown): Record<string, unknown> {
18
return typeof value === "object" && value !== null && !Array.isArray(value)
apps/web/package.json
+1
@@ -29,6 +29,7 @@
29
"@t3tools/client-runtime": "workspace:*",
30
"@t3tools/contracts": "workspace:*",
31
"@t3tools/provider-core": "workspace:*",
32
+ "@t3tools/provider-cursor": "workspace:*",
33
"@t3tools/provider-muse": "workspace:*",
34
"@t3tools/provider-opencode": "workspace:*",
35
"@t3tools/provider-pi": "workspace:*",
apps/web/src/components/chat/ProviderInstanceIcon.tsx
+1
-3
@@ -3,7 +3,7 @@ import { type CSSProperties, memo } from "react";
3
import { providerInstanceInitials } from "@t3tools/client-runtime/state/provider-instance-display";
4
5
import { ProviderDriverKind } from "@t3tools/contracts";
6
-import { AntigravityIcon, ClaudeAI, CursorIcon, GrokIcon, Icon, OpenAI } from "../Icons";
6
+import { AntigravityIcon, ClaudeAI, GrokIcon, Icon, OpenAI } from "../Icons";
7
8
import { cn } from "~/lib/utils";
9
import { providerClients } from "../settings/providerDriverMeta";
@@ -17,7 +17,6 @@ import {
17
const PROVIDER_ICON_BY_PROVIDER: Partial<Record<ProviderDriverKind, Icon>> = {
18
[ProviderDriverKind.make("codex")]: OpenAI,
19
[ProviderDriverKind.make("claudeAgent")]: ClaudeAI,
20
- [ProviderDriverKind.make("cursor")]: CursorIcon,
20
[ProviderDriverKind.make("grok")]: GrokIcon,
21
[ProviderDriverKind.make("antigravity")]: AntigravityIcon,
22
};
@@ -25,7 +24,6 @@ const PROVIDER_ICON_BY_PROVIDER: Partial<Record<ProviderDriverKind, Icon>> = {
24
const PROVIDER_TEXT_COLOR_BY_PROVIDER: Partial<Record<ProviderDriverKind, string>> = {
25
[ProviderDriverKind.make("codex")]: "text-black dark:text-white",
26
[ProviderDriverKind.make("claudeAgent")]: "text-[#d97757]",
28
- [ProviderDriverKind.make("cursor")]: "text-[#26251E] dark:text-[#EDECEC]",
27
[ProviderDriverKind.make("grok")]: "text-[#0F0F0F] dark:text-[#F5F5F5]",
28
[ProviderDriverKind.make("antigravity")]: "text-[#5b87bf]",
29
};
apps/web/src/components/settings/providerDriverMeta.ts
+2
-15
@@ -3,11 +3,11 @@ import {
3
AntigravitySettings,
4
ClaudeSettings,
5
CodexSettings,
6
- CursorSettings,
6
GrokSettings,
7
ProviderDriverKind,
8
} from "@t3tools/contracts";
9
import { makeProviderClientRegistry } from "@t3tools/provider-core/client";
10
+import { cursorClient } from "@t3tools/provider-cursor/client";
11
import { museClient } from "@t3tools/provider-muse/client";
12
import { openCodeClient } from "@t3tools/provider-opencode/client";
13
import { piClient } from "@t3tools/provider-pi/client";
@@ -24,20 +24,7 @@ export const providerClients = makeProviderClientRegistry([
24
label: "Claude",
25
settingsSchema: ClaudeSettings,
26
},
27
- {
28
- driverKind: ProviderDriverKind.make("cursor"),
29
- label: "Cursor",
30
- settingsSchema: CursorSettings,
31
- environmentFields: [
32
- {
33
- name: "CURSOR_API_KEY",
34
- label: "Cursor API key",
35
- description: "Optional. Overrides browser sign-in for this provider.",
36
- placeholder: "Paste API key",
37
- sensitive: true,
38
- },
39
- ],
40
- },
27
+ cursorClient,
28
{
29
driverKind: ProviderDriverKind.make("grok"),
30
label: "Grok",
docs/internals/adding-a-provider.md
+1
-1
@@ -115,7 +115,7 @@ A provider lives in its own `packages/provider-<name>` package, with
115
Settings live in `providerInstances`; new providers are off by default.
116
- **Package boundaries.** Server code imports only `@t3tools/provider-core/server/*`, contracts,
117
and shared. It reaches the server through `ProviderHost` (paths, settings, background demand,
118
- attachments), never through `apps/server`. Tests use `@t3tools/provider-testing`.
118
+ attachments, stored credentials), never through `apps/server`. Tests use `@t3tools/provider-testing`.
119
- **Server registration:** the driver's entry in
120
[`builtInDrivers.ts`](../../apps/server/src/provider/builtInDrivers.ts) and the adapter driver's in
121
[`builtInProviderAdapterDrivers.ts`](../../apps/server/src/orchestration-v2/builtInProviderAdapterDrivers.ts).
knip.jsonc
+3
-1
@@ -36,7 +36,9 @@
36
],
37
// Keep the transitive Effect runtime pinned for standalone npm installs.
38
// The Vite+ web build prerequisite.
39
- "ignoreDependencies": ["@effect/platform-node-shared", "@t3tools/web"],
39
+ // Native and disk-loaded provider packages stay external to the bundle; the
40
+ // CLI archive and desktop sidecar stage them from this manifest.
41
+ "ignoreDependencies": ["@effect/platform-node-shared", "@t3tools/web", "@napi-rs/keyring"],
42
},
43
"apps/desktop": {
44
// Electron loads these bundles by filename rather than importing them.
package.json
+1
-1
@@ -28,7 +28,7 @@
28
"tc": "vp run -r --concurrency-limit 2 typecheck",
29
"lint": "vp lint --report-unused-disable-directives",
30
"knip": "knip --preprocessor ./scripts/knip-schemas.ts",
31
- "knip:check": "knip --include files,dependencies --no-config-hints && knip --workspace apps/server --workspace apps/desktop --workspace apps/web --workspace packages/client-runtime --workspace packages/contracts --workspace packages/effect-acp --workspace packages/effect-codex-app-server --workspace packages/shared --workspace packages/ssh --workspace packages/tailscale --workspace packages/provider-core --workspace packages/provider-testing --workspace packages/provider-pi --workspace packages/provider-muse --workspace packages/provider-opencode --exports --preprocessor ./scripts/knip-schemas.ts --no-config-hints",
31
+ "knip:check": "knip --include files,dependencies --no-config-hints && knip --workspace apps/server --workspace apps/desktop --workspace apps/web --workspace packages/client-runtime --workspace packages/contracts --workspace packages/effect-acp --workspace packages/effect-codex-app-server --workspace packages/shared --workspace packages/ssh --workspace packages/tailscale --workspace packages/provider-core --workspace packages/provider-testing --workspace packages/provider-pi --workspace packages/provider-muse --workspace packages/provider-opencode --workspace packages/provider-cursor --exports --preprocessor ./scripts/knip-schemas.ts --no-config-hints",
32
"knip:production": "knip --production --preprocessor ./scripts/knip-schemas.ts",
33
"lint:mobile": "node scripts/mobile-native-static-check.ts",
34
"test": "vp run -r test",
packages/contracts/src/settings.ts
-26
@@ -707,32 +707,6 @@ export const ClaudeSettings = makeProviderSettingsSchema(
707
);
708
export type ClaudeSettings = typeof ClaudeSettings.Type;
709
710
-export const CursorSettings = makeProviderSettingsSchema(
711
- {
712
- // Off by default like Grok and OpenCode. Users opt in from Settings.
713
- enabled: Schema.Boolean.pipe(
714
- Schema.withDecodingDefault(Effect.succeed(false)),
715
- Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
716
- ),
717
- // Keep V1's CLI configuration when V2 rewrites the shared settings file.
718
- // V2's Cursor SDK does not use these fields.
719
- binaryPath: Schema.optionalKey(TrimmedString).pipe(
720
- Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
721
- ),
722
- apiEndpoint: Schema.optionalKey(TrimmedString).pipe(
723
- Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
724
- ),
725
- customModels: Schema.Array(CustomModelSetting).pipe(
726
- Schema.withDecodingDefault(Effect.succeed([])),
727
- Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
728
- ),
729
- },
730
- {
731
- order: [],
732
- },
733
-);
734
-export type CursorSettings = typeof CursorSettings.Type;
735
-
710
export const GrokSettings = makeProviderSettingsSchema(
711
{
712
// Off by default (like Cursor and OpenCode): the binding is not yet
packages/provider-core/src/server/ProviderHost.ts
+17
@@ -17,9 +17,12 @@ import type {
17
} from "@t3tools/contracts";
18
import * as Context from "effect/Context";
19
import type * as Effect from "effect/Effect";
20
+import type * as Option from "effect/Option";
21
import type * as Scope from "effect/Scope";
22
import type * as Stream from "effect/Stream";
23
24
+import type { ProviderCredentialError } from "./errors.ts";
25
+
26
export interface ProviderHostPaths {
27
/** Directory the server was started in; the fallback cwd for sessions without a project. */
28
readonly cwd: string;
@@ -31,6 +34,15 @@ export interface ProviderHostPaths {
34
readonly providerStatusCacheDir: string;
35
}
36
37
+/** One opaque credential blob in the server's secret store. Only the provider decodes it. */
38
+export interface ProviderCredentials {
39
+ /** Instances whose bindings are equal share these credentials. */
40
+ readonly binding: { readonly owner: "t3"; readonly key: string };
41
+ readonly get: Effect.Effect<Option.Option<Uint8Array>, ProviderCredentialError>;
42
+ readonly set: (credentials: Uint8Array) => Effect.Effect<void, ProviderCredentialError>;
43
+ readonly remove: Effect.Effect<void, ProviderCredentialError>;
44
+}
45
+
46
export interface ProviderHostShape {
47
readonly paths: ProviderHostPaths;
48
readonly settings: {
@@ -47,6 +59,11 @@ export interface ProviderHostShape {
59
* resolve inside the attachments directory.
60
*/
61
readonly resolveAttachmentPath: (attachment: ChatAttachment) => string | null;
62
+ /** The credentials stored for `bindingId`, usually an instance id, under a provider-chosen namespace. */
63
+ readonly credentials: (
64
+ namespace: string,
65
+ bindingId: string,
66
+ ) => Effect.Effect<ProviderCredentials>;
67
}
68
69
export class ProviderHost extends Context.Service<ProviderHost, ProviderHostShape>()(
packages/provider-core/src/server/errors.ts
+13
@@ -19,3 +19,16 @@ export class ProviderDriverError extends Schema.TaggedError<ProviderDriverError>
19
return `Provider driver '${this.driver}' failed to create instance '${this.instanceId}': ${this.detail}`;
20
}
21
}
22
+
23
+/** Reading or writing a provider's stored credentials failed. */
24
+export class ProviderCredentialError extends Schema.TaggedError<ProviderCredentialError>()(
25
+ "ProviderCredentialError",
26
+ {
27
+ operation: Schema.Literals(["get", "set", "remove"]),
28
+ cause: Schema.Defect(),
29
+ },
30
+) {
31
+ override get message(): string {
32
+ return `Could not ${this.operation} stored provider credentials.`;
33
+ }
34
+}
packages/provider-core/src/server/managedProvider.test.ts
+1
@@ -117,6 +117,7 @@ function layerProviderHost(input: {
117
},
118
shouldRunBackgroundWork: () => Effect.succeed(input.runBackgroundWork),
119
resolveAttachmentPath: () => null,
120
+ credentials: () => Effect.die("unused"),
121
}),
122
);
123
}
packages/provider-cursor/package.json
new
+47
@@ -0,0 +1,47 @@
1
+{
2
+ "name": "@t3tools/provider-cursor",
3
+ "private": true,
4
+ "type": "module",
5
+ "exports": {
6
+ "./client": {
7
+ "types": "./src/client.ts",
8
+ "import": "./src/client.ts"
9
+ },
10
+ "./settings": {
11
+ "types": "./src/settings.ts",
12
+ "import": "./src/settings.ts"
13
+ },
14
+ "./server": {
15
+ "types": "./src/server.ts",
16
+ "import": "./src/server.ts"
17
+ },
18
+ "./testing": {
19
+ "types": "./src/testing.ts",
20
+ "import": "./src/testing.ts"
21
+ },
22
+ "./server/CursorAgentSdk": {
23
+ "types": "./src/server/CursorAgentSdk.ts",
24
+ "import": "./src/server/CursorAgentSdk.ts"
25
+ }
26
+ },
27
+ "scripts": {
28
+ "typecheck": "tsc --noEmit",
29
+ "test": "vp test run --config ../../vite.config.ts --dir ."
30
+ },
31
+ "dependencies": {
32
+ "@cursor/sdk": "1.0.35",
33
+ "@napi-rs/keyring": "^1.3.0",
34
+ "@t3tools/contracts": "workspace:*",
35
+ "@t3tools/provider-core": "workspace:*",
36
+ "@t3tools/shared": "workspace:*",
37
+ "effect": "catalog:",
38
+ "yaml": "catalog:"
39
+ },
40
+ "devDependencies": {
41
+ "@effect/platform-node": "catalog:",
42
+ "@effect/vitest": "catalog:",
43
+ "@t3tools/provider-testing": "workspace:*",
44
+ "@types/node": "catalog:",
45
+ "vite-plus": "catalog:"
46
+ }
47
+}
packages/provider-cursor/src/client.ts
new
+34
@@ -0,0 +1,34 @@
1
+/**
2
+ * Cursor's client definition: settings form, label, sign-in environment
3
+ * field, and glyph. Browser- and React Native-safe.
4
+ *
5
+ * @module provider-cursor/client
6
+ */
7
+import { ProviderDriverKind } from "@t3tools/contracts";
8
+import { defineProviderClient } from "@t3tools/provider-core/client";
9
+
10
+import { CursorSettings } from "./settings.ts";
11
+
12
+export const cursorClient = defineProviderClient({
13
+ driverKind: ProviderDriverKind.make("cursor"),
14
+ label: "Cursor",
15
+ settingsSchema: CursorSettings,
16
+ environmentFields: [
17
+ {
18
+ name: "CURSOR_API_KEY",
19
+ label: "Cursor API key",
20
+ description: "Optional. Overrides browser sign-in for this provider.",
21
+ placeholder: "Paste API key",
22
+ sensitive: true,
23
+ },
24
+ ],
25
+ icon: {
26
+ viewBox: "0 0 466.73 532.09",
27
+ fill: { light: "#26251E", dark: "#EDECEC" },
28
+ paths: [
29
+ {
30
+ d: "M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z",
31
+ },
32
+ ],
33
+ },
34
+});
packages/provider-cursor/src/server.ts
new
+10
@@ -0,0 +1,10 @@
1
+/**
2
+ * Cursor's server entry: the driver the server registers, its adapter
3
+ * driver, the SDK runner layer the server provides once, and the keychain
4
+ * token reader the usage scanner shares.
5
+ *
6
+ * @module provider-cursor/server
7
+ */
8
+export { CursorDriver, type CursorDriverEnv } from "./server/driver.ts";
9
+export { CursorAdapterV2Driver, type CursorAdapterV2DriverEnv } from "./server/adapter.ts";
10
+export { CursorKeychainTimeoutError, readMacCursorAccessToken } from "./server/keychainToken.ts";
packages/provider-cursor/src/server/CursorAgentSdk.test.ts
renamed
+2
-2
@@ -5,7 +5,7 @@ import * as Effect from "effect/Effect";
5
import * as Layer from "effect/Layer";
6
import { vi } from "vite-plus/test";
7
8
-import * as ProviderEventLoggers from "../../provider/ProviderEventLoggers.ts";
8
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
9
import * as CursorAgentSdk from "./CursorAgentSdk.ts";
10
11
const cursorSdkMock = vi.hoisted(() => {
@@ -92,7 +92,7 @@ const cursorSdkMock = vi.hoisted(() => {
92
};
93
});
94
95
-vi.mock("../../provider/cursorSdk.ts", () => ({
95
+vi.mock("./sdk.ts", () => ({
96
Agent: {
97
create: cursorSdkMock.create,
98
resume: cursorSdkMock.resume,
packages/provider-cursor/src/server/CursorAgentSdk.ts
renamed
+4
-5
@@ -16,9 +16,8 @@ import * as Effect from "effect/Effect";
16
import * as Layer from "effect/Layer";
17
import * as Schema from "effect/Schema";
18
19
-import { Agent, createAgentPlatform } from "../../provider/cursorSdk.ts";
20
-import type { EventNdjsonLogger } from "../../provider/EventNdjsonLogger.ts";
21
-import * as ProviderEventLoggers from "../../provider/ProviderEventLoggers.ts";
19
+import { Agent, createAgentPlatform } from "./sdk.ts";
20
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
21
22
export const CURSOR_AGENT_SDK_PROTOCOL = "cursor-agent-sdk.local" as const;
23
export const CURSOR_PROVIDER = ProviderDriverKind.make("cursor");
@@ -77,7 +76,7 @@ export interface CursorAgentSdkRunnerShape {
76
export class CursorAgentSdkRunner extends Context.Service<
77
CursorAgentSdkRunner,
78
CursorAgentSdkRunnerShape
80
->()("t3/orchestration-v2/Adapters/CursorAgentSdk/CursorAgentSdkRunner") {}
79
+>()("@t3tools/provider-cursor/server/CursorAgentSdk/CursorAgentSdkRunner") {}
80
81
export interface CursorAgentSdkLoggedAgentOptions {
82
readonly model?: AgentOptions["model"];
@@ -276,7 +275,7 @@ export function loggedCursorSendOptions(
275
}
276
277
function makeCursorAgentSdkProtocolLogger(input: {
279
- readonly nativeEventLogger: EventNdjsonLogger | undefined;
278
+ readonly nativeEventLogger: ProviderEventLoggers.EventNdjsonLogger | undefined;
279
readonly threadId: ThreadId;
280
readonly providerSessionId: OrchestrationV2ProviderSession["id"];
281
}): CursorAgentSdkProtocolLogger | undefined {
packages/provider-cursor/src/server/CursorSdkCatalog.test.ts
renamed
packages/provider-cursor/src/server/CursorSdkCatalog.ts
renamed
+2
-2
@@ -7,7 +7,7 @@ import * as Exit from "effect/Exit";
7
import * as Layer from "effect/Layer";
8
import * as Schema from "effect/Schema";
9
10
-import { AuthenticationError, Cursor, CursorSdkError } from "./cursorSdk.ts";
10
+import { AuthenticationError, Cursor, CursorSdkError } from "./sdk.ts";
11
12
export interface CursorSdkCatalogSnapshot {
13
readonly user: SDKUser;
@@ -33,7 +33,7 @@ export interface CursorSdkCatalogShape {
33
}
34
35
export class CursorSdkCatalog extends Context.Service<CursorSdkCatalog, CursorSdkCatalogShape>()(
36
- "t3/provider/CursorSdkCatalog",
36
+ "@t3tools/provider-cursor/server/CursorSdkCatalog",
37
) {}
38
39
function isAuthenticationFailure(cause: unknown): boolean {
packages/provider-cursor/src/server/adapter.test.ts
renamed
+20
-21
@@ -2,7 +2,6 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
2
import { assert, describe, it } from "@effect/vitest";
3
import type { InteractionUpdate } from "@cursor/sdk";
4
import {
5
- CursorSettings,
5
EnvironmentId,
6
MessageId,
7
NodeId,
@@ -13,6 +12,7 @@ import {
12
RunId,
13
ThreadId,
14
} from "@t3tools/contracts";
15
+import { CursorSettings } from "../settings.ts";
16
import * as DateTime from "effect/DateTime";
17
import * as Effect from "effect/Effect";
18
import * as FileSystem from "effect/FileSystem";
@@ -22,10 +22,11 @@ import * as Path from "effect/Path";
22
import * as Schema from "effect/Schema";
23
import * as Stream from "effect/Stream";
24
25
-import * as ServerConfig from "../../config.ts";
25
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
26
+import { layerTestProviderHost } from "@t3tools/provider-testing/host";
27
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
28
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
28
-import { ProviderAdapterV2RuntimePolicy } from "@t3tools/provider-core/server/ProviderAdapter";
29
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
30
import {
31
cursorMcpServers,
32
cursorRuntimeAgentPolicy,
@@ -33,8 +34,8 @@ import {
34
makeCursorAgentOptions,
35
makeCursorAdapterV2,
36
nestedToolCallFromEnvelope,
36
-} from "./CursorAdapterV2.ts";
37
-import { isCursorCancellationError, loggedCursorAgentOptions } from "./CursorAgentSdk.ts";
37
+} from "./adapter.ts";
38
+import * as CursorAgentSdk from "./CursorAgentSdk.ts";
39
40
const decodeCursorSettings = Schema.decodeEffect(CursorSettings);
41
@@ -57,7 +58,7 @@ describe("CursorAdapterV2", () => {
58
const instanceId = ProviderInstanceId.make("cursor");
59
const threadId = ThreadId.make("cursor-lifecycle-thread");
60
const modelSelection = { instanceId, model: "composer-2.5" };
60
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
61
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
62
runtimeMode: "full-access",
63
interactionMode: "default",
64
cwd: workspace,
@@ -69,10 +70,8 @@ describe("CursorAdapterV2", () => {
70
fileSystem,
71
path,
72
idAllocator: yield* IdAllocator.IdAllocatorV2,
72
- serverConfig: yield* ServerConfig.ServerConfig.pipe(
73
- Effect.provide(
74
- ServerConfig.layerTest(workspace, { prefix: "cursor-v2-lifecycle-config-" }),
75
- ),
73
+ host: yield* ProviderHost.ProviderHost.pipe(
74
+ Effect.provide(layerTestProviderHost({ cwd: workspace })),
75
),
76
runner: {
77
assertComplete: Effect.void,
@@ -219,7 +218,7 @@ describe("CursorAdapterV2", () => {
218
const instanceId = ProviderInstanceId.make("cursor");
219
const threadId = ThreadId.make("cursor-transport-error-thread");
220
const modelSelection = { instanceId, model: "composer-2.5" };
222
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
221
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
222
runtimeMode: "full-access",
223
interactionMode: "default",
224
cwd: workspace,
@@ -231,8 +230,8 @@ describe("CursorAdapterV2", () => {
230
fileSystem,
231
path,
232
idAllocator: yield* IdAllocator.IdAllocatorV2,
234
- serverConfig: yield* ServerConfig.ServerConfig.pipe(
235
- Effect.provide(ServerConfig.layerTest(workspace, { prefix: "cursor-v2-error-config-" })),
233
+ host: yield* ProviderHost.ProviderHost.pipe(
234
+ Effect.provide(layerTestProviderHost({ cwd: workspace })),
235
),
236
runner: {
237
assertComplete: Effect.void,
@@ -367,7 +366,7 @@ describe("CursorAdapterV2", () => {
366
const instanceId = ProviderInstanceId.make("cursor");
367
const threadId = ThreadId.make("cursor-search-thread");
368
const modelSelection = { instanceId, model: "composer-2.5" };
370
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
369
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
370
runtimeMode: "full-access",
371
interactionMode: "default",
372
cwd: workspace,
@@ -572,8 +571,8 @@ describe("CursorAdapterV2", () => {
571
fileSystem,
572
path,
573
idAllocator: yield* IdAllocator.IdAllocatorV2,
575
- serverConfig: yield* ServerConfig.ServerConfig.pipe(
576
- Effect.provide(ServerConfig.layerTest(workspace, { prefix: "cursor-v2-search-config-" })),
574
+ host: yield* ProviderHost.ProviderHost.pipe(
575
+ Effect.provide(layerTestProviderHost({ cwd: workspace })),
576
),
577
runner: {
578
assertComplete: Effect.void,
@@ -908,7 +907,7 @@ describe("CursorAdapterV2", () => {
907
});
908
assert.deepEqual(options.mcpServers, cursorMcpServers(threadId));
909
911
- const logged = JSON.stringify(loggedCursorAgentOptions(options));
910
+ const logged = JSON.stringify(CursorAgentSdk.loggedCursorAgentOptions(options));
911
assert.notInclude(logged, "secret-cursor-api-key");
912
assert.notInclude(logged, "secret-cursor-mcp-token");
913
} finally {
@@ -917,9 +916,9 @@ describe("CursorAdapterV2", () => {
916
});
917
918
it("recognizes direct and SDK-wrapped abort failures as cancellation", () => {
920
- assert.isTrue(isCursorCancellationError({ name: "AbortError" }));
919
+ assert.isTrue(CursorAgentSdk.isCursorCancellationError({ name: "AbortError" }));
920
assert.isTrue(
922
- isCursorCancellationError({
921
+ CursorAgentSdk.isCursorCancellationError({
922
name: "ConnectError",
923
cause: {
924
name: "ConnectError",
@@ -927,8 +926,8 @@ describe("CursorAdapterV2", () => {
926
},
927
}),
928
);
930
- assert.isFalse(isCursorCancellationError(new Error("request failed")));
931
- assert.isFalse(isCursorCancellationError(null));
929
+ assert.isFalse(CursorAgentSdk.isCursorCancellationError(new Error("request failed")));
930
+ assert.isFalse(CursorAgentSdk.isCursorCancellationError(null));
931
});
932
933
it("preserves failed nested read calls when Cursor omits their path", () => {
packages/provider-cursor/src/server/adapter.ts
renamed
+16
-21
@@ -11,7 +11,6 @@ import type {
11
import { formatReadToolLabel, formatSearchToolLabel } from "@t3tools/shared/toolActivity";
12
import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";
13
import {
14
- CursorSettings,
14
isOrchestrationV2WorkActive,
15
defaultInstanceIdForDriver,
16
type ChatAttachment,
@@ -30,6 +29,7 @@ import {
29
type ProviderInstanceId,
30
type ThreadId,
31
} from "@t3tools/contracts";
32
+import { CursorSettings } from "../settings.ts";
33
import * as DateTime from "effect/DateTime";
34
import * as Deferred from "effect/Deferred";
35
import * as Effect from "effect/Effect";
@@ -42,17 +42,16 @@ import * as Ref from "effect/Ref";
42
import * as Schema from "effect/Schema";
43
import * as Stream from "effect/Stream";
44
45
-import { resolveAttachmentPath } from "../../attachmentStore.ts";
46
-import * as ServerConfig from "../../config.ts";
45
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
46
import { mcpToolPresentation } from "@t3tools/provider-core/server/mcpToolPresentation";
47
import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
49
-import { CursorTransportFailure } from "../../provider/acp/CursorTransportFailure.ts";
50
-import { cursorSdkModelSelection } from "../../provider/cursorSdkModel.ts";
48
+import { CursorTransportFailure } from "./transportFailure.ts";
49
+import { cursorSdkModelSelection } from "./sdkModel.ts";
50
import {
51
discoverCursorSkills,
52
hasCursorSkillMention,
53
rewriteCursorSkillMentions,
55
-} from "../../provider/Drivers/CursorSkills.ts";
54
+} from "./skills.ts";
55
import { mergeProviderInstanceEnvironment } from "@t3tools/provider-core/server/instanceEnvironment";
56
import { t3OrchestrationPromptForFirstRun } from "@t3tools/provider-core/server/orchestrationInstructions";
57
import { buildRuntimeInstructions } from "@t3tools/provider-core/server/runtimeInstructions";
@@ -75,7 +74,7 @@ import {
74
subagentThreadTitle,
75
} from "@t3tools/provider-core/server/subagentProjection";
76
import * as CursorAgentSdk from "./CursorAgentSdk.ts";
78
-export { cursorSdkModelSelection } from "../../provider/cursorSdkModel.ts";
77
+export { cursorSdkModelSelection } from "./sdkModel.ts";
78
79
export const CURSOR_DRIVER_KIND = CursorAgentSdk.CURSOR_PROVIDER;
80
export const CURSOR_DEFAULT_INSTANCE_ID = defaultInstanceIdForDriver(CURSOR_DRIVER_KIND);
@@ -849,13 +848,13 @@ export interface CursorAdapterV2Options {
848
readonly path: Path.Path;
849
readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
850
readonly runner: CursorAgentSdk.CursorAgentSdkRunnerShape;
852
- readonly serverConfig: ServerConfig.ServerConfig["Service"];
851
+ readonly host: ProviderHost.ProviderHostShape;
852
}
853
854
export function makeCursorAdapterV2(
855
adapterOptions: CursorAdapterV2Options,
856
): ProviderAdapter.ProviderAdapterV2Shape {
858
- const { fileSystem, path, idAllocator, runner, serverConfig } = adapterOptions;
857
+ const { fileSystem, path, idAllocator, runner, host } = adapterOptions;
858
const apiKey = adapterOptions.environment.CURSOR_API_KEY?.trim() || undefined;
859
860
return ProviderAdapter.ProviderAdapterV2.of({
@@ -2133,8 +2132,7 @@ export function makeCursorAdapterV2(
2132
? rawText
2133
: rewriteCursorSkillMentions(rawText, cursorSkillNames),
2134
attachments: turnInput.message.attachments,
2136
- resolveAttachmentPath: (attachment) =>
2137
- resolveAttachmentPath({ attachmentsDir: serverConfig.attachmentsDir, attachment }),
2135
+ resolveAttachmentPath: host.resolveAttachmentPath,
2136
}),
2137
runOrdinal: turnInput.runOrdinal,
2138
hasT3Mcp: cursorMcpServers(turnInput.threadId) !== undefined,
@@ -2143,10 +2141,7 @@ export function makeCursorAdapterV2(
2141
turnInput.message.attachments.filter(isProviderNativeImageAttachment),
2142
(attachment: ChatAttachment) =>
2143
Effect.gen(function* () {
2146
- const path = resolveAttachmentPath({
2147
- attachmentsDir: serverConfig.attachmentsDir,
2148
- attachment,
2149
- });
2144
+ const path = host.resolveAttachmentPath(attachment);
2145
if (path === null) {
2146
return yield* new ProviderAdapter.ProviderAdapterProtocolError({
2147
driver: CursorAgentSdk.CURSOR_PROVIDER,
@@ -2608,7 +2603,7 @@ export type CursorAdapterV2DriverEnv =
2603
| FileSystem.FileSystem
2604
| Path.Path
2605
| IdAllocator.IdAllocatorV2
2611
- | ServerConfig.ServerConfig;
2606
+ | ProviderHost.ProviderHost;
2607
2608
export const CursorAdapterV2Driver: ProviderAdapterDriver<
2609
CursorSettings,
@@ -2624,7 +2619,7 @@ export const CursorAdapterV2Driver: ProviderAdapterDriver<
2619
const path = yield* Path.Path;
2620
const idAllocator = yield* IdAllocator.IdAllocatorV2;
2621
const runner = yield* CursorAgentSdk.CursorAgentSdkRunner;
2627
- const serverConfig = yield* ServerConfig.ServerConfig;
2622
+ const host = yield* ProviderHost.ProviderHost;
2623
return makeCursorAdapterV2({
2624
instanceId: input.instanceId,
2625
settings: {
@@ -2636,7 +2631,7 @@ export const CursorAdapterV2Driver: ProviderAdapterDriver<
2631
path,
2632
idAllocator,
2633
runner,
2639
- serverConfig,
2634
+ host,
2635
});
2636
},
2637
(effect, input) =>
@@ -2661,7 +2656,7 @@ const layer: Layer.Layer<
2656
| FileSystem.FileSystem
2657
| Path.Path
2658
| IdAllocator.IdAllocatorV2
2664
- | ServerConfig.ServerConfig
2659
+ | ProviderHost.ProviderHost
2660
> = Layer.effect(
2661
ProviderAdapter.ProviderAdapterV2,
2662
Effect.gen(function* () {
@@ -2670,7 +2665,7 @@ const layer: Layer.Layer<
2665
const path = yield* Path.Path;
2666
const idAllocator = yield* IdAllocator.IdAllocatorV2;
2667
const runner = yield* CursorAgentSdk.CursorAgentSdkRunner;
2673
- const serverConfig = yield* ServerConfig.ServerConfig;
2668
+ const host = yield* ProviderHost.ProviderHost;
2669
return makeCursorAdapterV2({
2670
instanceId: CURSOR_DEFAULT_INSTANCE_ID,
2671
settings: DEFAULT_CURSOR_SETTINGS,
@@ -2679,7 +2674,7 @@ const layer: Layer.Layer<
2674
path,
2675
idAllocator,
2676
runner,
2682
- serverConfig,
2677
+ host,
2678
});
2679
}),
2680
);
packages/provider-cursor/src/server/auth.test.ts
renamed
+2
-2
@@ -12,8 +12,8 @@ import * as Scope from "effect/Scope";
12
import * as Stream from "effect/Stream";
13
import * as TestClock from "effect/testing/TestClock";
14
15
-import { makeCursorAuth, type CursorAuthOptions } from "./CursorAuth.ts";
16
-import { InMemoryCredentialStore } from "./cursorSdk.ts";
15
+import { makeCursorAuth, type CursorAuthOptions } from "./auth.ts";
16
+import { InMemoryCredentialStore } from "./sdk.ts";
17
18
const instanceId = ProviderInstanceId.make("cursor-personal");
19
const owner = "owner-client";
packages/provider-cursor/src/server/auth.ts
renamed
+2
-2
@@ -16,8 +16,8 @@ import * as Semaphore from "effect/Semaphore";
16
import * as Stream from "effect/Stream";
17
import * as SubscriptionRef from "effect/SubscriptionRef";
18
19
-import { Cursor, InMemoryCredentialStore } from "./cursorSdk.ts";
20
-import type { ProviderAuthController } from "./ProviderAuthService.ts";
19
+import { Cursor, InMemoryCredentialStore } from "./sdk.ts";
20
+import type { ProviderAuthController } from "@t3tools/provider-core/server/auth";
21
22
const AUTH_TIMEOUT_MS = 300_000;
23
packages/provider-cursor/src/server/credentialStore.test.ts
renamed
+15
-50
@@ -6,28 +6,12 @@ import * as FileSystem from "effect/FileSystem";
6
import * as Path from "effect/Path";
7
import * as Option from "effect/Option";
8
9
-import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
10
-import { makeCursorCredentialStore } from "./CursorCredentialStore.ts";
9
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
10
+import { layerTestProviderHost } from "@t3tools/provider-testing/host";
11
+import * as Layer from "effect/Layer";
12
+import { makeCursorCredentialStore } from "./credentialStore.ts";
13
12
-const makeSecrets = () => {
13
- const data = new Map<string, Uint8Array>();
14
- return {
15
- data,
16
- secrets: ServerSecretStore.ServerSecretStore.of({
17
- get: (key) => Effect.sync(() => Option.fromUndefinedOr(data.get(key))),
18
- set: (key, bytes) =>
19
- Effect.sync(() => {
20
- data.set(key, bytes);
21
- }),
22
- remove: (key) =>
23
- Effect.sync(() => {
24
- data.delete(key);
25
- }),
26
- create: () => Effect.die("unused"),
27
- getOrCreateRandom: () => Effect.die("unused"),
28
- }),
29
- };
30
-};
14
+const layerHost = Layer.provideMerge(layerTestProviderHost(), NodeServices.layer);
15
16
const legacyCredentials = {
17
version: 1 as const,
@@ -74,44 +58,23 @@ it.effect.each([
58
const path = yield* Path.Path;
59
const legacyFile = path.join(yield* fileSystem.makeTempDirectoryScoped(), "cursor.json");
60
yield* fileSystem.writeFileString(legacyFile, legacy);
77
- const { secrets } = makeSecrets();
61
+ const host = yield* ProviderHost.ProviderHost;
62
const instanceId = ProviderInstanceId.make("personal");
63
if (stored !== undefined) {
80
- const current = yield* makeCursorCredentialStore(instanceId).pipe(
81
- Effect.provideService(ServerSecretStore.ServerSecretStore, secrets),
82
- );
83
- yield* secrets.set(current.binding.key, new TextEncoder().encode(stored));
64
+ yield* (yield* host.credentials("cursor", instanceId)).set(new TextEncoder().encode(stored));
65
}
85
- const migrated = yield* makeCursorCredentialStore(instanceId, legacyFile).pipe(
86
- Effect.provideService(ServerSecretStore.ServerSecretStore, secrets),
87
- );
66
+ const migrated = yield* makeCursorCredentialStore(instanceId, legacyFile);
67
assert.strictEqual((yield* Effect.tryPromise(() => migrated.store.load()))?.apiKey, expected);
68
assert.isFalse(yield* fileSystem.exists(legacyFile));
90
- }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
69
+ }).pipe(Effect.scoped, Effect.provide(layerHost)),
70
);
71
72
it.effect(
73
"restores SDK credentials in a new controller and keeps another account when signing out",
74
() =>
75
Effect.gen(function* () {
97
- const data = new Map<string, Uint8Array>();
98
- const secrets = ServerSecretStore.ServerSecretStore.of({
99
- get: (key) => Effect.sync(() => Option.fromUndefinedOr(data.get(key))),
100
- set: (key, bytes) =>
101
- Effect.sync(() => {
102
- data.set(key, bytes);
103
- }),
104
- remove: (key) =>
105
- Effect.sync(() => {
106
- data.delete(key);
107
- }),
108
- create: () => Effect.die("unused"),
109
- getOrCreateRandom: () => Effect.die("unused"),
110
- });
111
- const makeStore = (id: string) =>
112
- makeCursorCredentialStore(ProviderInstanceId.make(id)).pipe(
113
- Effect.provideService(ServerSecretStore.ServerSecretStore, secrets),
114
- );
76
+ const host = yield* ProviderHost.ProviderHost;
77
+ const makeStore = (id: string) => makeCursorCredentialStore(ProviderInstanceId.make(id));
78
const personal = yield* makeStore("personal");
79
const work = yield* makeStore("work");
80
const credentials = {
@@ -128,7 +91,9 @@ it.effect(
91
);
92
const restored = yield* makeStore("personal");
93
assert.deepEqual(yield* Effect.tryPromise(() => restored.store.load()), credentials);
131
- data.set(personal.binding.key, new TextEncoder().encode("damaged credential"));
94
+ yield* (yield* host.credentials("cursor", "personal")).set(
95
+ new TextEncoder().encode("damaged credential"),
96
+ );
97
assert.isUndefined(yield* Effect.tryPromise(() => restored.store.load()));
98
yield* Effect.tryPromise(() => restored.store.save(credentials));
99
yield* Effect.tryPromise(() => restored.store.clear());
@@ -137,5 +102,5 @@ it.effect(
102
(yield* Effect.tryPromise(() => work.store.load()))?.apiKey,
103
"test-only-work-key",
104
);
140
- }).pipe(Effect.provide(NodeServices.layer)),
105
+ }).pipe(Effect.provide(layerHost)),
106
);
packages/provider-cursor/src/server/credentialStore.ts
renamed
+2
-2
@@ -5,7 +5,7 @@ import * as FileSystem from "effect/FileSystem";
5
import * as Option from "effect/Option";
6
import * as Schema from "effect/Schema";
7
8
-import * as ProviderCredentialStore from "./ProviderCredentialStore.ts";
8
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
9
10
const Credentials = Schema.fromJsonString(
11
Schema.Struct({
@@ -30,7 +30,7 @@ export const makeCursorCredentialStore = Effect.fn("makeCursorCredentialStore")(
30
instanceId: ProviderInstanceId,
31
legacyFile?: string,
32
) {
33
- const credentials = yield* ProviderCredentialStore.make("cursor", instanceId);
33
+ const credentials = yield* (yield* ProviderHost.ProviderHost).credentials("cursor", instanceId);
34
if (legacyFile !== undefined) {
35
const fileSystem = yield* FileSystem.FileSystem;
36
yield* Effect.gen(function* () {
packages/provider-cursor/src/server/driver.test.ts
renamed
+8
-24
@@ -1,5 +1,4 @@
1
// @effect-diagnostics nodeBuiltinImport:off
2
-import * as ServerSecretStore from "../../auth/ServerSecretStore.ts";
2
import * as NodeServices from "@effect/platform-node/NodeServices";
3
import { expect, it } from "@effect/vitest";
4
import { ProviderInstanceId, ProviderSessionId, ThreadId } from "@t3tools/contracts";
@@ -11,23 +10,15 @@ import { vi } from "vite-plus/test";
10
import { HttpClient } from "effect/http";
11
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
12
14
-import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts";
15
-import * as ServerConfig from "../../config.ts";
16
-import * as ServerSettings from "../../serverSettings.ts";
17
-import * as ProviderEventLoggers from "../ProviderEventLoggers.ts";
18
-import { CursorDriver } from "./CursorDriver.ts";
19
-import * as CursorAgentSdk from "../../orchestration-v2/Adapters/CursorAgentSdk.ts";
13
+import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
14
+import { layerTestProviderHost } from "@t3tools/provider-testing/host";
15
+import { CursorDriver } from "./driver.ts";
16
+import * as CursorAgentSdk from "./CursorAgentSdk.ts";
17
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
21
-import { ProviderAdapterV2RuntimePolicy } from "@t3tools/provider-core/server/ProviderAdapter";
22
-import { Cursor } from "../cursorSdk.ts";
23
-import * as ProviderHostLive from "../ProviderHostLive.ts";
18
+import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
19
+import { Cursor } from "./sdk.ts";
20
25
-const layerDeps = ServerSecretStore.layer.pipe(
26
- Layer.provideMerge(
27
- ServerConfig.layerTest(process.cwd(), {
28
- prefix: "t3-cursor-driver-copy-command-",
29
- }),
30
- ),
21
+const layerTest = layerTestProviderHost({ runBackgroundWork: false }).pipe(
22
Layer.provideMerge(NodeServices.layer),
23
Layer.provideMerge(IdAllocator.layer),
24
Layer.provideMerge(
@@ -35,12 +26,6 @@ const layerDeps = ServerSecretStore.layer.pipe(
26
open: () => Effect.die("Maintenance resolution must not open a Cursor session"),
27
}),
28
),
38
- Layer.provideMerge(ServerSettings.layerTest()),
39
- Layer.provideMerge(
40
- Layer.mock(BackgroundPolicy.BackgroundPolicy)({
41
- shouldRunScopeWork: () => Effect.succeed(false),
42
- }),
43
- ),
29
Layer.provideMerge(
30
Layer.succeed(
31
ProviderEventLoggers.ProviderEventLoggers,
@@ -54,7 +39,6 @@ const layerDeps = ServerSecretStore.layer.pipe(
39
),
40
),
41
);
57
-const layerTest = ProviderHostLive.layer.pipe(Layer.provideMerge(layerDeps));
42
43
it.layer(layerTest)("CursorDriver", (it) => {
44
it.effect(
@@ -134,7 +118,7 @@ it.layer(layerTest)("CursorDriver", (it) => {
118
});
119
const threadId = ThreadId.make("cursor-browser-thread");
120
const modelSelection = { instanceId: input.instanceId, model: "auto" };
137
- const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
121
+ const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
122
runtimeMode: "full-access",
123
interactionMode: "default",
124
cwd: process.cwd(),
packages/provider-cursor/src/server/driver.ts
renamed
+17
-29
@@ -6,29 +6,22 @@
6
*
7
* @module provider/Drivers/CursorDriver
8
*/
9
-import { CursorSettings, ProviderDriverKind, ProviderSetupError } from "@t3tools/contracts";
9
+import { ProviderDriverKind, ProviderSetupError } from "@t3tools/contracts";
10
+import { CursorSettings } from "../settings.ts";
11
import * as Effect from "effect/Effect";
12
import * as Crypto from "effect/Crypto";
13
import * as FileSystem from "effect/FileSystem";
14
import * as Path from "effect/Path";
15
import * as Schema from "effect/Schema";
16
import { HttpClient } from "effect/http";
16
-import { readCursorUsageLimits } from "../cursorUsageLimits.ts";
17
+import { readCursorUsageLimits } from "./usageLimits.ts";
18
18
-import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
19
-import * as ServerConfig from "../../config.ts";
20
-import * as ServerSettings from "../../serverSettings.ts";
21
-import { makeCursorTextGeneration } from "../../textGeneration/CursorTextGeneration.ts";
22
-import {
23
- CursorAdapterV2Driver,
24
- type CursorAdapterV2DriverEnv,
25
-} from "../../orchestration-v2/Adapters/CursorAdapterV2.ts";
26
-import { ProviderDriverError } from "../Errors.ts";
27
-import {
28
- buildInitialCursorProviderSnapshot,
29
- checkCursorProviderStatus,
30
-} from "../CursorProvider.ts";
31
-import * as CursorSdkCatalog from "../CursorSdkCatalog.ts";
19
+import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
20
+import { makeCursorTextGeneration } from "./textGeneration.ts";
21
+import { CursorAdapterV2Driver, type CursorAdapterV2DriverEnv } from "./adapter.ts";
22
+import { ProviderDriverError } from "@t3tools/provider-core/server/errors";
23
+import { buildInitialCursorProviderSnapshot, checkCursorProviderStatus } from "./status.ts";
24
+import * as CursorSdkCatalog from "./CursorSdkCatalog.ts";
25
import { makeManagedServerProvider } from "@t3tools/provider-core/server/managedProvider";
26
import {
27
defaultProviderContinuationIdentity,
@@ -43,11 +36,10 @@ import {
36
makeProviderSnapshotSettingsSource,
37
type ProviderSnapshotSettings,
38
} from "@t3tools/provider-core/server/snapshotSettings";
46
-import { probeCursorSkills } from "./CursorSkills.ts";
47
-import { makeCursorAuth } from "../CursorAuth.ts";
48
-import * as CursorCredentialStore from "../CursorCredentialStore.ts";
49
-import * as ServerSecretStore from "../../auth/ServerSecretStore.ts";
50
-import * as CursorAgentSdk from "../../orchestration-v2/Adapters/CursorAgentSdk.ts";
39
+import { probeCursorSkills } from "./skills.ts";
40
+import { makeCursorAuth } from "./auth.ts";
41
+import * as CursorCredentialStore from "./credentialStore.ts";
42
+import * as CursorAgentSdk from "./CursorAgentSdk.ts";
43
const decodeCursorSettings = Schema.decodeSync(CursorSettings);
44
const isSdkRunnerError = Schema.is(CursorAgentSdk.CursorAgentSdkRunnerError);
45
@@ -63,10 +55,7 @@ export type CursorDriverEnv =
55
| FileSystem.FileSystem
56
| Path.Path
57
| HttpClient.HttpClient
66
- | ProviderHost
67
- | ServerConfig.ServerConfig
68
- | ServerSecretStore.ServerSecretStore
69
- | ServerSettings.ServerSettingsService;
58
+ | ProviderHost.ProviderHost;
59
60
export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
61
driverKind: DRIVER_KIND,
@@ -78,8 +67,7 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
67
defaultConfig: (): CursorSettings => decodeCursorSettings({}),
68
create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
69
Effect.gen(function* () {
81
- const serverSettings = yield* ServerSettings.ServerSettingsService;
82
- const host = yield* ProviderHost;
70
+ const host = yield* ProviderHost.ProviderHost;
71
const fileSystem = yield* FileSystem.FileSystem;
72
const path = yield* Path.Path;
73
const httpClient = yield* HttpClient.HttpClient;
@@ -100,7 +88,7 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
88
const credentials = yield* CursorCredentialStore.makeCursorCredentialStore(
89
instanceId,
90
path.join(
103
- (yield* ServerConfig.ServerConfig).stateDir,
91
+ host.paths.stateDir,
92
"provider-auth",
93
encodeURIComponent(instanceId),
94
"cursor.json",
@@ -214,7 +202,7 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
202
effectiveConfig.enabled &&
203
snapshot.installed &&
204
snapshot.auth.status === "authenticated"
217
- ? serverSettings.getSettings.pipe(
205
+ ? host.settings.get.pipe(
206
Effect.flatMap((settings) =>
207
readCursorUsageLimits(
208
effectiveConfig,
packages/provider-cursor/src/server/keychainToken.test.ts
renamed
+1
-4
@@ -1,9 +1,6 @@
1
import { assert, describe, it } from "@effect/vitest";
2
3
-import {
4
- CursorKeychainTimeoutError,
5
- makeCachedCursorAccessTokenReader,
6
-} from "./cursorKeychainToken.ts";
3
+import { CursorKeychainTimeoutError, makeCachedCursorAccessTokenReader } from "./keychainToken.ts";
4
5
describe("Cursor Keychain reader", () => {
6
it("shares concurrent reads and rechecks after the cache expires", async () => {
packages/provider-cursor/src/server/keychainToken.ts
renamed
packages/provider-cursor/src/server/sdk.test.ts
renamed
+2
-2
@@ -2,9 +2,9 @@
2
import * as NodeChildProcess from "node:child_process";
3
import { describe, expect, it } from "vite-plus/test";
4
5
-const cursorSdkUrl = new URL("./cursorSdk.ts", import.meta.url).href;
5
+const cursorSdkUrl = new URL("./sdk.ts", import.meta.url).href;
6
7
-// Loads cursorSdk.ts in a fresh process. @cursor/sdk is stubbed so the guard
7
+// Loads sdk.ts in a fresh process. @cursor/sdk is stubbed so the guard
8
// can be tested without the real package. The vitest worker already has its
9
// own unhandledRejection listener, which would hide the process-exit behavior.
10
const probeProgram = `
packages/provider-cursor/src/server/sdk.ts
renamed
packages/provider-cursor/src/server/sdkModel.ts
renamed
packages/provider-cursor/src/server/skills.test.ts
renamed
+1
-1
@@ -12,7 +12,7 @@ import {
12
hasCursorSkillMention,
13
probeCursorSkills,
14
rewriteCursorSkillMentions,
15
-} from "./CursorSkills.ts";
15
+} from "./skills.ts";
16
17
const runNode = <A, E>(
18
effect: Effect.Effect<A, E, FileSystem.FileSystem | Path.Path | Scope.Scope>,
packages/provider-cursor/src/server/skills.ts
renamed
packages/provider-cursor/src/server/status.test.ts
renamed
+3
-3
@@ -2,8 +2,8 @@ import type { SDKModel } from "@cursor/sdk";
2
import { describe, expect, it } from "@effect/vitest";
3
import * as Effect from "effect/Effect";
4
import * as Schema from "effect/Schema";
5
-import type { CursorSettings } from "@t3tools/contracts";
6
-import { CursorSettings as CursorSettingsSchema } from "@t3tools/contracts";
5
+import type { CursorSettings } from "../settings.ts";
6
+import { CursorSettings as CursorSettingsSchema } from "../settings.ts";
7
import { createModelCapabilities } from "@t3tools/shared/model";
8
9
import {
@@ -12,7 +12,7 @@ import {
12
buildCursorProviderSnapshot,
13
buildInitialCursorProviderSnapshot,
14
checkCursorProviderStatus,
15
-} from "./CursorProvider.ts";
15
+} from "./status.ts";
16
import * as CursorSdkCatalog from "./CursorSdkCatalog.ts";
17
18
const decodeCursorSettings = Schema.decodeSync(CursorSettingsSchema);
packages/provider-cursor/src/server/status.ts
renamed
+2
-2
@@ -1,19 +1,19 @@
1
import type { SDKModel, SDKUser } from "@cursor/sdk";
2
import type {
3
- CursorSettings,
3
ModelCapabilities,
4
ProviderOptionDescriptor,
5
ServerProviderAuth,
6
ServerProviderModel,
7
ServerProviderState,
8
} from "@t3tools/contracts";
9
+import type { CursorSettings } from "../settings.ts";
10
import { createModelCapabilities } from "@t3tools/shared/model";
11
import * as DateTime from "effect/DateTime";
12
import * as Effect from "effect/Effect";
13
import * as Option from "effect/Option";
14
import * as Result from "effect/Result";
15
16
-import { cursorSdkParameterPriority, cursorSdkProviderOptionId } from "./cursorSdkModel.ts";
16
+import { cursorSdkParameterPriority, cursorSdkProviderOptionId } from "./sdkModel.ts";
17
import {
18
buildBooleanOptionDescriptor,
19
buildSelectOptionDescriptor,
packages/provider-cursor/src/server/textGeneration.test.ts
renamed
+4
-3
@@ -1,5 +1,6 @@
1
import type { RunResult } from "@cursor/sdk";
2
-import { CursorSettings, ProviderInstanceId, TextGenerationError } from "@t3tools/contracts";
2
+import { ProviderInstanceId, TextGenerationError } from "@t3tools/contracts";
3
+import { CursorSettings } from "../settings.ts";
4
import { describe, expect, it } from "@effect/vitest";
5
import * as Effect from "effect/Effect";
6
import * as FileSystem from "effect/FileSystem";
@@ -9,7 +10,7 @@ import * as Schema from "effect/Schema";
10
import { createModelSelection } from "@t3tools/shared/model";
11
import { beforeEach, vi } from "vite-plus/test";
12
12
-import { makeCursorTextGeneration } from "./CursorTextGeneration.ts";
13
+import { makeCursorTextGeneration } from "./textGeneration.ts";
14
15
const cursorSdkMock = vi.hoisted(() => ({
16
create: vi.fn<(options: unknown) => Promise<unknown>>(),
@@ -24,7 +25,7 @@ const cursorSdkMock = vi.hoisted(() => ({
25
})),
26
}));
27
27
-vi.mock("../provider/cursorSdk.ts", () => ({ Agent: { create: cursorSdkMock.create } }));
28
+vi.mock("./sdk.ts", () => ({ Agent: { create: cursorSdkMock.create } }));
29
30
let hasCustomPolicy = false;
31
const layerFs = FileSystem.layerNoop({
packages/provider-cursor/src/server/textGeneration.ts
renamed
+5
-8
@@ -2,20 +2,17 @@ import * as NodeOS from "node:os";
2
import * as FileSystem from "effect/FileSystem";
3
4
import type { AgentOptions, RunResult } from "@cursor/sdk";
5
-import { Agent } from "../provider/cursorSdk.ts";
5
+import { Agent } from "./sdk.ts";
6
import * as Effect from "effect/Effect";
7
import * as Option from "effect/Option";
8
import * as Schema from "effect/Schema";
9
10
-import {
11
- type CursorSettings,
12
- type ProviderSetupError,
13
- TextGenerationError,
14
-} from "@t3tools/contracts";
10
+import { type ProviderSetupError, TextGenerationError } from "@t3tools/contracts";
11
+import type { CursorSettings } from "../settings.ts";
12
13
import * as TextGenerationOperations from "@t3tools/provider-core/server/textGenerationOperations";
17
-import { cursorSdkModelSelection } from "../provider/cursorSdkModel.ts";
18
-import type { CursorAuth } from "../provider/CursorAuth.ts";
14
+import { cursorSdkModelSelection } from "./sdkModel.ts";
15
+import type { CursorAuth } from "./auth.ts";
16
17
const CURSOR_TIMEOUT_MS = 180_000;
18
packages/provider-cursor/src/server/transportFailure.test.ts
renamed
+1
-1
@@ -1,6 +1,6 @@
1
import { describe, expect, it } from "vite-plus/test";
2
3
-import { CursorTransportFailure } from "./CursorTransportFailure.ts";
3
+import { CursorTransportFailure } from "./transportFailure.ts";
4
5
const diagnostic = "Error: RetriableError: WritableIterable is closed";
6
packages/provider-cursor/src/server/transportFailure.ts
renamed
packages/provider-cursor/src/server/usageLimits.test.ts
renamed
+1
-1
@@ -5,7 +5,7 @@ import * as Effect from "effect/Effect";
5
import * as FileSystem from "effect/FileSystem";
6
import * as Path from "effect/Path";
7
import { HttpClient, HttpClientResponse } from "effect/http";
8
-import { cursorUsageResponseToLimits, readCursorUsageLimits } from "./cursorUsageLimits.ts";
8
+import { cursorUsageResponseToLimits, readCursorUsageLimits } from "./usageLimits.ts";
9
10
const withNodeServices = <A, E>(effect: Effect.Effect<A, E, FileSystem.FileSystem | Path.Path>) =>
11
effect.pipe(Effect.provide(NodeServices.layer));
packages/provider-cursor/src/server/usageLimits.ts
renamed
+3
-2
@@ -1,5 +1,6 @@
1
import * as NodeOS from "node:os";
2
-import type { CursorSettings, ServerProviderUsageWindow } from "@t3tools/contracts";
2
+import type { ServerProviderUsageWindow } from "@t3tools/contracts";
3
+import type { CursorSettings } from "../settings.ts";
4
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
5
import { CURSOR_USAGE_WINDOWS } from "@t3tools/shared/usageLimits";
6
import * as DateTime from "effect/DateTime";
@@ -14,7 +15,7 @@ import {
15
makeUnavailableUsageLimits,
16
makeUsageLimits,
17
} from "@t3tools/provider-core/server/usageLimits";
17
-import { readMacCursorAccessToken } from "./cursorKeychainToken.ts";
18
+import { readMacCursorAccessToken } from "./keychainToken.ts";
19
20
const CursorCredentials = Schema.Struct({ accessToken: Schema.optional(Schema.String) });
21
const DEFAULT_CURSOR_API_ENDPOINT = "https://api2.cursor.sh";
packages/provider-cursor/src/settings.ts
new
+35
@@ -0,0 +1,35 @@
1
+/**
2
+ * Cursor instance settings. Shared by the server driver and the client
3
+ * settings form, so it holds only browser-safe schema code.
4
+ *
5
+ * @module provider-cursor/settings
6
+ */
7
+import { CustomModelSetting, makeProviderSettingsSchema, TrimmedString } from "@t3tools/contracts";
8
+import * as Effect from "effect/Effect";
9
+import * as Schema from "effect/Schema";
10
+
11
+export const CursorSettings = makeProviderSettingsSchema(
12
+ {
13
+ // Off by default like Grok and OpenCode. Users opt in from Settings.
14
+ enabled: Schema.Boolean.pipe(
15
+ Schema.withDecodingDefault(Effect.succeed(false)),
16
+ Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
17
+ ),
18
+ // Keep V1's CLI configuration when V2 rewrites the shared settings file.
19
+ // V2's Cursor SDK does not use these fields.
20
+ binaryPath: Schema.optionalKey(TrimmedString).pipe(
21
+ Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
22
+ ),
23
+ apiEndpoint: Schema.optionalKey(TrimmedString).pipe(
24
+ Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
25
+ ),
26
+ customModels: Schema.Array(CustomModelSetting).pipe(
27
+ Schema.withDecodingDefault(Effect.succeed([])),
28
+ Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
29
+ ),
30
+ },
31
+ {
32
+ order: [],
33
+ },
34
+);
35
+export type CursorSettings = typeof CursorSettings.Type;
packages/provider-cursor/src/testing.ts
new
+13
@@ -0,0 +1,13 @@
1
+/**
2
+ * Cursor internals the server's replay testkit, fixture recorder, and
3
+ * orchestration tests use directly.
4
+ *
5
+ * @module provider-cursor/testing
6
+ */
7
+export {
8
+ CURSOR_DEFAULT_INSTANCE_ID,
9
+ CURSOR_DRIVER_KIND,
10
+ CursorProviderCapabilitiesV2,
11
+ cursorSdkModelSelection,
12
+ makeCursorAgentOptions,
13
+} from "./server/adapter.ts";
packages/provider-cursor/tsconfig.json
new
+7
@@ -0,0 +1,7 @@
1
+{
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "types": ["node"]
5
+ },
6
+ "include": ["src"]
7
+}
packages/provider-testing/src/host.ts
+13
@@ -10,6 +10,7 @@ import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
10
import * as Effect from "effect/Effect";
11
import * as FileSystem from "effect/FileSystem";
12
import * as Layer from "effect/Layer";
13
+import * as Option from "effect/Option";
14
import * as Path from "effect/Path";
15
import * as Stream from "effect/Stream";
16
@@ -39,6 +40,7 @@ export const layerTestProviderHost = (
40
yield* fileSystem.makeDirectory(directory, { recursive: true }).pipe(Effect.orDie);
41
}
42
const settings = options.settings ?? DEFAULT_SERVER_SETTINGS;
43
+ const credentials = new Map<string, Uint8Array>();
44
return ProviderHost.ProviderHost.of({
45
paths: { cwd: options.cwd ?? process.cwd(), baseDir, stateDir, providerStatusCacheDir },
46
settings: {
@@ -49,6 +51,17 @@ export const layerTestProviderHost = (
51
shouldRunBackgroundWork: () => Effect.succeed(options.runBackgroundWork ?? true),
52
// Tests store attachments flat under the attachments directory by id.
53
resolveAttachmentPath: (attachment) => path.join(attachmentsDir, attachment.id),
54
+ // Credentials live in memory for the layer's lifetime.
55
+ credentials: (namespace, bindingId) =>
56
+ Effect.sync(() => {
57
+ const key = `${namespace}:${bindingId}`;
58
+ return {
59
+ binding: { owner: "t3" as const, key },
60
+ get: Effect.sync(() => Option.fromUndefinedOr(credentials.get(key))),
61
+ set: (value: Uint8Array) => Effect.sync(() => void credentials.set(key, value)),
62
+ remove: Effect.sync(() => void credentials.delete(key)),
63
+ };
64
+ }),
65
});
66
}),
67
);
pnpm-lock.yaml
+49
@@ -356,6 +356,9 @@ importers:
356
'@t3tools/provider-core':
357
specifier: workspace:*
358
version: link:../../packages/provider-core
359
+ '@t3tools/provider-cursor':
360
+ specifier: workspace:*
361
+ version: link:../../packages/provider-cursor
362
'@t3tools/provider-muse':
363
specifier: workspace:*
364
version: link:../../packages/provider-muse
@@ -600,6 +603,9 @@ importers:
603
'@t3tools/provider-core':
604
specifier: workspace:*
605
version: link:../../packages/provider-core
606
+ '@t3tools/provider-cursor':
607
+ specifier: workspace:*
608
+ version: link:../../packages/provider-cursor
609
'@t3tools/provider-muse':
610
specifier: workspace:*
611
version: link:../../packages/provider-muse
@@ -736,6 +742,9 @@ importers:
742
'@t3tools/provider-core':
743
specifier: workspace:*
744
version: link:../../packages/provider-core
745
+ '@t3tools/provider-cursor':
746
+ specifier: workspace:*
747
+ version: link:../../packages/provider-cursor
748
'@t3tools/provider-muse':
749
specifier: workspace:*
750
version: link:../../packages/provider-muse
@@ -1108,6 +1117,46 @@ importers:
1117
specifier: 1.0.0
1118
version: 1.0.0(@types/node@24.12.4)(@vitest/ui@5.0.1(vitest@5.0.1))(bufferutil@4.1.0)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1119
1120
+ packages/provider-cursor:
1121
+ dependencies:
1122
+ '@cursor/sdk':
1123
+ specifier: 1.0.35
1124
+ version: 1.0.35
1125
+ '@napi-rs/keyring':
1126
+ specifier: ^1.3.0
1127
+ version: 1.3.0
1128
+ '@t3tools/contracts':
1129
+ specifier: workspace:*
1130
+ version: link:../contracts
1131
+ '@t3tools/provider-core':
1132
+ specifier: workspace:*
1133
+ version: link:../provider-core
1134
+ '@t3tools/shared':
1135
+ specifier: workspace:*
1136
+ version: link:../shared
1137
+ effect:
1138
+ specifier: 4.0.1
1139
+ version: 4.0.1(patch_hash=a33cba07c41f32374c2aaa86ea4a84d3ab9a872a78c94b65e929b19f8361856f)
1140
+ yaml:
1141
+ specifier: ^2.9.0
1142
+ version: 2.9.0
1143
+ devDependencies:
1144
+ '@effect/platform-node':
1145
+ specifier: 4.0.1
1146
+ version: 4.0.1(bufferutil@4.1.0)(effect@4.0.1(patch_hash=a33cba07c41f32374c2aaa86ea4a84d3ab9a872a78c94b65e929b19f8361856f))(redis@6.2.1)(utf-8-validate@6.0.6)
1147
+ '@effect/vitest':
1148
+ specifier: 4.0.1
1149
+ version: 4.0.1(patch_hash=359f6fb2f7b3ec145bb72208edb9034f02489791aa2491a55cdbd69bd56ee0d2)(@types/node@24.12.4)(@vitest/ui@5.0.1)(bufferutil@4.1.0)(effect@4.0.1(patch_hash=a33cba07c41f32374c2aaa86ea4a84d3ab9a872a78c94b65e929b19f8361856f))(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1150
+ '@t3tools/provider-testing':
1151
+ specifier: workspace:*
1152
+ version: link:../provider-testing
1153
+ '@types/node':
1154
+ specifier: 24.12.4
1155
+ version: 24.12.4
1156
+ vite-plus:
1157
+ specifier: 1.0.0
1158
+ version: 1.0.0(@types/node@24.12.4)(@vitest/ui@5.0.1(vitest@5.0.1))(bufferutil@4.1.0)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(msw@2.12.11(@types/node@24.12.4)(typescript@7.0.2))(terser@5.48.0)(typescript@7.0.2)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)
1159
+
1160
packages/provider-muse:
1161
dependencies:
1162
'@muse-code/sdk':
scripts/lib/cursor-sdk-packaging.test.ts
+1
-1
@@ -79,7 +79,7 @@ it("loads packaged Cursor catalog chunks without credentials or checkout depende
79
entry,
80
`
81
import assert from 'node:assert/strict';
82
- import { Cursor } from ${JSON.stringify(NodePath.join(repoRoot, "apps/server/src/provider/cursorSdk.ts"))};
82
+ import { Cursor } from ${JSON.stringify(NodePath.join(repoRoot, "packages/provider-cursor/src/server/sdk.ts"))};
83
for (const [operation, request] of [
84
['Cursor.models.list', () => Cursor.models.list({ apiKey: '' })],
85
['Cursor.me', () => Cursor.me({ apiKey: '' })],
scripts/release-smoke.ts
+1
@@ -31,6 +31,7 @@ const workspaceFiles = [
31
"packages/provider-core/package.json",
32
"packages/provider-testing/package.json",
33
"packages/provider-pi/package.json",
34
+ "packages/provider-cursor/package.json",
35
"packages/provider-muse/package.json",
36
"packages/provider-opencode/package.json",
37
"packages/effect-acp/package.json",