|
|
@ -1,5 +1,6 @@ |
|
|
import { defineWrappedResponseHandler } from "#server/utils/handler"; |
|
|
import { defineWrappedResponseHandler } from "#server/utils/handler"; |
|
|
import { R } from "#server/utils/response"; |
|
|
import { R } from "#server/utils/response"; |
|
|
|
|
|
import { getCurrentUser, getConfigGlobal } from "#server/utils/context"; |
|
|
import { getAgentBySlug, getAgentTools } from "#server/service/agent/agent"; |
|
|
import { getAgentBySlug, getAgentTools } from "#server/service/agent/agent"; |
|
|
|
|
|
|
|
|
export default defineWrappedResponseHandler(async (event) => { |
|
|
export default defineWrappedResponseHandler(async (event) => { |
|
|
@ -13,7 +14,15 @@ export default defineWrappedResponseHandler(async (event) => { |
|
|
return R.error("agent 不存在", null); |
|
|
return R.error("agent 不存在", null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const tools = await getAgentTools(agent.id); |
|
|
const user = await getCurrentUser(event); |
|
|
|
|
|
const isGuest = !user; |
|
|
|
|
|
|
|
|
|
|
|
let tools = await getAgentTools(agent.id); |
|
|
|
|
|
|
|
|
|
|
|
if (isGuest) { |
|
|
|
|
|
const publicToolSlugs: string[] = await getConfigGlobal("agentPublicToolSlugs"); |
|
|
|
|
|
tools = tools.filter((t) => publicToolSlugs.includes(t.slug)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return R.success({ |
|
|
return R.success({ |
|
|
id: agent.id, |
|
|
id: agent.id, |
|
|
|