feat: make DAVE Telegram chat conversational
This commit is contained in:
15
server.mjs
15
server.mjs
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user