File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
apps/sim/lib/copilot/tools Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
1010 type KnowledgeBaseArgs ,
1111} from '@/lib/copilot/tools/shared/schemas'
1212import { useCopilotStore } from '@/stores/panel/copilot/store'
13+ import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
1314
1415/**
1516 * Client tool for knowledge base operations
@@ -102,7 +103,19 @@ export class KnowledgeBaseClientTool extends BaseClientTool {
102103 const logger = createLogger ( 'KnowledgeBaseClientTool' )
103104 try {
104105 this . setState ( ClientToolCallState . executing )
105- const payload : KnowledgeBaseArgs = { ...( args || { operation : 'list' } ) }
106+
107+ // Get the workspace ID from the workflow registry hydration state
108+ const { hydration } = useWorkflowRegistry . getState ( )
109+ const workspaceId = hydration . workspaceId
110+
111+ // Build payload with workspace ID included in args
112+ const payload : KnowledgeBaseArgs = {
113+ ...( args || { operation : 'list' } ) ,
114+ args : {
115+ ...( args ?. args || { } ) ,
116+ workspaceId : args ?. args ?. workspaceId || workspaceId || undefined ,
117+ } ,
118+ }
106119
107120 const res = await fetch ( '/api/copilot/execute-copilot-server-tool' , {
108121 method : 'POST' ,
Original file line number Diff line number Diff line change @@ -2659,18 +2659,26 @@ async function preValidateCredentialInputs(
26592659 // Deep clone operations so we can modify them
26602660 const filteredOperations = structuredClone ( operations )
26612661
2662- // Filter out apiKey inputs for hosted models
2662+ // Filter out apiKey inputs for hosted models and add validation errors
26632663 if ( hasHostedApiKeysToFilter ) {
26642664 logger . info ( 'Filtering apiKey inputs for hosted models' , { count : hostedApiKeyInputs . length } )
26652665
26662666 for ( const apiKeyInput of hostedApiKeyInputs ) {
26672667 const op = filteredOperations [ apiKeyInput . operationIndex ]
26682668 if ( op . params ?. inputs ?. apiKey ) {
26692669 op . params . inputs . apiKey = undefined
2670- logger . debug ( 'Silently filtered apiKey for hosted model' , {
2670+ logger . debug ( 'Filtered apiKey for hosted model' , {
26712671 blockId : apiKeyInput . blockId ,
26722672 model : apiKeyInput . model ,
26732673 } )
2674+
2675+ errors . push ( {
2676+ blockId : apiKeyInput . blockId ,
2677+ blockType : apiKeyInput . blockType ,
2678+ field : 'apiKey' ,
2679+ value : '[redacted]' ,
2680+ error : `Cannot set API key for hosted model "${ apiKeyInput . model } " - API keys are managed by the platform when using hosted models` ,
2681+ } )
26742682 }
26752683 }
26762684 }
You can’t perform that action at this time.
0 commit comments