Compare commits

..

4 Commits

Author SHA1 Message Date
Siddharth Ganesan
80eb2a8aa1 Fix 2026-01-26 12:25:01 -08:00
Siddharth Ganesan
315d9ee3f9 Lint 2026-01-26 10:21:01 -08:00
Siddharth Ganesan
62b06d00de Fix comments 2026-01-25 14:33:27 -08:00
Siddharth Ganesan
2a630859fb Fix validation 2026-01-25 14:31:12 -08:00
2 changed files with 26 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ import {
type KnowledgeBaseArgs, type KnowledgeBaseArgs,
} from '@/lib/copilot/tools/shared/schemas' } from '@/lib/copilot/tools/shared/schemas'
import { useCopilotStore } from '@/stores/panel/copilot/store' import { useCopilotStore } from '@/stores/panel/copilot/store'
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
/** /**
* Client tool for knowledge base operations * Client tool for knowledge base operations
@@ -102,7 +103,19 @@ export class KnowledgeBaseClientTool extends BaseClientTool {
const logger = createLogger('KnowledgeBaseClientTool') const logger = createLogger('KnowledgeBaseClientTool')
try { try {
this.setState(ClientToolCallState.executing) this.setState(ClientToolCallState.executing)
const payload: KnowledgeBaseArgs = { ...(args || { operation: 'list' }) }
// Get the workspace ID from the workflow registry hydration state
const { hydration } = useWorkflowRegistry.getState()
const workspaceId = hydration.workspaceId
// Build payload with workspace ID included in args
const payload: KnowledgeBaseArgs = {
...(args || { operation: 'list' }),
args: {
...(args?.args || {}),
workspaceId: args?.args?.workspaceId || workspaceId || undefined,
},
}
const res = await fetch('/api/copilot/execute-copilot-server-tool', { const res = await fetch('/api/copilot/execute-copilot-server-tool', {
method: 'POST', method: 'POST',

View File

@@ -2609,9 +2609,7 @@ async function preValidateCredentialInputs(
model: string model: string
}> = [] }> = []
const hostedModelsLower = isHosted const hostedModelsLower = isHosted ? new Set(getHostedModels().map((m) => m.toLowerCase())) : null
? new Set(getHostedModels().map((m) => m.toLowerCase()))
: null
operations.forEach((op, opIndex) => { operations.forEach((op, opIndex) => {
if (!op.params?.inputs || !op.params?.type) return if (!op.params?.inputs || !op.params?.type) return
@@ -2661,18 +2659,26 @@ async function preValidateCredentialInputs(
// Deep clone operations so we can modify them // Deep clone operations so we can modify them
const filteredOperations = structuredClone(operations) const filteredOperations = structuredClone(operations)
// Filter out apiKey inputs for hosted models // Filter out apiKey inputs for hosted models and add validation errors
if (hasHostedApiKeysToFilter) { if (hasHostedApiKeysToFilter) {
logger.info('Filtering apiKey inputs for hosted models', { count: hostedApiKeyInputs.length }) logger.info('Filtering apiKey inputs for hosted models', { count: hostedApiKeyInputs.length })
for (const apiKeyInput of hostedApiKeyInputs) { for (const apiKeyInput of hostedApiKeyInputs) {
const op = filteredOperations[apiKeyInput.operationIndex] const op = filteredOperations[apiKeyInput.operationIndex]
if (op.params?.inputs?.apiKey) { if (op.params?.inputs?.apiKey) {
delete op.params.inputs.apiKey op.params.inputs.apiKey = undefined
logger.debug('Silently filtered apiKey for hosted model', { logger.debug('Filtered apiKey for hosted model', {
blockId: apiKeyInput.blockId, blockId: apiKeyInput.blockId,
model: apiKeyInput.model, model: apiKeyInput.model,
}) })
errors.push({
blockId: apiKeyInput.blockId,
blockType: apiKeyInput.blockType,
field: 'apiKey',
value: '[redacted]',
error: `Cannot set API key for hosted model "${apiKeyInput.model}" - API keys are managed by the platform when using hosted models`,
})
} }
} }
} }