Require Cursor API key for provider checks
- Switch Cursor provider status and model discovery to the SDK catalog - Improve chat content lane alignment and provider secret handling
This commit is contained in:
1 parent
626a879b78
commit
29cd06590a
20 files changed
+632
-339
No files matched your search
@@ -30,7 +30,7 @@
|
||||
"@anthropic-ai/claude-agent-sdk": "^0.3.170",
|
||||
"@connectrpc/connect": "1.7.0",
|
||||
"@connectrpc/connect-node": "1.7.0",
|
||||
"@cursor/sdk": "1.0.19",
|
||||
"@cursor/sdk": "1.0.22",
|
||||
"@effect/platform-bun": "catalog:",
|
||||
"@effect/platform-node": "catalog:",
|
||||
"@effect/platform-node-shared": "catalog:",
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, describe, it } from "@effect/vitest";
|
||||
import { ProviderSessionId, ThreadId } from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import { vi } from "vite-plus/test";
|
||||
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import {
|
||||
CursorAgentSdkRunner,
|
||||
CursorAgentSdkRunnerError,
|
||||
cursorAgentSdkRunnerLiveLayer,
|
||||
} from "./CursorAgentSdk.ts";
|
||||
|
||||
const cursorSdkMock = vi.hoisted(() => {
|
||||
const runWait = vi.fn(async () => ({
|
||||
id: "run-cursor-agent-sdk-test",
|
||||
requestId: "request-cursor-agent-sdk-test",
|
||||
status: "finished",
|
||||
result: "ok",
|
||||
model: { id: "default" },
|
||||
durationMs: 1,
|
||||
}));
|
||||
const runCancel = vi.fn(async () => {});
|
||||
const agentClose = vi.fn(() => {});
|
||||
const send = vi.fn(
|
||||
async (
|
||||
_message: unknown,
|
||||
options: { readonly onDelta?: (input: { readonly update: unknown }) => Promise<void> },
|
||||
) => {
|
||||
await options.onDelta?.({
|
||||
update: {
|
||||
type: "assistant-message-chunk",
|
||||
text: "hello",
|
||||
},
|
||||
});
|
||||
return {
|
||||
id: "run-cursor-agent-sdk-test",
|
||||
agentId: "agent-cursor-agent-sdk-test",
|
||||
wait: runWait,
|
||||
cancel: runCancel,
|
||||
};
|
||||
},
|
||||
);
|
||||
const create = vi.fn(async () => ({
|
||||
agentId: "agent-cursor-agent-sdk-test",
|
||||
send,
|
||||
close: agentClose,
|
||||
}));
|
||||
|
||||
return {
|
||||
agentClose,
|
||||
create,
|
||||
runCancel,
|
||||
runWait,
|
||||
send,
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("@cursor/sdk", () => ({
|
||||
Agent: {
|
||||
create: cursorSdkMock.create,
|
||||
resume: vi.fn(),
|
||||
messages: {
|
||||
list: vi.fn(async () => []),
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const testLayer = cursorAgentSdkRunnerLiveLayer.pipe(
|
||||
Layer.provide(
|
||||
ServerConfig.layerTest(process.cwd(), {
|
||||
prefix: "t3-cursor-agent-sdk-runner-",
|
||||
}),
|
||||
),
|
||||
Layer.provide(NodeServices.layer),
|
||||
);
|
||||
|
||||
describe("CursorAgentSdkRunner", () => {
|
||||
it.effect("surfaces interaction callback failures through run.wait", () =>
|
||||
Effect.gen(function* () {
|
||||
cursorSdkMock.create.mockClear();
|
||||
cursorSdkMock.runWait.mockClear();
|
||||
cursorSdkMock.send.mockClear();
|
||||
|
||||
const runner = yield* CursorAgentSdkRunner;
|
||||
const session = yield* runner.open({
|
||||
operation: "create",
|
||||
options: {
|
||||
model: { id: "default" },
|
||||
mode: "agent",
|
||||
local: {
|
||||
cwd: process.cwd(),
|
||||
autoReview: false,
|
||||
sandboxOptions: { enabled: false },
|
||||
enableAgentRetries: true,
|
||||
},
|
||||
},
|
||||
threadId: ThreadId.make("thread-cursor-agent-sdk-test"),
|
||||
providerSessionId: ProviderSessionId.make("provider-session-cursor-agent-sdk-test"),
|
||||
});
|
||||
|
||||
const callbackFailure = new Error("delta callback failed");
|
||||
const run = yield* session.send({
|
||||
message: "hello",
|
||||
onDelta: () => Effect.fail(callbackFailure),
|
||||
});
|
||||
|
||||
const error = yield* Effect.flip(run.wait);
|
||||
|
||||
assert.instanceOf(error, CursorAgentSdkRunnerError);
|
||||
assert.equal(error.method, "run.wait");
|
||||
assert.strictEqual(error.cause, callbackFailure);
|
||||
assert.equal(cursorSdkMock.create.mock.calls.length, 1);
|
||||
assert.equal(cursorSdkMock.send.mock.calls.length, 1);
|
||||
assert.equal(cursorSdkMock.runWait.mock.calls.length, 1);
|
||||
}).pipe(Effect.provide(testLayer)),
|
||||
);
|
||||
});
|
||||
@@ -366,22 +366,30 @@ export const cursorAgentSdkRunnerLiveLayer: Layer.Layer<CursorAgentSdkRunner, ne
|
||||
|
||||
let callbacksReady = false;
|
||||
const pendingUpdates: Array<InteractionUpdate> = [];
|
||||
let callbackFailure: { readonly cause: unknown } | undefined;
|
||||
let callbackChain = Promise.resolve();
|
||||
let runId = "";
|
||||
const dispatchUpdate = (update: InteractionUpdate): Promise<void> => {
|
||||
callbackChain = callbackChain.then(() =>
|
||||
Effect.runPromiseWith(context)(
|
||||
log({
|
||||
direction: "incoming",
|
||||
stage: "decoded",
|
||||
payload: {
|
||||
type: "interaction.update",
|
||||
runId,
|
||||
update,
|
||||
},
|
||||
}).pipe(Effect.andThen(sendInput.onDelta?.(update) ?? Effect.void)),
|
||||
),
|
||||
);
|
||||
callbackChain = callbackChain
|
||||
.then(() => {
|
||||
if (callbackFailure !== undefined) {
|
||||
return;
|
||||
}
|
||||
return Effect.runPromiseWith(context)(
|
||||
log({
|
||||
direction: "incoming",
|
||||
stage: "decoded",
|
||||
payload: {
|
||||
type: "interaction.update",
|
||||
runId,
|
||||
update,
|
||||
},
|
||||
}).pipe(Effect.andThen(sendInput.onDelta?.(update) ?? Effect.void)),
|
||||
);
|
||||
})
|
||||
.catch((cause) => {
|
||||
callbackFailure ??= { cause };
|
||||
});
|
||||
return callbackChain;
|
||||
};
|
||||
|
||||
@@ -424,6 +432,9 @@ export const cursorAgentSdkRunnerLiveLayer: Layer.Layer<CursorAgentSdkRunner, ne
|
||||
try: async () => {
|
||||
const result = await run.wait();
|
||||
await callbackChain;
|
||||
if (callbackFailure !== undefined) {
|
||||
throw callbackFailure.cause;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
catch: (cause) => runnerError(cause, "run.wait"),
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/**
|
||||
* CursorDriver — `ProviderDriver` for the Cursor Agent (`cursor-agent`) runtime.
|
||||
* CursorDriver — `ProviderDriver` for the Cursor Agent SDK runtime.
|
||||
*
|
||||
* Provider status and model discovery use the official Cursor SDK when an API
|
||||
* key is configured. The ACP CLI remains the compatibility fallback for
|
||||
* installations that authenticate through the local Cursor binary.
|
||||
* Provider status, model discovery, and orchestration use the official Cursor
|
||||
* SDK and require CURSOR_API_KEY in the provider instance environment.
|
||||
*
|
||||
* Text generation is supported via the ACP runtime — `makeCursorTextGeneration`
|
||||
* drives `runtime.prompt` with a structured-output schema and collects the
|
||||
@@ -103,10 +102,6 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
|
||||
defaultConfig: (): CursorSettings => decodeCursorSettings({}),
|
||||
create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
|
||||
Effect.gen(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const httpClient = yield* HttpClient.HttpClient;
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
const processEnv = mergeProviderInstanceEnvironment(environment);
|
||||
@@ -149,9 +144,6 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
|
||||
const checkProvider = checkCursorProviderStatus(effectiveConfig, processEnv).pipe(
|
||||
Effect.map(stampIdentity),
|
||||
Effect.provide(CursorSdkCatalogLive),
|
||||
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
|
||||
Effect.provideService(FileSystem.FileSystem, fileSystem),
|
||||
Effect.provideService(Path.Path, path),
|
||||
);
|
||||
|
||||
const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);
|
||||
@@ -163,8 +155,8 @@ export const CursorDriver: ProviderDriver<CursorSettings, CursorDriverEnv> = {
|
||||
initialSnapshot: (settings) =>
|
||||
buildInitialCursorProviderSnapshot(settings.provider).pipe(Effect.map(stampIdentity)),
|
||||
checkProvider,
|
||||
// Model catalog and capabilities come exclusively from Cursor's
|
||||
// list_available_models extension method during provider checks.
|
||||
// Model catalog and capabilities come from Cursor's SDK catalog during
|
||||
// provider checks.
|
||||
enrichSnapshot: ({ settings, snapshot: currentSnapshot, publishSnapshot }) =>
|
||||
enrichCursorSnapshot({
|
||||
settings: settings.provider,
|
||||
|
||||
@@ -30,11 +30,46 @@ import {
|
||||
} from "./CursorProvider.ts";
|
||||
import { CursorSdkCatalogError, makeCursorSdkCatalogTestLayer } from "./CursorSdkCatalog.ts";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const mockAgentPath = path.join(__dirname, "../../../scripts/acp-mock-agent.ts");
|
||||
const resolveMockAgentPath = Effect.fn("resolveMockAgentPath")(function* () {
|
||||
const path = yield* Path.Path;
|
||||
return yield* path.fromFileUrl(new URL("../../../scripts/acp-mock-agent.ts", import.meta.url));
|
||||
});
|
||||
|
||||
async function makeMockAgentWrapper(extraEnv?: Record<string, string>) {
|
||||
const dir = await mkdtemp(path.join(os.tmpdir(), "cursor-provider-mock-"));
|
||||
function selectDescriptor(
|
||||
id: string,
|
||||
label: string,
|
||||
options: ReadonlyArray<{ id: string; label: string; isDefault?: boolean }>,
|
||||
) {
|
||||
return {
|
||||
id,
|
||||
label,
|
||||
type: "select" as const,
|
||||
options: [...options],
|
||||
...(options.find((option) => option.isDefault)?.id
|
||||
? { currentValue: options.find((option) => option.isDefault)?.id }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
function booleanDescriptor(id: string, label: string, currentValue?: boolean) {
|
||||
return {
|
||||
id,
|
||||
label,
|
||||
type: "boolean" as const,
|
||||
...(typeof currentValue === "boolean" ? { currentValue } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
const makeMockAgentWrapper = Effect.fn("makeMockAgentWrapper")(function* (
|
||||
extraEnv?: Record<string, string>,
|
||||
) {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const mockAgentPath = yield* resolveMockAgentPath();
|
||||
const dir = yield* fileSystem.makeTempDirectory({
|
||||
directory: NodeOS.tmpdir(),
|
||||
prefix: "cursor-provider-mock-",
|
||||
});
|
||||
const wrapperPath = path.join(dir, "fake-agent.sh");
|
||||
const envExports = Object.entries(extraEnv ?? {})
|
||||
.map(([key, value]) => `export ${key}=${JSON.stringify(value)}`)
|
||||
@@ -244,6 +279,13 @@ const baseCursorSettings: CursorSettings = {
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
};
|
||||
const cursorAcpDiscoveryFailedMessage = [
|
||||
"Cursor ACP model discovery failed.",
|
||||
"Cursor CLI setup may be incomplete; install or enable the Cursor CLI, restart T3 Code, and try again.",
|
||||
"See https://cursor.com/docs/cli/installation.",
|
||||
"Check server logs for ACP details.",
|
||||
].join(" ");
|
||||
const missingCursorBinaryPath = "/definitely/not/installed/t3-cursor-agent";
|
||||
|
||||
const sdkParameterizedModel = {
|
||||
id: "claude-opus-4-8",
|
||||
@@ -515,23 +557,14 @@ describe("checkCursorProviderStatus", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("passes the injected environment to ACP model discovery", async () => {
|
||||
const { requestLogPath, wrapperPath } = await runNode(makeProviderStatusEnvFixture());
|
||||
|
||||
const provider = await runNode(
|
||||
checkCursorProviderStatus(
|
||||
{
|
||||
enabled: true,
|
||||
binaryPath: wrapperPath,
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
},
|
||||
{
|
||||
...process.env,
|
||||
CURSOR_API_KEY: "",
|
||||
T3_ACP_REQUEST_LOG_PATH: requestLogPath,
|
||||
},
|
||||
).pipe(
|
||||
it("requires a Cursor API key without probing the legacy CLI fallback", async () => {
|
||||
const provider = await Effect.runPromise(
|
||||
checkCursorProviderStatus({
|
||||
enabled: true,
|
||||
binaryPath: missingCursorBinaryPath,
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
makeCursorSdkCatalogTestLayer(() =>
|
||||
@@ -543,17 +576,44 @@ describe("checkCursorProviderStatus", () => {
|
||||
),
|
||||
);
|
||||
|
||||
expect(provider.models.map((model) => model.slug)).toEqual([
|
||||
"default",
|
||||
"composer-2",
|
||||
"gpt-5.4",
|
||||
"claude-opus-4-6",
|
||||
]);
|
||||
await expect(runNode(waitForFileContent(requestLogPath))).resolves.toContain("initialize");
|
||||
expect(provider).toMatchObject({
|
||||
installed: true,
|
||||
status: "error",
|
||||
auth: { status: "unauthenticated" },
|
||||
message: "Cursor API key is required. Add CURSOR_API_KEY in provider settings.",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("discoverCursorModelsViaAcp", () => {
|
||||
it.effect("passes the injected environment to ACP model discovery", () =>
|
||||
Effect.gen(function* () {
|
||||
const { requestLogPath, wrapperPath } = yield* makeProviderStatusEnvFixture();
|
||||
const models = yield* discoverCursorModelsViaAcp(
|
||||
{
|
||||
enabled: true,
|
||||
binaryPath: wrapperPath,
|
||||
apiEndpoint: "",
|
||||
customModels: [],
|
||||
},
|
||||
{
|
||||
...process.env,
|
||||
T3_ACP_REQUEST_LOG_PATH: requestLogPath,
|
||||
},
|
||||
);
|
||||
|
||||
expect(models.map((model) => model.slug)).toEqual([
|
||||
"default",
|
||||
"composer-2",
|
||||
"gpt-5.4",
|
||||
"claude-opus-4-6",
|
||||
]);
|
||||
yield* waitForFileContent(requestLogPath).pipe(
|
||||
Effect.tap((content) => Effect.sync(() => expect(content).toContain("initialize"))),
|
||||
);
|
||||
}).pipe(Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
|
||||
it.effect("keeps the ACP probe runtime alive long enough to discover models", () =>
|
||||
Effect.gen(function* () {
|
||||
const wrapperPath = yield* makeMockAgentWrapper();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import * as NodeOs from "node:os";
|
||||
import type { SDKModel, SDKUser } from "@cursor/sdk";
|
||||
import type {
|
||||
CursorSettings,
|
||||
@@ -15,29 +14,22 @@ import { causeErrorTag } from "@t3tools/shared/observability";
|
||||
import * as Crypto from "effect/Crypto";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Result from "effect/Result";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { HttpClient } from "effect/unstable/http";
|
||||
import * as ChildProcess from "effect/unstable/process/ChildProcess";
|
||||
import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";
|
||||
import {
|
||||
createModelCapabilities,
|
||||
getProviderOptionBooleanSelectionValue,
|
||||
getProviderOptionStringSelectionValue,
|
||||
} from "@t3tools/shared/model";
|
||||
import { resolveSpawnCommand } from "@t3tools/shared/shell";
|
||||
|
||||
import {
|
||||
buildBooleanOptionDescriptor,
|
||||
buildSelectOptionDescriptor,
|
||||
buildServerProvider,
|
||||
collectStreamAsString,
|
||||
isCommandMissingCause,
|
||||
providerModelsFromSettings,
|
||||
type CommandResult,
|
||||
type ServerProviderDraft,
|
||||
@@ -63,16 +55,8 @@ const EMPTY_CAPABILITIES: ModelCapabilities = createModelCapabilities({
|
||||
optionDescriptors: [],
|
||||
});
|
||||
|
||||
const CURSOR_ACP_MODEL_DISCOVERY_TIMEOUT_MS = 15_000;
|
||||
const CURSOR_SDK_CATALOG_TIMEOUT_MS = 15_000;
|
||||
const CURSOR_PARAMETERIZED_MODEL_PICKER_MIN_VERSION_DATE = 2026_04_08;
|
||||
const CURSOR_CLI_INSTALLATION_DOCS_URL = "https://cursor.com/docs/cli/installation";
|
||||
const CURSOR_ACP_MODEL_DISCOVERY_FAILED_MESSAGE = [
|
||||
"Cursor ACP model discovery failed.",
|
||||
"Cursor CLI setup may be incomplete; install or enable the Cursor CLI, restart T3 Code, and try again.",
|
||||
`See ${CURSOR_CLI_INSTALLATION_DOCS_URL}.`,
|
||||
"Check server logs for ACP details.",
|
||||
].join(" ");
|
||||
export const CURSOR_PARAMETERIZED_MODEL_PICKER_CAPABILITIES = {
|
||||
_meta: {
|
||||
parameterizedModelPicker: true,
|
||||
@@ -688,9 +672,6 @@ export function getCursorFallbackModels(
|
||||
return providerModelsFromSettings([], cursorSettings.customModels, EMPTY_CAPABILITIES);
|
||||
}
|
||||
|
||||
/** Timeout for `agent about` — it's slower than a simple `--version` probe. */
|
||||
const ABOUT_TIMEOUT_MS = 8_000;
|
||||
|
||||
/** Strip ANSI escape sequences so we can parse plain key-value lines. */
|
||||
function stripAnsi(text: string): string {
|
||||
// eslint-disable-next-line no-control-regex
|
||||
@@ -725,14 +706,6 @@ function joinProviderMessages(...messages: ReadonlyArray<string | undefined>): s
|
||||
return parts.length > 0 ? parts.join(" ") : undefined;
|
||||
}
|
||||
|
||||
function buildCursorCliCommandMissingMessage(binaryPath: string): string {
|
||||
return [
|
||||
`Cursor CLI command \`${binaryPath}\` was not found.`,
|
||||
`Install or enable the Cursor CLI, make sure \`${binaryPath}\` is on PATH, then restart T3 Code.`,
|
||||
`See ${CURSOR_CLI_INSTALLATION_DOCS_URL}.`,
|
||||
].join(" ");
|
||||
}
|
||||
|
||||
export function buildCursorProviderSnapshot(input: {
|
||||
readonly checkedAt: string;
|
||||
readonly cursorSettings: CursorSettings;
|
||||
@@ -857,24 +830,6 @@ function hasOwn(record: object, key: string): boolean {
|
||||
return Object.prototype.hasOwnProperty.call(record, key);
|
||||
}
|
||||
|
||||
function isCursorAboutJsonFormatUnsupported(result: CommandResult): boolean {
|
||||
const lowerOutput = `${result.stdout}\n${result.stderr}`.toLowerCase();
|
||||
return (
|
||||
lowerOutput.includes("unknown option '--format'") ||
|
||||
lowerOutput.includes("unexpected argument '--format'") ||
|
||||
lowerOutput.includes("unrecognized option '--format'") ||
|
||||
lowerOutput.includes("unknown argument '--format'")
|
||||
);
|
||||
}
|
||||
|
||||
const readCursorCliConfigChannel = Effect.fn("readCursorCliConfigChannel")(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const configPath = path.join(NodeOS.homedir(), ".cursor", "cli-config.json");
|
||||
const raw = yield* fileSystem.readFileString(configPath).pipe(Effect.orElseSucceed(() => ""));
|
||||
return parseCursorCliConfigChannel(raw);
|
||||
});
|
||||
|
||||
export function getCursorParameterizedModelPickerUnsupportedMessage(input: {
|
||||
readonly version: string | null | undefined;
|
||||
readonly channel: string | null | undefined;
|
||||
@@ -1052,57 +1007,10 @@ export function parseCursorAboutOutput(result: CommandResult): CursorAboutResult
|
||||
};
|
||||
}
|
||||
|
||||
const runCursorCommand = (
|
||||
cursorSettings: CursorSettings,
|
||||
args: ReadonlyArray<string>,
|
||||
environment?: NodeJS.ProcessEnv,
|
||||
) =>
|
||||
Effect.gen(function* () {
|
||||
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const spawnCommand = yield* resolveSpawnCommand(
|
||||
cursorSettings.binaryPath,
|
||||
args,
|
||||
environment ? { env: environment } : {},
|
||||
);
|
||||
const command = ChildProcess.make(spawnCommand.command, spawnCommand.args, {
|
||||
...(environment ? { env: environment } : { extendEnv: true }),
|
||||
shell: spawnCommand.shell,
|
||||
});
|
||||
|
||||
const child = yield* spawner.spawn(command);
|
||||
const [stdout, stderr, exitCode] = yield* Effect.all(
|
||||
[
|
||||
collectStreamAsString(child.stdout),
|
||||
collectStreamAsString(child.stderr),
|
||||
child.exitCode.pipe(Effect.map(Number)),
|
||||
],
|
||||
{ concurrency: "unbounded" },
|
||||
);
|
||||
|
||||
return { stdout, stderr, code: exitCode } satisfies CommandResult;
|
||||
}).pipe(Effect.scoped);
|
||||
|
||||
const runCursorAboutCommand = (cursorSettings: CursorSettings, environment?: NodeJS.ProcessEnv) =>
|
||||
Effect.gen(function* () {
|
||||
const jsonResult = yield* runCursorCommand(
|
||||
cursorSettings,
|
||||
["about", "--format", "json"],
|
||||
environment,
|
||||
);
|
||||
if (!isCursorAboutJsonFormatUnsupported(jsonResult)) {
|
||||
return jsonResult;
|
||||
}
|
||||
return yield* runCursorCommand(cursorSettings, ["about"], environment);
|
||||
});
|
||||
|
||||
export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(function* (
|
||||
cursorSettings: CursorSettings,
|
||||
environment?: NodeJS.ProcessEnv,
|
||||
): Effect.fn.Return<
|
||||
ServerProviderDraft,
|
||||
never,
|
||||
ChildProcessSpawner.ChildProcessSpawner | CursorSdkCatalog | FileSystem.FileSystem | Path.Path
|
||||
> {
|
||||
): Effect.fn.Return<ServerProviderDraft, never, CursorSdkCatalog> {
|
||||
const checkedAt = DateTime.formatIso(yield* DateTime.now);
|
||||
const fallbackModels = getCursorFallbackModels(cursorSettings);
|
||||
|
||||
@@ -1184,105 +1092,18 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(
|
||||
});
|
||||
}
|
||||
|
||||
// Single `agent about` probe: returns version + auth status in one call.
|
||||
const aboutProbe = yield* runCursorAboutCommand(cursorSettings, environment).pipe(
|
||||
Effect.timeoutOption(ABOUT_TIMEOUT_MS),
|
||||
Effect.result,
|
||||
);
|
||||
|
||||
if (Result.isFailure(aboutProbe)) {
|
||||
const error = aboutProbe.failure;
|
||||
yield* Effect.logWarning("Cursor Agent CLI health check failed.", {
|
||||
errorTag: error._tag,
|
||||
});
|
||||
return buildServerProvider({
|
||||
presentation: CURSOR_PRESENTATION,
|
||||
enabled: cursorSettings.enabled,
|
||||
checkedAt,
|
||||
models: fallbackModels,
|
||||
probe: {
|
||||
installed: !isCommandMissingCause(error),
|
||||
version: null,
|
||||
status: "error",
|
||||
auth: { status: "unknown" },
|
||||
message: isCommandMissingCause(error)
|
||||
? buildCursorCliCommandMissingMessage(cursorSettings.binaryPath)
|
||||
: "Failed to execute Cursor Agent CLI health check.",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (Option.isNone(aboutProbe.success)) {
|
||||
return buildServerProvider({
|
||||
presentation: CURSOR_PRESENTATION,
|
||||
enabled: cursorSettings.enabled,
|
||||
checkedAt,
|
||||
models: fallbackModels,
|
||||
probe: {
|
||||
installed: true,
|
||||
version: null,
|
||||
status: "error",
|
||||
auth: { status: "unknown" },
|
||||
message: "Cursor Agent CLI is installed but timed out while running `agent about`.",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const parsed = parseCursorAboutOutput(aboutProbe.success.value);
|
||||
const cursorCliConfigChannel = yield* readCursorCliConfigChannel();
|
||||
const parameterizedModelPickerUnsupportedMessage =
|
||||
getCursorParameterizedModelPickerUnsupportedMessage({
|
||||
version: parsed.version,
|
||||
channel: cursorCliConfigChannel,
|
||||
});
|
||||
if (parameterizedModelPickerUnsupportedMessage) {
|
||||
return buildServerProvider({
|
||||
presentation: CURSOR_PRESENTATION,
|
||||
enabled: cursorSettings.enabled,
|
||||
checkedAt,
|
||||
models: fallbackModels,
|
||||
probe: {
|
||||
installed: true,
|
||||
version: parsed.version,
|
||||
status: "error",
|
||||
auth: parsed.auth,
|
||||
message:
|
||||
parsed.auth.status === "unauthenticated" && parsed.message
|
||||
? `${parameterizedModelPickerUnsupportedMessage} ${parsed.message}`
|
||||
: parameterizedModelPickerUnsupportedMessage,
|
||||
},
|
||||
});
|
||||
}
|
||||
let discoveredModels = Option.none<ReadonlyArray<ServerProviderModel>>();
|
||||
let discoveryWarning: string | undefined;
|
||||
if (parsed.auth.status !== "unauthenticated") {
|
||||
const discoveryExit = yield* Effect.exit(
|
||||
discoverCursorModelsViaAcp(cursorSettings, environment).pipe(
|
||||
Effect.timeoutOption(CURSOR_ACP_MODEL_DISCOVERY_TIMEOUT_MS),
|
||||
),
|
||||
);
|
||||
if (Exit.isFailure(discoveryExit)) {
|
||||
yield* Effect.logWarning("Cursor ACP model discovery failed", {
|
||||
errorTag: causeErrorTag(discoveryExit.cause),
|
||||
});
|
||||
discoveryWarning = CURSOR_ACP_MODEL_DISCOVERY_FAILED_MESSAGE;
|
||||
} else if (Option.isNone(discoveryExit.value)) {
|
||||
discoveryWarning = `Cursor ACP model discovery timed out after ${CURSOR_ACP_MODEL_DISCOVERY_TIMEOUT_MS}ms.`;
|
||||
} else if (discoveryExit.value.value.length === 0) {
|
||||
discoveryWarning = "Cursor ACP model discovery returned no built-in models.";
|
||||
} else {
|
||||
discoveredModels = discoveryExit.value;
|
||||
}
|
||||
}
|
||||
return buildCursorProviderSnapshot({
|
||||
return buildServerProvider({
|
||||
presentation: CURSOR_PRESENTATION,
|
||||
enabled: cursorSettings.enabled,
|
||||
checkedAt,
|
||||
cursorSettings,
|
||||
parsed,
|
||||
discoveredModels: Option.getOrElse(
|
||||
Option.filter(discoveredModels, (models) => models.length > 0),
|
||||
() => [] as const,
|
||||
),
|
||||
...(discoveryWarning ? { discoveryWarning } : {}),
|
||||
models: fallbackModels,
|
||||
probe: {
|
||||
installed: true,
|
||||
version: null,
|
||||
status: "error",
|
||||
auth: { status: "unauthenticated" },
|
||||
message: "Cursor API key is required. Add CURSOR_API_KEY in provider settings.",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1291,9 +1112,8 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(
|
||||
*
|
||||
* Used by `CursorDriver` as the `makeManagedServerProvider.enrichSnapshot`
|
||||
* hook: republishes update/version advisory metadata without performing any
|
||||
* model or capability discovery. Provider status checks source Cursor model
|
||||
* data from the SDK when an API key is configured, with ACP discovery as the
|
||||
* compatibility fallback.
|
||||
* model or capability discovery. Provider status and model data come from
|
||||
* the Cursor SDK catalog and require CURSOR_API_KEY.
|
||||
*/
|
||||
export const enrichCursorSnapshot = (input: {
|
||||
readonly settings: CursorSettings;
|
||||
|
||||
@@ -6456,7 +6456,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
ref={attachDraftHeroTransitionGroupRef}
|
||||
className="chat-composer-horizontal-inset w-full"
|
||||
>
|
||||
<div className="relative mx-auto h-full w-full max-w-208 overflow-clip rounded-t-[20px]">
|
||||
<div className="chat-content-lane relative h-full overflow-clip rounded-t-[20px]">
|
||||
<div className="chat-composer-shared-blur absolute -inset-8" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2680,7 +2680,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
<form
|
||||
ref={composerFormRef}
|
||||
onSubmit={submitComposer}
|
||||
className="mx-auto w-full min-w-0 max-w-3xl"
|
||||
className="chat-content-lane"
|
||||
data-chat-composer-form="true"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -98,7 +98,7 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={cn("group/banner-stack mx-auto mb-2 max-w-3xl", className)}>
|
||||
<div className={cn("group/banner-stack chat-content-lane mb-2", className)}>
|
||||
<div
|
||||
className={cn(
|
||||
"relative flex flex-col-reverse",
|
||||
|
||||
@@ -574,14 +574,16 @@ export const MessagesTimeline = memo(function MessagesTimeline({
|
||||
parentThreadLink === null ? (
|
||||
TIMELINE_LIST_HEADER
|
||||
) : (
|
||||
<div className="mx-auto w-full min-w-0 max-w-3xl pt-1 sm:pt-2">
|
||||
<TimelineSystemDivider
|
||||
label="Subagent of"
|
||||
detail={parentThreadLink.title}
|
||||
icon={BotIcon}
|
||||
actionLabel="Open parent thread"
|
||||
onAction={() => onOpenThread(parentThreadLink.threadId)}
|
||||
/>
|
||||
<div className="messages-timeline-row-frame">
|
||||
<div className="chat-content-lane pt-1 sm:pt-2">
|
||||
<TimelineSystemDivider
|
||||
label="Subagent of"
|
||||
detail={parentThreadLink.title}
|
||||
icon={BotIcon}
|
||||
actionLabel="Open parent thread"
|
||||
onAction={() => onOpenThread(parentThreadLink.threadId)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
[onOpenThread, parentThreadLink],
|
||||
@@ -591,8 +593,10 @@ export const MessagesTimeline = memo(function MessagesTimeline({
|
||||
// from TimelineRowCtx, which propagates through LegendList's memo.
|
||||
const renderItem = useCallback(
|
||||
({ item }: { item: MessagesTimelineRow }) => (
|
||||
<div className="mx-auto w-full min-w-0 max-w-3xl overflow-x-clip" data-timeline-root="true">
|
||||
<TimelineRowContent row={item} />
|
||||
<div className="messages-timeline-row-frame">
|
||||
<div className="chat-content-lane overflow-x-clip" data-timeline-root="true">
|
||||
<TimelineRowContent row={item} />
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
[],
|
||||
@@ -609,24 +613,50 @@ export const MessagesTimeline = memo(function MessagesTimeline({
|
||||
return (
|
||||
<TimelineRowCtx value={sharedState}>
|
||||
<TimelineRowActivityCtx value={activityState}>
|
||||
<LegendList<MessagesTimelineRow>
|
||||
ref={listRef}
|
||||
data={rows}
|
||||
keyExtractor={keyExtractor}
|
||||
getItemType={getItemType}
|
||||
renderItem={renderItem}
|
||||
estimatedItemSize={90}
|
||||
initialScrollAtEnd
|
||||
{...(anchoredEndSpace ? { anchoredEndSpace } : {})}
|
||||
contentInsetEndAdjustment={contentInsetEndAdjustment}
|
||||
maintainScrollAtEnd={!foldToggleSettling}
|
||||
maintainScrollAtEndThreshold={0.1}
|
||||
maintainVisibleContentPosition
|
||||
onScroll={handleScroll}
|
||||
className="messages-timeline-scroll scrollbar-gutter-both h-full min-h-0 overflow-x-hidden overscroll-y-contain"
|
||||
ListHeaderComponent={listHeader}
|
||||
ListFooterComponent={TIMELINE_LIST_FOOTER}
|
||||
/>
|
||||
<div ref={setTimelineViewportElement} className="relative h-full min-h-0">
|
||||
<LegendList<MessagesTimelineRow>
|
||||
ref={listRef}
|
||||
data={rows}
|
||||
keyExtractor={keyExtractor}
|
||||
getItemType={getItemType}
|
||||
renderItem={renderItem}
|
||||
estimatedItemSize={90}
|
||||
initialScrollAtEnd
|
||||
{...(anchoredEndSpace ? { anchoredEndSpace } : {})}
|
||||
contentInsetEndAdjustment={contentInsetEndAdjustment}
|
||||
maintainScrollAtEnd={
|
||||
anchoredEndSpace
|
||||
? false
|
||||
: {
|
||||
animated: false,
|
||||
on: {
|
||||
dataChange: true,
|
||||
itemLayout: true,
|
||||
layout: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
maintainVisibleContentPosition={maintainVisibleContentPosition}
|
||||
onScroll={handleScroll}
|
||||
className="messages-timeline-scroll scrollbar-gutter-both h-full min-h-0 overflow-x-hidden overscroll-y-contain [overflow-anchor:none]"
|
||||
ListHeaderComponent={listHeader}
|
||||
ListFooterComponent={TIMELINE_LIST_FOOTER}
|
||||
/>
|
||||
<TimelineMinimap
|
||||
items={minimapItems}
|
||||
bottomInset={contentInsetEndAdjustment}
|
||||
hasPersistentGutter={minimapHasPersistentGutter}
|
||||
stripMap={minimapStripMap}
|
||||
onSelect={(item) => {
|
||||
onManualNavigation();
|
||||
void listRef.current?.scrollToIndex({
|
||||
index: item.rowIndex,
|
||||
animated: true,
|
||||
viewOffset: 24,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</TimelineRowActivityCtx>
|
||||
</TimelineRowCtx>
|
||||
);
|
||||
|
||||
@@ -118,7 +118,7 @@ export const PanelLayoutControls = memo(function PanelLayoutControls({
|
||||
collisionAvoidance={{ side: "shift", align: "shift", fallbackAxisSide: "none" }}
|
||||
side="bottom"
|
||||
sideOffset={0}
|
||||
positionerClassName="w-[min(21rem,var(--anchor-width))] !transition-none"
|
||||
positionerClassName="w-[min(var(--thread-details-panel-width),var(--anchor-width))] !transition-none"
|
||||
className="w-full !overflow-visible rounded-none border-0 bg-transparent shadow-none before:hidden [--viewport-inline-padding:0]"
|
||||
viewportClassName="!overflow-visible p-2"
|
||||
>
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
import type { ServerProviderModel } from "@t3tools/contracts";
|
||||
|
||||
import { deriveProviderModelsForDisplay } from "./ProviderInstanceCard";
|
||||
import {
|
||||
deriveProviderModelsForDisplay,
|
||||
nextProviderEnvironmentWithFieldValue,
|
||||
providerEnvironmentWithoutNames,
|
||||
readProviderEnvironmentVariable,
|
||||
} from "./ProviderInstanceCard";
|
||||
|
||||
describe("deriveProviderModelsForDisplay", () => {
|
||||
it("uses current config custom models instead of stale live custom rows", () => {
|
||||
@@ -34,3 +39,55 @@ describe("deriveProviderModelsForDisplay", () => {
|
||||
).toEqual(["server-model", "kept-custom"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("provider environment helpers", () => {
|
||||
const cursorApiKeyField = {
|
||||
name: "CURSOR_API_KEY",
|
||||
label: "Cursor API key",
|
||||
sensitive: true,
|
||||
};
|
||||
|
||||
it("writes dedicated provider secrets as sensitive environment variables", () => {
|
||||
expect(
|
||||
nextProviderEnvironmentWithFieldValue(
|
||||
[{ name: "EXTRA_FLAG", value: "1", sensitive: false }],
|
||||
cursorApiKeyField,
|
||||
" cursor-key ",
|
||||
),
|
||||
).toEqual([
|
||||
{ name: "EXTRA_FLAG", value: "1", sensitive: false },
|
||||
{ name: "CURSOR_API_KEY", value: "cursor-key", sensitive: true },
|
||||
]);
|
||||
});
|
||||
|
||||
it("replaces redacted provider secrets without preserving redaction markers", () => {
|
||||
expect(
|
||||
nextProviderEnvironmentWithFieldValue(
|
||||
[
|
||||
{
|
||||
name: "CURSOR_API_KEY",
|
||||
value: "",
|
||||
sensitive: true,
|
||||
valueRedacted: true,
|
||||
},
|
||||
],
|
||||
cursorApiKeyField,
|
||||
"new-key",
|
||||
),
|
||||
).toEqual([{ name: "CURSOR_API_KEY", value: "new-key", sensitive: true }]);
|
||||
});
|
||||
|
||||
it("separates dedicated provider secrets from the generic environment table", () => {
|
||||
const environment = [
|
||||
{ name: "CURSOR_API_KEY", value: "cursor-key", sensitive: true },
|
||||
{ name: "EXTRA_FLAG", value: "1", sensitive: false },
|
||||
];
|
||||
|
||||
expect(readProviderEnvironmentVariable(environment, "CURSOR_API_KEY")?.value).toBe(
|
||||
"cursor-key",
|
||||
);
|
||||
expect(providerEnvironmentWithoutNames(environment, new Set(["CURSOR_API_KEY"]))).toEqual([
|
||||
{ name: "EXTRA_FLAG", value: "1", sensitive: false },
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -37,7 +37,7 @@ import { Switch } from "../ui/switch";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../ui/table";
|
||||
import { stackedThreadToast, toastManager } from "../ui/toast";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
import type { DriverOption } from "./providerDriverMeta";
|
||||
import type { DriverOption, ProviderEnvironmentFieldDefinition } from "./providerDriverMeta";
|
||||
import { ProviderSettingsForm } from "./ProviderSettingsForm";
|
||||
import { ProviderModelsSection } from "./ProviderModelsSection";
|
||||
import { ProviderInstanceIcon } from "../chat/ProviderInstanceIcon";
|
||||
@@ -109,6 +109,55 @@ function nextConfigBlobWithValue(
|
||||
return base;
|
||||
}
|
||||
|
||||
export function readProviderEnvironmentVariable(
|
||||
environment: ReadonlyArray<ProviderInstanceEnvironmentVariable> | undefined,
|
||||
name: string,
|
||||
): ProviderInstanceEnvironmentVariable | undefined {
|
||||
return environment?.find((variable) => variable.name === name);
|
||||
}
|
||||
|
||||
export function providerEnvironmentWithoutNames(
|
||||
environment: ReadonlyArray<ProviderInstanceEnvironmentVariable> | undefined,
|
||||
names: ReadonlySet<string>,
|
||||
): ReadonlyArray<ProviderInstanceEnvironmentVariable> {
|
||||
return (environment ?? []).filter((variable) => !names.has(variable.name));
|
||||
}
|
||||
|
||||
export function nextProviderEnvironmentWithFieldValue(
|
||||
environment: ReadonlyArray<ProviderInstanceEnvironmentVariable> | undefined,
|
||||
field: ProviderEnvironmentFieldDefinition,
|
||||
value: string,
|
||||
): ReadonlyArray<ProviderInstanceEnvironmentVariable> {
|
||||
const trimmed = value.trim();
|
||||
const next: ProviderInstanceEnvironmentVariable[] = [];
|
||||
let found = false;
|
||||
|
||||
for (const variable of environment ?? []) {
|
||||
if (variable.name !== field.name) {
|
||||
next.push(variable);
|
||||
continue;
|
||||
}
|
||||
found = true;
|
||||
if (trimmed.length > 0) {
|
||||
next.push({
|
||||
name: variable.name,
|
||||
value: trimmed,
|
||||
sensitive: field.sensitive ?? variable.sensitive,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && trimmed.length > 0) {
|
||||
next.push({
|
||||
name: field.name,
|
||||
value: trimmed,
|
||||
sensitive: field.sensitive ?? true,
|
||||
});
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
export function deriveProviderModelsForDisplay(input: {
|
||||
readonly liveModels: ReadonlyArray<ServerProviderModel> | undefined;
|
||||
readonly customModels: ReadonlyArray<string>;
|
||||
@@ -318,6 +367,53 @@ function ProviderEnvironmentSection(props: {
|
||||
);
|
||||
}
|
||||
|
||||
function ProviderEnvironmentFieldRow(props: {
|
||||
readonly field: ProviderEnvironmentFieldDefinition;
|
||||
readonly variable: ProviderInstanceEnvironmentVariable | undefined;
|
||||
readonly idPrefix: string;
|
||||
readonly onCommit: (field: ProviderEnvironmentFieldDefinition, value: string) => void;
|
||||
readonly onRemove: (field: ProviderEnvironmentFieldDefinition) => void;
|
||||
}) {
|
||||
const inputId = `${props.idPrefix}-environment-${props.field.name}`;
|
||||
const value = props.variable?.valueRedacted ? "" : (props.variable?.value ?? "");
|
||||
const placeholder = props.variable?.valueRedacted
|
||||
? "Stored secret - enter a new value to replace"
|
||||
: props.field.placeholder;
|
||||
|
||||
return (
|
||||
<label htmlFor={inputId} className="block">
|
||||
<span className="text-xs font-medium text-foreground">{props.field.label}</span>
|
||||
<div className="mt-1.5 flex min-w-0 items-center gap-2">
|
||||
<DraftInput
|
||||
id={inputId}
|
||||
className="min-w-0 flex-1"
|
||||
type={props.field.sensitive === false ? undefined : "password"}
|
||||
autoComplete="off"
|
||||
value={value}
|
||||
onCommit={(next) => props.onCommit(props.field, next)}
|
||||
placeholder={placeholder}
|
||||
spellCheck={false}
|
||||
/>
|
||||
{props.variable ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="icon-sm"
|
||||
variant="ghost"
|
||||
className="size-8 shrink-0 text-muted-foreground hover:text-destructive"
|
||||
onClick={() => props.onRemove(props.field)}
|
||||
aria-label={`Clear ${props.field.label}`}
|
||||
>
|
||||
<XIcon className="size-3.5" />
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
{props.field.description ? (
|
||||
<span className="mt-1 block text-xs text-muted-foreground">{props.field.description}</span>
|
||||
) : null}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
interface ProviderInstanceCardProps {
|
||||
readonly instanceId: ProviderInstanceId;
|
||||
readonly instance: ProviderInstanceConfig;
|
||||
@@ -444,6 +540,12 @@ export function ProviderInstanceCard({
|
||||
: null;
|
||||
|
||||
const customModels = readConfigStringArray(instance.config, "customModels");
|
||||
const environmentFields = driverOption?.environmentFields ?? [];
|
||||
const environmentFieldNames = new Set(environmentFields.map((field) => field.name));
|
||||
const genericEnvironment = providerEnvironmentWithoutNames(
|
||||
instance.environment,
|
||||
environmentFieldNames,
|
||||
);
|
||||
// Server-returned models may lag behind settings writes. Treat probe
|
||||
// models as the source for built-ins only; custom rows come directly
|
||||
// from the current instance config so add/remove reflects immediately.
|
||||
@@ -501,6 +603,23 @@ export function ProviderInstanceCard({
|
||||
);
|
||||
};
|
||||
|
||||
const updateGenericEnvironment = (
|
||||
environment: ReadonlyArray<ProviderInstanceEnvironmentVariable>,
|
||||
) => {
|
||||
const dedicatedEnvironment = (instance.environment ?? []).filter((variable) =>
|
||||
environmentFieldNames.has(variable.name),
|
||||
);
|
||||
updateEnvironment([...dedicatedEnvironment, ...environment]);
|
||||
};
|
||||
|
||||
const updateEnvironmentField = (field: ProviderEnvironmentFieldDefinition, value: string) => {
|
||||
updateEnvironment(nextProviderEnvironmentWithFieldValue(instance.environment, field, value));
|
||||
};
|
||||
|
||||
const removeEnvironmentField = (field: ProviderEnvironmentFieldDefinition) => {
|
||||
updateEnvironment(providerEnvironmentWithoutNames(instance.environment, new Set([field.name])));
|
||||
};
|
||||
|
||||
const titleIconNode = driverKind ? (
|
||||
<ProviderInstanceIcon
|
||||
driverKind={driverKind}
|
||||
@@ -757,10 +876,24 @@ export function ProviderInstanceCard({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className="border-t border-border/60 px-4 py-3 sm:px-5">
|
||||
{environmentFields.length > 0 ? (
|
||||
<div className="mb-4 grid gap-3">
|
||||
{environmentFields.map((field) => (
|
||||
<ProviderEnvironmentFieldRow
|
||||
key={field.name}
|
||||
field={field}
|
||||
variable={readProviderEnvironmentVariable(instance.environment, field.name)}
|
||||
idPrefix={`provider-instance-${instanceId}`}
|
||||
onCommit={updateEnvironmentField}
|
||||
onRemove={removeEnvironmentField}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
<ProviderEnvironmentSection
|
||||
environment={instance.environment ?? []}
|
||||
onChange={updateEnvironment}
|
||||
environment={genericEnvironment}
|
||||
onChange={updateGenericEnvironment}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -37,6 +37,22 @@ describe("ProviderSettingsForm helpers", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses a dedicated environment field instead of legacy Cursor CLI settings", () => {
|
||||
const cursor = DRIVER_OPTION_BY_VALUE[ProviderDriverKind.make("cursor")];
|
||||
|
||||
expect(cursor).toBeDefined();
|
||||
expect(deriveProviderSettingsFields(cursor!)).toEqual([]);
|
||||
expect(cursor?.environmentFields).toEqual([
|
||||
{
|
||||
name: "CURSOR_API_KEY",
|
||||
label: "Cursor API key",
|
||||
description: "Required by the Cursor Agent SDK.",
|
||||
placeholder: "Paste API key",
|
||||
sensitive: true,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("exposes ACP Registry as an instance-only configurable driver", () => {
|
||||
const acpRegistry = DRIVER_OPTION_BY_VALUE[ProviderDriverKind.make("acpRegistry")];
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ export interface ProviderClientDefinition {
|
||||
readonly label: string;
|
||||
readonly icon: Icon;
|
||||
readonly settingsSchema: ProviderSettingsSchema;
|
||||
readonly environmentFields?: readonly ProviderEnvironmentFieldDefinition[];
|
||||
/** Whether this driver has a built-in default instance backed by legacy settings. */
|
||||
readonly hasDefaultInstance?: boolean;
|
||||
/**
|
||||
@@ -45,6 +46,14 @@ export interface ProviderClientDefinition {
|
||||
readonly badgeLabel?: string;
|
||||
}
|
||||
|
||||
export interface ProviderEnvironmentFieldDefinition {
|
||||
readonly name: string;
|
||||
readonly label: string;
|
||||
readonly description?: string;
|
||||
readonly placeholder?: string;
|
||||
readonly sensitive?: boolean;
|
||||
}
|
||||
|
||||
export const PROVIDER_CLIENT_DEFINITIONS: readonly ProviderClientDefinition[] = [
|
||||
{
|
||||
value: ProviderDriverKind.make("codex"),
|
||||
@@ -64,6 +73,15 @@ export const PROVIDER_CLIENT_DEFINITIONS: readonly ProviderClientDefinition[] =
|
||||
icon: CursorIcon,
|
||||
badgeLabel: "Early Access",
|
||||
settingsSchema: CursorSettings,
|
||||
environmentFields: [
|
||||
{
|
||||
name: "CURSOR_API_KEY",
|
||||
label: "Cursor API key",
|
||||
description: "Required by the Cursor Agent SDK.",
|
||||
placeholder: "Paste API key",
|
||||
sensitive: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: ProviderDriverKind.make("grok"),
|
||||
|
||||
+11
-3
@@ -102,7 +102,8 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
--workspace-native-controls-inset: 0px;
|
||||
--workspace-titlebar-control-size: 1.75rem;
|
||||
--workspace-titlebar-control-gap: 0.75rem;
|
||||
--thread-details-panel-width: clamp(18rem, 24vw, 21rem);
|
||||
--chat-content-max-width: 46rem;
|
||||
--thread-details-panel-width: 19.5rem;
|
||||
--thread-details-panel-inset: 0px;
|
||||
}
|
||||
|
||||
@@ -642,11 +643,18 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
border-bottom-color: transparent;
|
||||
}
|
||||
|
||||
.chat-content-lane {
|
||||
margin-inline: auto;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: var(--chat-content-max-width);
|
||||
}
|
||||
|
||||
[data-thread-details-inline-reserved="true"] {
|
||||
--thread-details-panel-inset: var(--thread-details-panel-width);
|
||||
}
|
||||
|
||||
.messages-timeline-scroll {
|
||||
.messages-timeline-row-frame {
|
||||
padding-inline-start: 0.75rem;
|
||||
padding-inline-end: calc(0.75rem + var(--thread-details-panel-inset));
|
||||
}
|
||||
@@ -1043,7 +1051,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
--topbar-scroll-fade-height: 3rem;
|
||||
}
|
||||
|
||||
.messages-timeline-scroll {
|
||||
.messages-timeline-row-frame {
|
||||
padding-inline-start: 1.25rem;
|
||||
padding-inline-end: calc(1.25rem + var(--thread-details-panel-inset));
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import { resolveThreadPanelPresentation } from "./rightPanelLayout";
|
||||
describe("resolveThreadPanelPresentation", () => {
|
||||
it("uses the stable workspace width minus the real right panel width", () => {
|
||||
expect(resolveThreadPanelPresentation(null, 0, false)).toBe("inline");
|
||||
expect(resolveThreadPanelPresentation(960, 0, false)).toBe("inline");
|
||||
expect(resolveThreadPanelPresentation(959, 0, false)).toBe("popover");
|
||||
expect(resolveThreadPanelPresentation(1_104, 0, false)).toBe("inline");
|
||||
expect(resolveThreadPanelPresentation(1_103, 0, false)).toBe("popover");
|
||||
|
||||
expect(resolveThreadPanelPresentation(1_400, 0, false)).toBe("inline");
|
||||
expect(resolveThreadPanelPresentation(1_400, 540, false)).toBe("popover");
|
||||
expect(resolveThreadPanelPresentation(1_500, 540, false)).toBe("inline");
|
||||
expect(resolveThreadPanelPresentation(1_644, 540, false)).toBe("inline");
|
||||
});
|
||||
|
||||
it("uses a popover while the real right panel is maximized", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export const RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY = "(max-width: 980px)";
|
||||
export const THREAD_PANEL_INLINE_MIN_WIDTH = 960;
|
||||
export const THREAD_PANEL_INLINE_MIN_WIDTH = 1_104;
|
||||
export const RIGHT_PANEL_SHEET_CLASS_NAME =
|
||||
"w-[min(42vw,28rem)] min-w-80 max-w-[28rem] p-0 max-[760px]:w-[min(88vw,24rem)] max-[760px]:min-w-0 wco:mt-[env(titlebar-area-height)] wco:h-[calc(100%-env(titlebar-area-height))] wco:max-h-[calc(100%-env(titlebar-area-height))]";
|
||||
|
||||
|
||||
@@ -363,12 +363,40 @@ export const ClaudeSettings = makeProviderSettingsSchema(
|
||||
);
|
||||
export type ClaudeSettings = typeof ClaudeSettings.Type;
|
||||
|
||||
export const CursorSettings = Schema.Struct({
|
||||
enabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
binaryPath: makeBinaryPathSetting("agent"),
|
||||
apiEndpoint: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
|
||||
customModels: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
|
||||
});
|
||||
export const CursorSettings = makeProviderSettingsSchema(
|
||||
{
|
||||
enabled: Schema.Boolean.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(false)),
|
||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
||||
),
|
||||
binaryPath: makeBinaryPathSetting("agent").pipe(
|
||||
Schema.annotateKey({
|
||||
title: "Binary path",
|
||||
description: "Legacy Cursor Agent CLI path.",
|
||||
providerSettingsForm: { hidden: true, placeholder: "agent", clearWhenEmpty: "omit" },
|
||||
}),
|
||||
),
|
||||
apiEndpoint: TrimmedString.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed("")),
|
||||
Schema.annotateKey({
|
||||
title: "API endpoint",
|
||||
description: "Legacy Cursor Agent CLI API endpoint override.",
|
||||
providerSettingsForm: {
|
||||
hidden: true,
|
||||
placeholder: "https://...",
|
||||
clearWhenEmpty: "omit",
|
||||
},
|
||||
}),
|
||||
),
|
||||
customModels: Schema.Array(Schema.String).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed([])),
|
||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
||||
),
|
||||
},
|
||||
{
|
||||
order: [],
|
||||
},
|
||||
);
|
||||
export type CursorSettings = typeof CursorSettings.Type;
|
||||
|
||||
export const GrokSettings = makeProviderSettingsSchema(
|
||||
|
||||
Generated
+41
-40
Reference in new issue
Block a user