-
Notifications
You must be signed in to change notification settings - Fork 5.3k
feat(usage): read Cursor and Grok plan quota from their TUIs #9532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import { GrokSettings, ProviderDriverKind } from "@t3tools/contracts"; | ||
| import * as Crypto from "effect/Crypto"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Option from "effect/Option"; | ||
| import * as FileSystem from "effect/FileSystem"; | ||
| import * as Path from "effect/Path"; | ||
| import * as Schema from "effect/Schema"; | ||
|
|
@@ -9,6 +10,7 @@ import { ChildProcessSpawner } from "effect/unstable/process"; | |
|
|
||
| import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts"; | ||
| import { ServerConfig } from "../../config.ts"; | ||
| import * as PtyAdapter from "../../terminal/PtyAdapter.ts"; | ||
| import { ServerSettingsService } from "../../serverSettings.ts"; | ||
| import { makeGrokTextGeneration } from "../../textGeneration/GrokTextGeneration.ts"; | ||
| import { ProviderDriverError } from "../Errors.ts"; | ||
|
|
@@ -100,10 +102,15 @@ export const GrokDriver: ProviderDriver<GrokSettings, GrokDriverEnv> = { | |
| }); | ||
| const textGeneration = yield* makeGrokTextGeneration(effectiveConfig, processEnv); | ||
|
|
||
| // The usage probe drives the CLI's TUI, so it needs a PTY. The adapter | ||
| // is optional here: without it the probe reports limits unavailable. | ||
| const ptyAdapter = Option.getOrUndefined(yield* Effect.serviceOption(PtyAdapter.PtyAdapter)); | ||
| const checkProvider = checkGrokProviderStatus(effectiveConfig, processEnv, cwd).pipe( | ||
| Effect.map(stampIdentity), | ||
| Effect.provideService(Crypto.Crypto, crypto), | ||
| Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner), | ||
| (effect) => | ||
| ptyAdapter ? Effect.provideService(effect, PtyAdapter.PtyAdapter, ptyAdapter) : effect, | ||
|
Comment on lines
+107
to
+113
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same conditional-provide bypass as in Posted via Macroscope — Effect Service Conventions |
||
| ); | ||
|
|
||
| const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hand-rolls optional dependency plumbing around the layer boundary:
PtyAdapteris not part ofCursorDriverEnv, so the type system never requires it, and the ternaryprovideServiceis either redundant (a provided adapter is already visible to the probe'sserviceOptionthrough the inherited fiber context) or a silent no-op (nothing providesPtyAdapterto the driver layer today, so the probe always reports limits unavailable).Consider acquiring it as a normal dependency —
const ptyAdapter = yield* PtyAdapter.PtyAdapter;plus an unconditionalEffect.provideService(PtyAdapter.PtyAdapter, ptyAdapter)— and addingPtyAdapter.PtyAdapterto theCursorDriverEnvunion so the missing wiring becomes a type error instead of a runtime degradation.Posted via Macroscope — Effect Service Conventions