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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions apps/server/src/mcp/WorktreeMcpService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ const expectTypedFailure = (exit: Exit.Exit<unknown, unknown>, expected: object)

// Resolve once so calls share the in-flight guard.
const resolveService = (harness: ReturnType<typeof makeHarness>) =>
Effect.gen(function* () {
return yield* WorktreeMcpService.WorktreeMcpService;
}).pipe(Effect.provide(harness.layer));
WorktreeMcpService.WorktreeMcpService.pipe(Effect.provide(harness.layer));

const runHandoff = (
harness: ReturnType<typeof makeHarness>,
Expand Down
20 changes: 8 additions & 12 deletions packages/provider-acp/src/server/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5339,12 +5339,10 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
Effect.ensuring(
runRuntimeCallbackAtGeneration(
generation,
Effect.gen(function* () {
yield* Ref.update(pendingRuntimeRequests, (current) => {
const updated = new Map(current);
updated.delete(String(requestId));
return updated;
});
Ref.update(pendingRuntimeRequests, (current) => {
const updated = new Map(current);
updated.delete(String(requestId));
return updated;
}),
).pipe(Effect.asVoid),
),
Expand Down Expand Up @@ -6032,12 +6030,10 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
Effect.ensuring(
runRuntimeCallbackAtGeneration(
handlerGeneration,
Effect.gen(function* () {
yield* Ref.update(pendingRuntimeRequests, (current) => {
const updated = new Map(current);
updated.delete(String(requestId));
return updated;
});
Ref.update(pendingRuntimeRequests, (current) => {
const updated = new Map(current);
updated.delete(String(requestId));
return updated;
}),
).pipe(Effect.asVoid),
),
Expand Down
80 changes: 39 additions & 41 deletions packages/provider-cursor/src/server/usageLimits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,49 +71,47 @@ describe("Cursor usage limits", () => {
});

it.effect("reads the instance's credentials and endpoint even when usage enabled is false", () =>
Effect.gen(function* () {
yield* withNodeServices(
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const directory = yield* fs.makeTempDirectoryScoped();
yield* fs.makeDirectory(path.join(directory, "cursor"));
yield* fs.writeFileString(
path.join(directory, "cursor", "auth.json"),
'{"accessToken":"instance-token"}',
withNodeServices(
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const directory = yield* fs.makeTempDirectoryScoped();
yield* fs.makeDirectory(path.join(directory, "cursor"));
yield* fs.writeFileString(
path.join(directory, "cursor", "auth.json"),
'{"accessToken":"instance-token"}',
);
const client = HttpClient.make((request) => {
expect(request.url).toBe(
"https://cursor.example/aiserver.v1.DashboardService/GetCurrentPeriodUsage",
);
const client = HttpClient.make((request) => {
expect(request.url).toBe(
"https://cursor.example/aiserver.v1.DashboardService/GetCurrentPeriodUsage",
);
expect(request.method).toBe("POST");
expect(request.headers.authorization).toBe("Bearer instance-token");
expect(request.headers["connect-protocol-version"]).toBe("1");
return Effect.succeed(
HttpClientResponse.fromWeb(
request,
Response.json({ enabled: false, planUsage: { totalPercentUsed: 42 } }),
),
);
});
yield* fs.makeDirectory(path.join(directory, ".cursor"));
yield* fs.writeFileString(
path.join(directory, ".cursor", "auth.json"),
'{"accessToken":"instance-token"}',
expect(request.method).toBe("POST");
expect(request.headers.authorization).toBe("Bearer instance-token");
expect(request.headers["connect-protocol-version"]).toBe("1");
return Effect.succeed(
HttpClientResponse.fromWeb(
request,
Response.json({ enabled: false, planUsage: { totalPercentUsed: 42 } }),
),
);
for (const platform of ["linux", "darwin"] as const) {
const limits = yield* readCursorUsageLimits(
{ apiEndpoint: "https://cursor.example/" },
{ XDG_CONFIG_HOME: directory, HOME: directory, AGENT_CLI_CREDENTIAL_STORE: "file" },
).pipe(
Effect.provideService(HostProcess.Platform, platform),
Effect.provideService(HttpClient.HttpClient, client),
);
expect(limits.windows[0]?.usedPercent).toBe(42);
}
}).pipe(Effect.scoped),
);
}),
});
yield* fs.makeDirectory(path.join(directory, ".cursor"));
yield* fs.writeFileString(
path.join(directory, ".cursor", "auth.json"),
'{"accessToken":"instance-token"}',
);
for (const platform of ["linux", "darwin"] as const) {
const limits = yield* readCursorUsageLimits(
{ apiEndpoint: "https://cursor.example/" },
{ XDG_CONFIG_HOME: directory, HOME: directory, AGENT_CLI_CREDENTIAL_STORE: "file" },
).pipe(
Effect.provideService(HostProcess.Platform, platform),
Effect.provideService(HttpClient.HttpClient, client),
);
expect(limits.windows[0]?.usedPercent).toBe(42);
}
}).pipe(Effect.scoped),
),
);

it.effect(
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"namespaceImportPackages": ["@effect/platform-node", "effect"],
"effectFn": ["span", "inferred-span", "suggested-span"],
"diagnosticSeverity": {
"unnecessaryEffectGen": "error",
"allOfMapToForEach": "error",
"catchToOrElseSucceed": "error",
"unnecessaryFailYieldableError": "error",
Expand Down
Loading