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

@@ -1,6 +1,7 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { TerminalAgent, TerminalToolRegistry } from '../lib/agent/terminal-agent.mjs';
import { createTerminalToolRegistry } from '../lib/agent/terminal-tools.mjs';
function providerWith(decisions) {
let index = 0;
@@ -214,3 +215,38 @@ test('malformed tagged protocol is repaired instead of returned to the user', as
assert.equal(result.answer, 'I could not run the malformed tool request.');
assert.doesNotMatch(result.answer, /tool_call|call:get_evidence/i);
});
test('terminal registry exposes bounded public web search as a read-only tool', async () => {
const originalFetch = globalThis.fetch;
let requestedUrl = '';
globalThis.fetch = async (url) => {
requestedUrl = String(url);
return {
ok: true,
status: 200,
headers: { get: () => 'application/json' },
text: async () => JSON.stringify({
articles: [{
title: 'Verified report',
sourceCommonName: 'Example News',
url: 'https://example.test/report',
seendate: '20260707100000',
language: 'English',
}],
}),
};
};
try {
const registry = createTerminalToolRegistry();
const tool = registry.get('web_search');
assert.equal(tool.mutating, false);
const result = await registry.execute('web_search', { query: 'Russia attack claim', limit: 3, hours: 24 });
assert.match(requestedUrl, /api\.gdeltproject\.org\/api\/v2\/doc\/doc/);
assert.equal(result.query, 'Russia attack claim');
assert.equal(result.results.length, 1);
assert.equal(result.results[0].url, 'https://example.test/report');
} finally {
globalThis.fetch = originalFetch;
}
});