@@ -6,7 +6,7 @@ import * as path from "path"
66import * as vscode from "vscode"
77import { Anthropic } from "@anthropic-ai/sdk"
88
9- import type { GlobalState , ProviderSettings , ModelInfo } from "@roo-code/types"
9+ import { providerIdentifiers , type GlobalState , type ProviderSettings , type ModelInfo } from "@roo-code/types"
1010import { TelemetryService } from "@roo-code/telemetry"
1111
1212import { Task } from "../Task"
@@ -1902,6 +1902,52 @@ describe("Cline", () => {
19021902 expect ( metadata ! . abortSignal ) . toBe ( task . currentRequestAbortController ! . signal )
19031903 } )
19041904
1905+ it ( "enables allowed function names through the canonical Gemini provider identifier" , async ( ) => {
1906+ const identifiers = providerIdentifiers as Record < string , string >
1907+ const originalIdentifier = identifiers . gemini
1908+
1909+ try {
1910+ identifiers . gemini = "canonical-gemini"
1911+ const apiConfiguration = {
1912+ ...mockApiConfig ,
1913+ apiProvider : identifiers . gemini ,
1914+ } as ProviderSettings
1915+ const task = new Task ( {
1916+ provider : mockProvider ,
1917+ apiConfiguration,
1918+ task : "test task" ,
1919+ startTask : false ,
1920+ } )
1921+
1922+ vi . spyOn ( task as any , "getSystemPrompt" ) . mockResolvedValue ( "mock system prompt" )
1923+ vi . spyOn ( task . api , "getModel" ) . mockReturnValue ( {
1924+ id : mockApiConfig . apiModelId ! ,
1925+ info : { contextWindow : 200000 , maxTokens : 4096 } as ModelInfo ,
1926+ } )
1927+ const providerState = await mockProvider . getState ( )
1928+ vi . spyOn ( mockProvider , "getState" ) . mockResolvedValue ( {
1929+ ...providerState ,
1930+ apiConfiguration,
1931+ autoApprovalEnabled : true ,
1932+ requestDelaySeconds : 0 ,
1933+ } )
1934+ const mockStream = ( async function * ( ) {
1935+ yield { type : "text" , text : "response" } as ApiStreamChunk
1936+ } ) ( )
1937+ const createMessageSpy = vi . spyOn ( task . api , "createMessage" ) . mockReturnValue ( mockStream )
1938+ task . apiConversationHistory = [
1939+ { role : "user" , content : [ { type : "text" , text : "test message" } ] , ts : Date . now ( ) } ,
1940+ ] as any
1941+
1942+ await task . attemptApiRequest ( 0 ) . next ( )
1943+
1944+ const [ , , metadata ] = createMessageSpy . mock . calls [ 0 ] !
1945+ expect ( metadata ?. allowedFunctionNames ) . toEqual ( expect . any ( Array ) )
1946+ } finally {
1947+ identifiers . gemini = originalIdentifier
1948+ }
1949+ } )
1950+
19051951 it ( "should invoke abort on currentRequestAbortController during first-chunk wait" , async ( ) => {
19061952 const task = new Task ( {
19071953 provider : mockProvider ,
0 commit comments