@@ -8,7 +8,7 @@ import { getWidgetConfig, WIDGET_URIS } from '../resources/widgets.js';
88import type { InternalToolArgs , ToolEntry , ToolInputSchema } from '../types.js' ;
99import { compileSchema } from '../utils/ajv.js' ;
1010import { logHttpError } from '../utils/logging.js' ;
11- import { buildMCPResponse } from '../utils/mcp.js' ;
11+ import { buildMCPResponse , buildUsageMeta } from '../utils/mcp.js' ;
1212import { generateSchemaFromItems } from '../utils/schema-generation.js' ;
1313import { getActorRunOutputSchema } from './structured-output-schemas.js' ;
1414
@@ -138,15 +138,13 @@ USAGE EXAMPLES:
138138 : `Actor run ${ parsed . runId } status: ${ run . status } . A progress widget has been rendered.` ;
139139
140140 const widgetConfig = getWidgetConfig ( WIDGET_URIS . ACTOR_RUN ) ;
141+ const usageMeta = buildUsageMeta ( run ) ;
141142 return buildMCPResponse ( {
142143 texts : [ statusText ] ,
143144 structuredContent,
144145 _meta : {
145146 ...widgetConfig ?. meta ,
146- ...( run . usageTotalUsd !== undefined && {
147- apifyUsageTotalUsd : run . usageTotalUsd ,
148- apifyUsageUsd : run . usageUsd ,
149- } ) ,
147+ ...usageMeta ,
150148 } ,
151149 } ) ;
152150 }
@@ -158,10 +156,7 @@ USAGE EXAMPLES:
158156 return buildMCPResponse ( {
159157 texts,
160158 structuredContent,
161- _meta : run . usageTotalUsd !== undefined ? {
162- apifyUsageTotalUsd : run . usageTotalUsd ,
163- apifyUsageUsd : run . usageUsd as Record < string , number > | undefined ,
164- } : undefined ,
159+ _meta : buildUsageMeta ( run ) ,
165160 } ) ;
166161 } catch ( error ) {
167162 logHttpError ( error , 'Failed to get Actor run' , { runId : parsed . runId } ) ;
0 commit comments