@@ -12,6 +12,7 @@ vi.mock('@/lib/internal/workflows/read-tool-enrichment', () => ({
1212} ) )
1313
1414import { getParamsForToolOperation } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/param-dependents'
15+ import { GaugeBlock } from '@/blocks/blocks/gauge'
1516import { GreenhouseV2Block } from '@/blocks/blocks/greenhouse'
1617import { IntuneBlock } from '@/blocks/blocks/intune'
1718import { MicrosoftExcelV2Block } from '@/blocks/blocks/microsoft_excel'
@@ -46,6 +47,14 @@ import {
4647 transformBlockTool ,
4748} from '@/providers/utils'
4849import { useProvidersStore } from '@/stores/providers/store'
50+ import { gaugeGetQueryMetadataTool } from '@/tools/gauge/get_query_metadata'
51+ import { gaugeListPromptsTool } from '@/tools/gauge/list_prompts'
52+ import type {
53+ GaugeGetQueryMetadataParams ,
54+ GaugeListPromptsParams ,
55+ GaugeUpdatePromptParams ,
56+ } from '@/tools/gauge/types'
57+ import { gaugeUpdatePromptTool } from '@/tools/gauge/update_prompt'
4958import { greenhouseConvertProspectV2Tool } from '@/tools/greenhouse/convert_prospect_v2'
5059import { greenhouseCreateApplicationV2Tool } from '@/tools/greenhouse/create_application_v2'
5160import { greenhouseHireApplicationV2Tool } from '@/tools/greenhouse/hire_application_v2'
@@ -79,6 +88,137 @@ const mockGetRotatingApiKey = vi.fn().mockReturnValue('rotating-server-key')
7988const originalRequire = module . require
8089
8190describe ( 'integration filters through agent execution' , ( ) => {
91+ it . each ( [ 'configured' , 'model' ] as const ) (
92+ 'retains the %s Gauge topic filter without a stored operation' ,
93+ async ( source ) => {
94+ const tool = gaugeListPromptsTool
95+ vi . spyOn ( toolMetadata , 'getToolMetadata' ) . mockReturnValue ( tool )
96+ const field = getSubBlocksForToolInput (
97+ tool . id ,
98+ 'gauge' ,
99+ { operation : tool . id } ,
100+ undefined ,
101+ GaugeBlock
102+ ) ?. subBlocks . find ( ( item ) => item . canonicalParamId === 'topicFilter' )
103+ if ( ! field ) throw new Error ( 'Gauge topic filter control is unavailable' )
104+ const providerTool = await transformBlockTool (
105+ {
106+ type : 'gauge' ,
107+ params : {
108+ org : 'example' ,
109+ category : 'example' ,
110+ ...( source === 'configured' ? { [ field . id ] : 'top_configured' } : { } ) ,
111+ } ,
112+ } ,
113+ { selectedOperation : tool . id , getAllBlocks : ( ) => [ GaugeBlock ] , getTool : ( ) => tool }
114+ )
115+ if ( ! providerTool ) throw new Error ( 'Gauge agent tool was not created' )
116+ const { executionParams } = prepareToolExecution (
117+ providerTool ,
118+ { topic : 'top_model' } ,
119+ { } ,
120+ undefined
121+ )
122+ const params = { ...executionParams , accessToken : 'fixture-token' } as GaugeListPromptsParams
123+ const url =
124+ typeof tool . request . url === 'function' ? tool . request . url ( params ) : tool . request . url
125+ expect ( new URL ( url ) . searchParams . get ( 'topic' ) ) . toBe (
126+ source === 'configured' ? 'top_configured' : 'top_model'
127+ )
128+ }
129+ )
130+
131+ it . each ( [ 'configured' , 'unchanged' , 'model' ] as const ) (
132+ 'retains %s Gauge tracking intent without a stored operation' ,
133+ async ( source ) => {
134+ const tool = gaugeUpdatePromptTool
135+ vi . spyOn ( toolMetadata , 'getToolMetadata' ) . mockReturnValue ( tool )
136+ const field = getSubBlocksForToolInput (
137+ tool . id ,
138+ 'gauge' ,
139+ { operation : tool . id } ,
140+ undefined ,
141+ GaugeBlock
142+ ) ?. subBlocks . find ( ( item ) => item . id === 'promptTrackingType' )
143+ if ( ! field && source !== 'model' ) throw new Error ( 'Gauge tracking control is unavailable' )
144+ const providerTool = await transformBlockTool (
145+ {
146+ type : 'gauge' ,
147+ params : {
148+ org : 'example' ,
149+ category : 'example' ,
150+ promptId : 'prompt_example' ,
151+ ...( field && source !== 'model'
152+ ? { [ field . id ] : source === 'unchanged' ? 'unchanged' : 'visibility' }
153+ : { } ) ,
154+ } ,
155+ } ,
156+ { selectedOperation : tool . id , getAllBlocks : ( ) => [ GaugeBlock ] , getTool : ( ) => tool }
157+ )
158+ if ( ! providerTool ) throw new Error ( 'Gauge agent tool was not created' )
159+ const { executionParams } = prepareToolExecution (
160+ providerTool ,
161+ { trackingType : 'branded_own' } ,
162+ { } ,
163+ undefined
164+ )
165+ const params = { ...executionParams , accessToken : 'fixture-token' } as GaugeUpdatePromptParams
166+ expect ( tool . request . body ?.( params ) ) . toEqual ( {
167+ topicId : undefined ,
168+ trackingType :
169+ source === 'unchanged'
170+ ? undefined
171+ : source === 'configured'
172+ ? 'visibility'
173+ : 'branded_own' ,
174+ } )
175+ }
176+ )
177+
178+ it . each ( [ 'configured' , 'all' , 'model' ] as const ) (
179+ 'retains %s Gauge catalog intent without a stored operation' ,
180+ async ( source ) => {
181+ const tool = gaugeGetQueryMetadataTool
182+ vi . spyOn ( toolMetadata , 'getToolMetadata' ) . mockReturnValue ( tool )
183+ const field = getSubBlocksForToolInput (
184+ tool . id ,
185+ 'gauge' ,
186+ { operation : tool . id } ,
187+ undefined ,
188+ GaugeBlock
189+ ) ?. subBlocks . find ( ( item ) => item . id === 'metadataDataset' )
190+ if ( ! field && source !== 'model' ) throw new Error ( 'Gauge catalog control is unavailable' )
191+ const providerTool = await transformBlockTool (
192+ {
193+ type : 'gauge' ,
194+ params : {
195+ org : 'example' ,
196+ ...( field && source !== 'model'
197+ ? { [ field . id ] : source === 'all' ? 'all' : 'citations' }
198+ : { } ) ,
199+ } ,
200+ } ,
201+ { selectedOperation : tool . id , getAllBlocks : ( ) => [ GaugeBlock ] , getTool : ( ) => tool }
202+ )
203+ if ( ! providerTool ) throw new Error ( 'Gauge agent tool was not created' )
204+ const { executionParams } = prepareToolExecution (
205+ providerTool ,
206+ { dataset : 'aiTraffic' } ,
207+ { } ,
208+ undefined
209+ )
210+ const params = {
211+ ...executionParams ,
212+ accessToken : 'fixture-token' ,
213+ } as GaugeGetQueryMetadataParams
214+ const url =
215+ typeof tool . request . url === 'function' ? tool . request . url ( params ) : tool . request . url
216+ expect ( new URL ( url ) . searchParams . get ( 'dataset' ) ) . toBe (
217+ source === 'all' ? null : source === 'configured' ? 'citations' : 'aiTraffic'
218+ )
219+ }
220+ )
221+
82222 it . each ( [
83223 {
84224 operation : 'list_jobs' ,
0 commit comments