Repository navigation
feat(usage): report usage and limits for the provider you actually run #33847
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
a17729a
61a5011
cbf1a55
c785bca
dc0eea3
628afe8
6257203
e78e004
33f7834
1e1d3fb
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 |
|---|---|---|
|
|
@@ -88,14 +88,42 @@ const layer = Layer.mergeAll( | |
| Layer.succeed(OpenCodeRuntime.OpenCodeRuntime, openCode2Runtime), | ||
| ).pipe(Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))); | ||
|
|
||
| const create = (config: Partial<OpenCodeSettings>, http: HttpClient.HttpClient, enabled = true) => | ||
| OpenCodeDriver.create({ | ||
| instanceId: ProviderInstanceId.make("opencode-test"), | ||
| displayName: undefined, | ||
| environment: [], | ||
| enabled, | ||
| config: { ...OpenCodeDriver.defaultConfig(), ...config }, | ||
| }).pipe(Effect.provideService(HttpClient.HttpClient, http)); | ||
| /** | ||
| * Keeps the provider from reading the developer's own OpenCode store: the | ||
| * quota probe would send those credentials to the provider's API. | ||
| */ | ||
| const sandboxStore = Effect.gen(function* () { | ||
| const fileSystem = yield* FileSystem.FileSystem; | ||
| const home = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-opencode-driver-home-" }); | ||
| return [ | ||
| { name: "HOME", value: home, sensitive: false }, | ||
| { name: "XDG_DATA_HOME", value: home, sensitive: false }, | ||
|
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. Override If the developer sets an absolute If that database contains an eligible MiniMax credential, the integration probe reads it and invokes the test HTTP client. Tests using Add an
|
||
| ]; | ||
| }); | ||
|
|
||
| const create = ( | ||
| config: Partial<OpenCodeSettings>, | ||
| http: HttpClient.HttpClient, | ||
| options: { | ||
| readonly enabled?: boolean; | ||
| readonly environment?: NodeJS.ProcessEnv; | ||
| } = {}, | ||
| ) => | ||
| Effect.gen(function* () { | ||
| const sandbox = yield* sandboxStore; | ||
| return yield* OpenCodeDriver.create({ | ||
| instanceId: ProviderInstanceId.make("opencode-test"), | ||
| displayName: undefined, | ||
| environment: [ | ||
| ...sandbox, | ||
| ...Object.entries(options.environment ?? {}).flatMap(([name, value]) => | ||
| value === undefined ? [] : [{ name, value, sensitive: false }], | ||
| ), | ||
| ], | ||
| enabled: options.enabled ?? true, | ||
| config: { ...OpenCodeDriver.defaultConfig(), ...config }, | ||
| }).pipe(Effect.provideService(HttpClient.HttpClient, http)); | ||
| }); | ||
|
|
||
| const noHttp = HttpClient.make(() => Effect.die("A local binary must not be probed over HTTP")); | ||
|
|
||
|
|
@@ -219,7 +247,7 @@ it.live("discovers models through a home-relative OpenCode wrapper", () => | |
| const instance = yield* OpenCodeDriver.create({ | ||
| instanceId: ProviderInstanceId.make("opencode-home"), | ||
| displayName: undefined, | ||
| environment: [], | ||
| environment: yield* sandboxStore, | ||
| enabled: true, | ||
| config: { | ||
| ...OpenCodeDriver.defaultConfig(), | ||
|
|
@@ -326,9 +354,9 @@ it.layer(layer)("OpenCodeDriver runtime selection", (it) => { | |
| return { stdout: "opencode v2.1.2\n", stderr: "", code: 0 }; | ||
| }), | ||
| } as OpenCodeRuntime.OpenCodeRuntime["Service"]; | ||
| const instance = yield* create({ serverUrl: "http://127.0.0.1:4096" }, noHttp, false).pipe( | ||
| Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, runtime), | ||
| ); | ||
| const instance = yield* create({ serverUrl: "http://127.0.0.1:4096" }, noHttp, { | ||
| enabled: false, | ||
| }).pipe(Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, runtime)); | ||
|
|
||
| const snapshot = yield* instance.snapshot.refresh; | ||
| assert.isFalse(snapshot.enabled); | ||
|
|
@@ -970,6 +998,7 @@ it.layer(layer)("OpenCodeDriver runtime selection", (it) => { | |
| instanceId: ProviderInstanceId.make("opencode-usage-recovery"), | ||
| displayName: undefined, | ||
| environment: [ | ||
| ...(yield* sandboxStore), | ||
| { | ||
| name: "OPENCODE_AUTH_CONTENT", | ||
| sensitive: true, | ||
|
|
@@ -1244,7 +1273,7 @@ it.layer(layerUpdate)("OpenCodeDriver updates", (it) => { | |
| const instance = yield* OpenCodeDriver.create({ | ||
| instanceId: ProviderInstanceId.make("opencode-update"), | ||
| displayName: undefined, | ||
| environment: [], | ||
| environment: yield* sandboxStore, | ||
| enabled: true, | ||
| config: { ...OpenCodeDriver.defaultConfig(), binaryPath }, | ||
| }).pipe(Effect.provideService(HttpClient.HttpClient, noHttp)); | ||
|
|
||
|
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. 🟠 High
Usage-recovery refreshes never retry 🤖 Copy this AI Prompt to have your agent fix this:
Author
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. Fixed: the provider reads the Console budget and the integration quotas through one probe, so the usage recovery that retries a failed read retries both.
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. Sorry, I'm unable to act on this request because you do not have permissions within this repository. |
Uh oh!
There was an error while loading. Please reload this page.