feat: make DAVE Telegram chat conversational
All checks were successful
Codex Template Compliance / template-compliance (pull_request) Successful in 8s
Build / test-and-image (pull_request) Successful in 52s

This commit is contained in:
2026-07-07 18:46:44 +02:00
parent c0fb9d1e66
commit a7f3f36d2b
10 changed files with 244 additions and 35 deletions

View File

@@ -228,7 +228,7 @@ if (telegramAlerter.isConfigured) {
},
};
}
return { text: `${result.answer}${traceSuffix}`, parseMode: null };
return { text: `${result.answer}${traceSuffix}`, parseMode: null, conversation: true, maxChunkChars: 900 };
};
telegramAlerter.onMessage((text, msg) => {
@@ -927,7 +927,7 @@ function shouldRunProactiveAgent(delta) {
async function runProactiveAgent(data, delta) {
if (telegramAlerter.getMuteStatus().muted) return false;
const prompt = `Evaluate the latest sweep as the operator's Security Manager. Use the security profile when available to assess geographic and personal relevance, dependencies, urgency, and preferred language. Cross-check material changes with source health, evidence, scenarios, memory, and predictions as needed. Distinguish verified facts from inference. Do not call mutating tools. Delta summary: ${JSON.stringify(delta?.summary || {})}`;
const prompt = `Evaluate the latest sweep as the operator's Security Manager. Use the security profile when available to assess geographic and personal relevance, dependencies, urgency, and preferred language. Cross-check material changes with source health, evidence, scenarios, memory, predictions, and web_search when current external corroboration is needed. Distinguish verified facts from inference. Do not call mutating tools. If you notify, write like a live Telegram chat: short first message, no visible Markdown, no report wall. Delta summary: ${JSON.stringify(delta?.summary || {})}`;
const profile = securityProfileStore.getAgentProfile();
const result = await terminalAgent.analyzeProactively(prompt, {
context: buildTelegramChatContext(data, buildHealth()),
@@ -944,13 +944,18 @@ async function runProactiveAgent(data, delta) {
return false;
}
const german = profile?.language === 'de';
const evidence = result.evidence?.length ? `\n${german ? 'Belege' : 'Evidence'}:\n${result.evidence.map(item => `- ${item}`).join('\n')}` : '';
const evidence = result.evidence?.length ? `${german ? 'Belege' : 'Evidence'}:\n${result.evidence.map(item => `- ${item}`).join('\n')}` : '';
const tools = [...new Set((result.trace || []).filter(item => item.status === 'ok').map(item => item.tool))];
const trace = tools.length ? `\n${german ? 'Werkzeuge' : 'Tools'}: ${tools.join(', ')}` : '';
const trace = tools.length ? `${german ? 'Werkzeuge' : 'Tools'}: ${tools.join(', ')}` : '';
const priority = german
? ({ routine: 'HINWEIS', priority: 'PRIORITÄT', flash: 'SOFORT' }[result.priority] || 'HINWEIS')
: String(result.priority || 'routine').toUpperCase();
const sent = await telegramAlerter.sendMessage(`[DAVE // ${priority}]\n${result.answer}${evidence}${trace}`, { parseMode: null });
const messages = [
`[DAVE // ${priority}]\n${result.answer}`,
evidence,
trace,
].filter(Boolean);
const sent = await telegramAlerter.sendConversation(messages, { maxChunkChars: 800 });
return sent.ok;
}