feat: wire code agent runs to tool mode
This commit is contained in:
+17
-4
@@ -1061,11 +1061,18 @@ export function createTkmindProxy({
|
||||
});
|
||||
}
|
||||
|
||||
async function reconcileSessionPolicyForUser(userId, sessionId) {
|
||||
async function getSessionPolicyForToolMode(userId, toolMode = 'chat') {
|
||||
if (toolMode === 'code' && userAuth.getCodeAgentSessionPolicy) {
|
||||
return userAuth.getCodeAgentSessionPolicy(userId);
|
||||
}
|
||||
return userAuth.getAgentSessionPolicy(userId);
|
||||
}
|
||||
|
||||
async function reconcileSessionPolicyForUser(userId, sessionId, { toolMode = 'chat' } = {}) {
|
||||
if (!userId || !sessionId) return;
|
||||
const target = await resolveTarget(sessionId);
|
||||
const workingDir = await userAuth.resolveWorkingDir(userId);
|
||||
const sessionPolicy = await userAuth.getAgentSessionPolicy(userId);
|
||||
const sessionPolicy = await getSessionPolicyForToolMode(userId, toolMode);
|
||||
const publishLayout = await userAuth.getUserPublishLayout(userId);
|
||||
const userMemories = conversationMemoryService?.listMemories
|
||||
? await conversationMemoryService.listMemories(userId, { limit: 40 }).catch(() => [])
|
||||
@@ -1091,7 +1098,13 @@ export function createTkmindProxy({
|
||||
);
|
||||
}
|
||||
|
||||
async function submitSessionReplyForUser(userId, sessionId, requestId, userMessage) {
|
||||
async function submitSessionReplyForUser(
|
||||
userId,
|
||||
sessionId,
|
||||
requestId,
|
||||
userMessage,
|
||||
{ toolMode = 'chat' } = {},
|
||||
) {
|
||||
if (!userId || !sessionId) throw new Error('缺少会话信息');
|
||||
const owns = await userAuth.ownsSession(userId, sessionId);
|
||||
if (!owns) throw new Error('无权访问该会话');
|
||||
@@ -1103,7 +1116,7 @@ export function createTkmindProxy({
|
||||
throw err;
|
||||
}
|
||||
|
||||
await reconcileSessionPolicyForUser(userId, sessionId);
|
||||
await reconcileSessionPolicyForUser(userId, sessionId, { toolMode });
|
||||
await applySessionLlmProvider(sessionId);
|
||||
|
||||
const user = await userAuth.getUserById(userId);
|
||||
|
||||
Reference in New Issue
Block a user