forked from pingdotgg/t3code
-
Notifications
You must be signed in to change notification settings - Fork 0
fix(provider): harden Antigravity adapter (#653/#696–#701) #3
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
76b1594
feat(server): add Antigravity CLI provider protocol spike
anonb3ll e0d8e9a
feat(provider): add Antigravity (agy) production provider adapter
anonb3ll a8461d4
Merge branch 'task-653-antigravity-provider'
anonb3ll 1423995
fix(provider): harden Antigravity adapter for production follow-ups
anonb3ll 8fd34ea
test(provider): update ProviderRegistry expectations for Antigravity
anonb3ll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| import { AntigravitySettings, ProviderDriverKind, type ServerProvider } from "@t3tools/contracts"; | ||
| import * as Crypto from "effect/Crypto"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as FileSystem from "effect/FileSystem"; | ||
| import * as Path from "effect/Path"; | ||
| import * as Schema from "effect/Schema"; | ||
| import * as Scope from "effect/Scope"; | ||
| import { HttpClient } from "effect/unstable/http"; | ||
| import { ChildProcessSpawner } from "effect/unstable/process"; | ||
|
|
||
| import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts"; | ||
| import { ServerConfig } from "../../config.ts"; | ||
| import { ServerSettingsService } from "../../serverSettings.ts"; | ||
| import { ProviderDriverError } from "../Errors.ts"; | ||
| import { makeAntigravityAdapter } from "../Layers/AntigravityAdapter.ts"; | ||
| import { | ||
| buildInitialAntigravityProviderSnapshot, | ||
| checkAntigravityProviderStatus, | ||
| } from "../Layers/AntigravityProvider.ts"; | ||
| import { ProviderEventLoggers } from "../Layers/ProviderEventLoggers.ts"; | ||
| import { makeManagedServerProvider } from "../makeManagedServerProvider.ts"; | ||
| import { | ||
| defaultProviderContinuationIdentity, | ||
| type ProviderDriver, | ||
| type ProviderInstance, | ||
| } from "../ProviderDriver.ts"; | ||
| import type { ServerProviderDraft } from "../providerSnapshot.ts"; | ||
| import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment.ts"; | ||
| import { | ||
| makeManualOnlyProviderMaintenanceCapabilities, | ||
| makeStaticProviderMaintenanceResolver, | ||
| resolveProviderMaintenanceCapabilitiesEffect, | ||
| } from "../providerMaintenance.ts"; | ||
| import { | ||
| haveProviderSnapshotSettingsChanged, | ||
| makeProviderSnapshotSettingsSource, | ||
| type ProviderSnapshotSettings, | ||
| } from "../providerUpdateSettings.ts"; | ||
|
|
||
| const decodeAntigravitySettings = Schema.decodeSync(AntigravitySettings); | ||
|
|
||
| const DRIVER_KIND = ProviderDriverKind.make("antigravity"); | ||
| const UPDATE = makeStaticProviderMaintenanceResolver( | ||
| makeManualOnlyProviderMaintenanceCapabilities({ | ||
| provider: DRIVER_KIND, | ||
| packageName: null, | ||
| }), | ||
| ); | ||
|
|
||
| export type AntigravityDriverEnv = | ||
| | BackgroundPolicy.BackgroundPolicy | ||
| | ChildProcessSpawner.ChildProcessSpawner | ||
| | Crypto.Crypto | ||
| | FileSystem.FileSystem | ||
| | HttpClient.HttpClient | ||
| | Path.Path | ||
| | ProviderEventLoggers | ||
| | ServerConfig | ||
| | ServerSettingsService | ||
| | Scope.Scope; | ||
|
|
||
| const withInstanceIdentity = | ||
| (input: { | ||
| readonly instanceId: ProviderInstance["instanceId"]; | ||
| readonly displayName: string | undefined; | ||
| readonly accentColor: string | undefined; | ||
| readonly continuationGroupKey: string; | ||
| }) => | ||
| (snapshot: ServerProviderDraft): ServerProvider => ({ | ||
| ...snapshot, | ||
| instanceId: input.instanceId, | ||
| driver: DRIVER_KIND, | ||
| ...(input.displayName ? { displayName: input.displayName } : {}), | ||
| ...(input.accentColor ? { accentColor: input.accentColor } : {}), | ||
| continuation: { groupKey: input.continuationGroupKey }, | ||
| }); | ||
|
|
||
| export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityDriverEnv> = { | ||
| driverKind: DRIVER_KIND, | ||
| metadata: { | ||
| displayName: "Antigravity", | ||
| supportsMultipleInstances: true, | ||
| }, | ||
| configSchema: AntigravitySettings, | ||
| defaultConfig: (): AntigravitySettings => decodeAntigravitySettings({}), | ||
| create: ({ instanceId, displayName, accentColor, environment, enabled, config }) => | ||
| Effect.gen(function* () { | ||
| const crypto = yield* Crypto.Crypto; | ||
| const spawner = yield* ChildProcessSpawner.ChildProcessSpawner; | ||
| const serverSettings = yield* ServerSettingsService; | ||
| const processEnv = mergeProviderInstanceEnvironment(environment); | ||
| const continuationIdentity = defaultProviderContinuationIdentity({ | ||
| driverKind: DRIVER_KIND, | ||
| instanceId, | ||
| }); | ||
| const stampIdentity = withInstanceIdentity({ | ||
| instanceId, | ||
| displayName, | ||
| accentColor, | ||
| continuationGroupKey: continuationIdentity.continuationKey, | ||
| }); | ||
| const effectiveConfig = { ...config, enabled } satisfies AntigravitySettings; | ||
| const maintenanceCapabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(UPDATE, { | ||
| binaryPath: effectiveConfig.binaryPath, | ||
| env: processEnv, | ||
| }); | ||
|
|
||
| const adapter = yield* makeAntigravityAdapter(effectiveConfig, { | ||
| environment: processEnv, | ||
| instanceId, | ||
| }); | ||
|
|
||
| const checkProvider = checkAntigravityProviderStatus(effectiveConfig, processEnv).pipe( | ||
| Effect.map(stampIdentity), | ||
| Effect.provideService(Crypto.Crypto, crypto), | ||
| Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner), | ||
| ); | ||
|
|
||
| const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings); | ||
| const snapshot = yield* makeManagedServerProvider< | ||
| ProviderSnapshotSettings<AntigravitySettings> | ||
| >({ | ||
| maintenanceCapabilities, | ||
| getSettings: snapshotSettings.getSettings, | ||
| streamSettings: snapshotSettings.streamSettings, | ||
| haveSettingsChanged: haveProviderSnapshotSettingsChanged, | ||
| initialSnapshot: (settings) => | ||
| buildInitialAntigravityProviderSnapshot(settings.provider).pipe( | ||
| Effect.map(stampIdentity), | ||
| ), | ||
| checkProvider, | ||
| }).pipe( | ||
| Effect.mapError( | ||
| (cause) => | ||
| new ProviderDriverError({ | ||
| driver: DRIVER_KIND, | ||
| instanceId, | ||
| detail: `Failed to build Antigravity snapshot: ${cause.message ?? String(cause)}`, | ||
| cause, | ||
| }), | ||
| ), | ||
| ); | ||
|
|
||
| return { | ||
| instanceId, | ||
| driverKind: DRIVER_KIND, | ||
| continuationIdentity, | ||
| displayName, | ||
| accentColor, | ||
| enabled, | ||
| snapshot, | ||
| adapter, | ||
| } satisfies ProviderInstance; | ||
| }), | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Return the required
textGenerationservice.ProviderInstancerequirestextGeneration, but this object omits it. Thesatisfies ProviderInstancecheck fails compilation. Add the service to the returned instance.🤖 Prompt for AI Agents