mirror of
https://github.com/simstudioai/sim.git
synced 2026-11-02 22:52:17 +08:00
* fix: require explicit trust for internal tool routes * fix(tools): harden internal route validation * fix(tools): close request audit gaps * fix(tools): validate request trust policies
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import type { KnowledgeTriggerSyncResponse } from '@/tools/knowledge/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const knowledgeTriggerSyncTool: ToolConfig<any, KnowledgeTriggerSyncResponse> = {
|
|
id: 'knowledge_trigger_sync',
|
|
name: 'Knowledge Trigger Sync',
|
|
description: 'Trigger a manual sync for a knowledge base connector',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
knowledgeBaseId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'ID of the knowledge base the connector belongs to',
|
|
},
|
|
connectorId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'ID of the connector to trigger sync for',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
internal: true,
|
|
internalAuth: 'executor_delegation',
|
|
url: (params) =>
|
|
`/api/knowledge/${encodeURIComponent(params.knowledgeBaseId)}/connectors/${encodeURIComponent(params.connectorId)}/sync`,
|
|
method: 'POST',
|
|
headers: () => ({
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response, params): Promise<KnowledgeTriggerSyncResponse> => {
|
|
const result = await response.json()
|
|
|
|
return {
|
|
success: result.success ?? true,
|
|
output: {
|
|
connectorId: params?.connectorId ?? '',
|
|
message: result.message ?? 'Sync triggered',
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
connectorId: {
|
|
type: 'string',
|
|
description: 'ID of the connector that was synced',
|
|
},
|
|
message: {
|
|
type: 'string',
|
|
description: 'Status message from the sync trigger',
|
|
},
|
|
},
|
|
}
|