677
*/
678
private async _fetchNativeModels(): Promise<readonly IAgentModelInfo[]> {
679
>
// A prompt iterable that never yields: enumeration only needs the
claudeAgent.ts
680
>
// control-request channel (`Query.supportedModels()`), not a real turn.
681
>
const neverYieldingPrompt: AsyncIterable<SDKUserMessage> = {
682
>
[Symbol.asyncIterator]: () => ({ next: () => new Promise<IteratorResult<SDKUserMessage>>(() => { /* never resolves */ }) }),
683
>
};
684
>
const options = buildModelEnumerationOptions();
685
>
const query = await this._sdkService.query({ prompt: neverYieldingPrompt, options });
686
>
try {
687
>
const models = await query.supportedModels();
688
>
return models.map(m => fromSdkModelInfo(m, this.id));
689
>
} finally {
690
>
// `close()` terminates the subprocess; aborting the controller is a
691
>
// belt-and-suspenders teardown for anything `close()` leaves pending.
692
>
query.close();
693
>
options.abortController?.abort();
694
>
}
695
>
}
696
697
/**