This commit is contained in:
seb
2026-10-16 16:24:58 +02:00
parent f506dd35be
commit 3b875c9f9a
14 changed files with 28 additions and 1228 deletions

View File

@@ -17,7 +17,6 @@ import { createApiSuggestionsOrIssuesTool } from '../tools/apisuggestionsorissue
import { createFindFilesTool } from '../tools/find-files.js';
import { createReadFileTool } from '../tools/read-file.js';
import { createPatchTool } from '../tools/patch.js';
import { setCachedDraft, parseDraftPath } from '../services/draftManager.js';
import { createRmTool } from '../tools/rm.js';
import { createSearchImagesTool } from '../tools/search-images.js';
import { createAnalyzeImageTool } from '../tools/analyze-image.js';
@@ -503,38 +502,6 @@ export class ConversationManager {
toolMsg = await db.addMessage(googleAuthId, this.conversationId, { message: payload, role: 'tool' });
await db.setState(googleAuthId, this.conversationId, 'busy');
// If this tool response is answering a draft read, cache the draft
try {
let parsedContent = null;
try { parsedContent = JSON.parse(rawContent); } catch {}
if (parsedContent && (parsedContent.manifest || parsedContent.lines)) {
const messages = await db.listMessages(googleAuthId, this.conversationId);
for (let i = messages.length - 1; i >= 0; i--) {
const m = messages[i];
if (m.role === 'assistant' || m.role === 'model') {
let p = null;
try { p = typeof m.message === 'string' ? JSON.parse(m.message) : m.message; } catch {}
const tc = p?.tool_calls?.find((c) => c.id === tool_call_id);
if (tc) {
let tcArgs = {};
try { tcArgs = typeof tc.function?.arguments === 'string' ? JSON.parse(tc.function.arguments) : (tc.function?.arguments || {}); } catch {}
const draftInfo = parseDraftPath(tcArgs.filename || tcArgs.file || '');
if (draftInfo.isDraft) {
setCachedDraft({
companyId: this.companyId,
userId: googleAuthId,
name: draftInfo.name,
content: parsedContent,
});
}
break;
}
}
}
}
} catch (err) {
console.warn('[conversationManager] could not cache draft from tool message:', err.message);
}
} catch (err) {
this.isProcessing = false;
throw err;
@@ -773,8 +740,8 @@ export class ConversationManager {
// can never end up pointed at different companies.
createJavascriptExecuteTool({ googleAuthId }),
createFindFilesTool({ googleAuthId }),
createReadFileTool({ googleAuthId, conversationId: this.conversationId }),
createPatchTool({ googleAuthId, conversationId: this.conversationId }),
createReadFileTool({ googleAuthId }),
createPatchTool({ googleAuthId }),
createRmTool({ googleAuthId }),
createSearchImagesTool({ googleAuthId }),
createAnalyzeImageTool({ googleAuthId, model }),