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