Repository navigation
feat(provider): add Antigravity (Google AGY) provider integration & ACP bridge #4578
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
76f12ef
feat(provider): add Antigravity (Google AGY) provider integration & A…
umarfaruq0z 16bfba3
fix(provider): address PR feedback for Antigravity integration
umarfaruq0z 39f2218
fix(provider): address bots feedback for Antigravity integration
umarfaruq0z bc83db2
Update apps/server/src/provider/Layers/AntigravityProvider.ts
umarfaruq0z 93a0230
Update apps/server/src/provider/Layers/AntigravityProvider.ts
umarfaruq0z 8760a0f
fix(provider): address further bot feedback
umarfaruq0z b96462a
feat(provider): merge agentool PR #4497 bridge architecture with new …
umarfaruq0z bcbd5f6
fix(provider): resolve block structure in AntigravityProvider
umarfaruq0z 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
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
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
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,31 @@ | ||
| /** | ||
| * Hidden CLI entry points for the Antigravity ACP bridge. | ||
| * | ||
| * Both are internal plumbing rather than user-facing commands: the provider | ||
| * spawns `t3 agy-acp` as an ACP agent, and that bridge registers `t3 agy-hook | ||
| * <event>` as Antigravity's tool-lifecycle hook. Shipping them as subcommands | ||
| * of the server binary keeps the bridge inside the same bundle. | ||
| * | ||
| * @module cli/agy | ||
| */ | ||
| import * as Effect from "effect/Effect"; | ||
| import { Command, Flag } from "effect/unstable/cli"; | ||
|
|
||
| import { runAgyBridge, runAgyHook } from "../provider/acp/antigravity/agyBridge.ts"; | ||
|
|
||
| export const agyAcpCommand = Command.make("agy-acp").pipe( | ||
| Command.withDescription("Run the Antigravity ACP compatibility bridge over stdio."), | ||
| Command.withHidden, | ||
| Command.withHandler(() => Effect.promise(() => runAgyBridge())), | ||
| ); | ||
|
|
||
| export const agyHookCommand = Command.make("agy-hook", { | ||
| event: Flag.string("event").pipe( | ||
| Flag.withDescription("Antigravity hook event name."), | ||
| Flag.withDefault("unknown"), | ||
| ), | ||
| }).pipe( | ||
| Command.withDescription("Handle one Antigravity tool-lifecycle hook event."), | ||
| Command.withHidden, | ||
| Command.withHandler(({ event }) => Effect.promise(() => runAgyHook(event))), | ||
| ); |
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,177 @@ | ||
| /** | ||
| * AntigravityDriver — built-in driver for the Antigravity CLI (`agy`). | ||
| * | ||
| * Sessions run through T3 Code's bundled ACP bridge rather than a native agent | ||
| * protocol; see `provider/acp/antigravity/agyBridge.ts`. | ||
| * | ||
| * @module Drivers/AntigravityDriver | ||
| */ | ||
| import { AntigravitySettings, ProviderDriverKind, type ServerProvider } from "@t3tools/contracts"; | ||
| import * as Duration from "effect/Duration"; | ||
| 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 { HttpClient } from "effect/unstable/http"; | ||
| import { ChildProcessSpawner } from "effect/unstable/process"; | ||
|
|
||
| import { ServerConfig } from "../../config.ts"; | ||
| import { ServerSettingsService } from "../../serverSettings.ts"; | ||
| import { makeAntigravityTextGeneration } from "../../textGeneration/AntigravityTextGeneration.ts"; | ||
| import { ProviderDriverError } from "../Errors.ts"; | ||
| import { makeAntigravityAdapter } from "../Layers/AntigravityAdapter.ts"; | ||
| import { | ||
| buildInitialAntigravityProviderSnapshot, | ||
| checkAntigravityProviderStatus, | ||
| enrichAntigravitySnapshot, | ||
| } 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 SNAPSHOT_REFRESH_INTERVAL = Duration.minutes(5); | ||
| // Antigravity ships its own installer and updater (`agy update`), so T3 Code | ||
| // never manages the binary itself. | ||
| const UPDATE = makeStaticProviderMaintenanceResolver( | ||
| makeManualOnlyProviderMaintenanceCapabilities({ | ||
| provider: DRIVER_KIND, | ||
| packageName: null, | ||
| }), | ||
| ); | ||
|
|
||
| export type AntigravityDriverEnv = | ||
| | ChildProcessSpawner.ChildProcessSpawner | ||
| | Crypto.Crypto | ||
| | FileSystem.FileSystem | ||
| | HttpClient.HttpClient | ||
| | Path.Path | ||
| | ProviderEventLoggers | ||
| | ServerConfig | ||
| | ServerSettingsService; | ||
|
|
||
| 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 spawner = yield* ChildProcessSpawner.ChildProcessSpawner; | ||
| const httpClient = yield* HttpClient.HttpClient; | ||
| const serverSettings = yield* ServerSettingsService; | ||
| const eventLoggers = yield* ProviderEventLoggers; | ||
| 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, | ||
| ...(eventLoggers.native ? { nativeEventLogger: eventLoggers.native } : {}), | ||
| instanceId, | ||
| }); | ||
| const textGeneration = yield* makeAntigravityTextGeneration(effectiveConfig, processEnv); | ||
|
|
||
| const checkProvider = checkAntigravityProviderStatus(effectiveConfig, processEnv).pipe( | ||
| Effect.map(stampIdentity), | ||
| 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, | ||
| enrichSnapshot: ({ settings, snapshot: currentSnapshot, publishSnapshot }) => | ||
| enrichAntigravitySnapshot({ | ||
| snapshot: currentSnapshot, | ||
| maintenanceCapabilities, | ||
| enableProviderUpdateChecks: settings.enableProviderUpdateChecks, | ||
| publishSnapshot, | ||
| httpClient, | ||
| }), | ||
| refreshInterval: SNAPSHOT_REFRESH_INTERVAL, | ||
| }).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, | ||
| textGeneration, | ||
| } satisfies ProviderInstance; | ||
| }), | ||
| }; | ||
74 changes: 74 additions & 0 deletions
74
apps/server/src/provider/Layers/AntigravityAdapter.test.ts
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,74 @@ | ||
| import * as NodeServices from "@effect/platform-node/NodeServices"; | ||
| import { assert, it } from "@effect/vitest"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Layer from "effect/Layer"; | ||
| import * as Schema from "effect/Schema"; | ||
|
|
||
| import { | ||
| ApprovalRequestId, | ||
| AntigravitySettings, | ||
| ProviderDriverKind, | ||
| ThreadId, | ||
| } from "@t3tools/contracts"; | ||
|
|
||
| import * as ServerConfig from "../../config.ts"; | ||
| import { makeAntigravityAdapter } from "./AntigravityAdapter.ts"; | ||
|
|
||
| const decodeAntigravitySettings = Schema.decodeSync(AntigravitySettings); | ||
|
|
||
| const antigravityAdapterTestLayer = ServerConfig.ServerConfig.layerTest(process.cwd(), { | ||
| prefix: "t3code-agy-adapter-test-", | ||
| }).pipe(Layer.provideMerge(NodeServices.layer)); | ||
|
|
||
| it.layer(antigravityAdapterTestLayer)("AntigravityAdapterLive", (it) => { | ||
| it.effect("declares sessionModelSwitch as in-session in capabilities", () => | ||
| Effect.gen(function* () { | ||
| const adapter = yield* makeAntigravityAdapter(decodeAntigravitySettings({})); | ||
| assert.equal(adapter.capabilities.sessionModelSwitch, "in-session"); | ||
| assert.equal(adapter.provider, ProviderDriverKind.make("antigravity")); | ||
| }), | ||
| ); | ||
|
|
||
| it.effect( | ||
| "returns ProviderAdapterSessionNotFoundError for respondToRequest on unknown thread", | ||
| () => | ||
| Effect.gen(function* () { | ||
| const adapter = yield* makeAntigravityAdapter(decodeAntigravitySettings({})); | ||
| const threadId = ThreadId.make("agy-nonexistent-thread"); | ||
|
|
||
| const error = yield* Effect.flip( | ||
| adapter.respondToRequest(threadId, ApprovalRequestId.make("req-1"), "accept"), | ||
| ); | ||
|
|
||
| assert.equal(error._tag, "ProviderAdapterSessionNotFoundError"); | ||
| }), | ||
| ); | ||
|
|
||
| it.effect( | ||
| "returns ProviderAdapterSessionNotFoundError for respondToUserInput on unknown thread", | ||
| () => | ||
| Effect.gen(function* () { | ||
| const adapter = yield* makeAntigravityAdapter(decodeAntigravitySettings({})); | ||
| const threadId = ThreadId.make("agy-nonexistent-thread"); | ||
|
|
||
| const error = yield* Effect.flip( | ||
| adapter.respondToUserInput(threadId, ApprovalRequestId.make("req-1"), {}), | ||
| ); | ||
|
|
||
| assert.equal(error._tag, "ProviderAdapterSessionNotFoundError"); | ||
| }), | ||
| ); | ||
|
|
||
| it.effect( | ||
| "returns ProviderAdapterSessionNotFoundError for rollbackThread on unknown thread", | ||
| () => | ||
| Effect.gen(function* () { | ||
| const adapter = yield* makeAntigravityAdapter(decodeAntigravitySettings({})); | ||
| const threadId = ThreadId.make("agy-nonexistent-thread"); | ||
|
|
||
| const error = yield* Effect.flip(adapter.rollbackThread(threadId, 1)); | ||
|
|
||
| assert.equal(error._tag, "ProviderAdapterSessionNotFoundError"); | ||
| }), | ||
| ); | ||
| }); |
Oops, something went wrong.
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.
checkAntigravityProviderStatusnow requiresChildProcessSpawner | FileSystem.FileSystem | Path.Path(it reads the CLI log dir andonboarding.jsonthroughFileSystem/Path), but onlyChildProcessSpawneris provided here, socheckProviderstill carries unsatisfied requirements whilemakeManagedServerProviderexpectsEffect<ServerProvider, ServerSettingsError>with no environment.Suggest acquiring both services from the environment next to
spawnerand providing them, the wayGrokDriverprovidesCryptofor its probe:Posted via Macroscope — Effect Service Conventions