@@ -20,6 +20,7 @@ import type * as EffectAcpErrors from "effect-acp/errors";
2020import type * as EffectAcpSchema from "effect-acp/compat" ;
2121
2222import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime" ;
23+ import { acpProviderOptionDescriptors } from "@t3tools/provider-acp/server/sessionConfig" ;
2324import { makeManagedServerProvider } from "@t3tools/provider-core/server/managedProvider" ;
2425import {
2526 makeManualOnlyProviderMaintenanceCapabilities ,
@@ -32,6 +33,8 @@ import {
3233} from "@t3tools/provider-core/server/snapshotProbe" ;
3334import { resolveUsageLimitsAfterProbe } from "@t3tools/provider-core/server/usageLimits" ;
3435
36+ import { antigravityThinkingConfig } from "./acp/AntigravityAcpSupport.ts" ;
37+
3538const EMPTY_MODEL_CAPABILITIES = createModelCapabilities ( { optionDescriptors : [ ] } ) ;
3639const MAX_WORKSPACE_SNAPSHOTS = 32 ;
3740const HEALTH_CHECK_TIMEOUT = "90 seconds" ;
@@ -44,8 +47,24 @@ type SessionSetupResult = Pick<
4447 "configOptions" | "models"
4548> ;
4649
50+ type ThinkingConfig = NonNullable < ReturnType < typeof antigravityThinkingConfig > > ;
51+
52+ /** Thinking options each model reported when selected; `null` means it has none. */
53+ export type AntigravityThinkingLevels = ReadonlyMap < string , ThinkingConfig | null > ;
54+
55+ function thinkingCapabilities ( config : ThinkingConfig | null | undefined , observed : boolean ) {
56+ const descriptor = config
57+ ? acpProviderOptionDescriptors ( { configOptions : [ config ] , modeState : undefined } ) [ 0 ]
58+ : undefined ;
59+ if ( descriptor ?. type !== "select" ) return EMPTY_MODEL_CAPABILITIES ;
60+ // Another model's selected level is not this model's default.
61+ const { currentValue : _currentValue , ...unobserved } = descriptor ;
62+ return createModelCapabilities ( { optionDescriptors : [ observed ? descriptor : unobserved ] } ) ;
63+ }
64+
4765export function buildAntigravityModelsFromSession (
4866 setup : SessionSetupResult ,
67+ thinkingLevels : AntigravityThinkingLevels = new Map ( ) ,
4968) : ReadonlyArray < ServerProviderModel > {
5069 const config = setup . configOptions ?. find (
5170 ( option ) => option . id === "model" || option . category === "model" ,
@@ -61,10 +80,13 @@ export function buildAntigravityModelsFromSession(
6180 name : model . name ,
6281 } ) ) ?? [ ] )
6382 : [ ] ;
83+ const currentThinking = antigravityThinkingConfig ( setup . configOptions ) ;
6484 const seen = new Set < string > ( ) ;
6585 return entries . flatMap ( ( entry ) : ServerProviderModel [ ] => {
6686 if ( ! entry . value . trim ( ) || seen . has ( entry . value ) ) return [ ] ;
6787 seen . add ( entry . value ) ;
88+ const observed =
89+ entry . value === currentValue ? ( currentThinking ?? null ) : thinkingLevels . get ( entry . value ) ;
6890 return [
6991 {
7092 slug : entry . value ,
@@ -73,7 +95,10 @@ export function buildAntigravityModelsFromSession(
7395 ...( entry . value === currentValue
7496 ? { isDefault : true , aliases : [ ANTIGRAVITY_DEFAULT_MODEL ] }
7597 : { } ) ,
76- capabilities : EMPTY_MODEL_CAPABILITIES ,
98+ capabilities :
99+ observed === undefined
100+ ? thinkingCapabilities ( currentThinking , false )
101+ : thinkingCapabilities ( observed , true ) ,
77102 } ,
78103 ] ;
79104 } ) ;
@@ -162,6 +187,17 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
162187 } ) ;
163188 // Preserve disk-discovered skills when callbacks replace workspace commands; the registry will not rescan them.
164189 const discoveredSkills = new Map < string , ServerProvider [ "skills" ] > ( ) ;
190+ const thinkingLevels = new Map < string , ThinkingConfig | null > ( ) ;
191+ const observeThinkingLevels = (
192+ configOptions : ReadonlyArray < EffectAcpSchema . SessionConfigOption > | null | undefined ,
193+ ) => {
194+ const model = configOptions ?. find (
195+ ( option ) => option . id === "model" || option . category === "model" ,
196+ ) ;
197+ if ( model ?. type === "select" && model . currentValue ) {
198+ thinkingLevels . set ( model . currentValue , antigravityThinkingConfig ( configOptions ) ?? null ) ;
199+ }
200+ } ;
165201 const getSnapshot = SubscriptionRef . get ( metadata ) . pipe (
166202 Effect . flatMap ( ( state ) => options . stampIdentity ( state . draft ) ) ,
167203 ) ;
@@ -267,6 +303,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
267303 cwd ?: string ,
268304 ) {
269305 if ( ! settings . enabled ) return ;
306+ observeThinkingLevels ( started . sessionSetupResult . configOptions ) ;
270307 const before = yield * SubscriptionRef . get ( metadata ) ;
271308 const supportsTextGeneration = yield * options . supportsTextGeneration ;
272309 const usageLimits =
@@ -301,7 +338,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
301338 published : draft . usageLimits ,
302339 probed : usageLimits ?? draft . usageLimits ,
303340 } ) ,
304- models : buildAntigravityModelsFromSession ( started . sessionSetupResult ) ,
341+ models : buildAntigravityModelsFromSession ( started . sessionSetupResult , thinkingLevels ) ,
305342 supportsTextGeneration,
306343 ...( cwd
307344 ? {
@@ -324,7 +361,8 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
324361 const onConfigOptionsUpdated = Effect . fn ( "AntigravityProvider.onConfigOptionsUpdated" ) ( function * (
325362 configOptions : ReadonlyArray < EffectAcpSchema . SessionConfigOption > ,
326363 ) {
327- const models = buildAntigravityModelsFromSession ( { configOptions } ) ;
364+ observeThinkingLevels ( configOptions ) ;
365+ const models = buildAntigravityModelsFromSession ( { configOptions } , thinkingLevels ) ;
328366 yield * SubscriptionRef . update ( metadata , ( state ) => {
329367 if ( state . draft . auth . status !== "authenticated" ) return state ;
330368 return { ...state , draft : { ...state . draft , models } } ;
@@ -391,6 +429,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func
391429 } ) satisfies AntigravityProviderState ,
392430 ) ;
393431 discoveredSkills . clear ( ) ;
432+ thinkingLevels . clear ( ) ;
394433 } ) ;
395434
396435 const snapshotForCwd = Effect . fn ( "AntigravityProvider.snapshotForCwd" ) ( function * (
0 commit comments