11import { createLogger } from '@sim/logger'
22import { type PermissionType , permissionSatisfies } from '@sim/platform-authz/workspace'
33import { toError } from '@sim/utils/errors'
4+ import { omit } from '@sim/utils/object'
45import { openResourceInputSchema } from '@/lib/api/contracts/mothership-resource-tools'
56import { observeContentDelivery } from '@/lib/core/application'
67import { withWorkspaceInvocationScope } from '@/lib/core/application/workspace-invocation-scope'
@@ -11,8 +12,8 @@ import { createRegistryContentGate } from '@/lib/mothership/content-delivery'
1112import { prepareCopilotEnvironmentContext } from '@/lib/mothership/environment-context'
1213import { isSearchIntegrationToolsEnabled } from '@/lib/mothership/feature-flags'
1314import { isOwnerScopedFile } from '@/lib/mothership/file-owners'
14- import { ToolActivity } from '@/lib/mothership/generated/protocol'
1515import { projectToolErrorMessageForCopilot } from '@/lib/mothership/request/tools/resolved-secret-result'
16+ import { readToolActivity } from '@/lib/mothership/tools/activity'
1617import { recordSecretUsage } from '@/lib/secrets/usage/record'
1718import { executeTool as executeAppTool } from '@/tools'
1819import { getToolMetadata , getToolParams } from '@/tools/metadata'
@@ -294,8 +295,7 @@ async function executeGatedTool(
294295 }
295296
296297 try {
297- const { activity : _activity , ...executionParams } = params
298- return await handler ( executionParams , context )
298+ return await handler ( omit ( params , [ 'activity' ] ) , context )
299299 } catch ( error ) {
300300 const message = toError ( error ) . message
301301 logger . error ( 'Tool execution failed' , {
@@ -341,11 +341,9 @@ function withoutDisplayActivity(
341341 toolId : string ,
342342 params : Record < string , unknown >
343343) : Record < string , unknown > {
344- if ( ! ToolActivity . safeParse ( params . activity ) . success || getToolParams ( toolId ) ?. activity ) {
345- return params
346- }
347- const { activity : _activity , ...rest } = params
348- return rest
344+ return readToolActivity ( params ) && ! getToolParams ( toolId ) ?. activity
345+ ? omit ( params , [ 'activity' ] )
346+ : params
349347}
350348
351349function buildAppToolParams (
0 commit comments