feat: default locale Russian, geo determines language for other countries

- localization-svc: defaultLocale ru, resolveLocale only by geo
- web-svc: DEFAULT_LOCALE ru, layout lang=ru, embeddedTranslations fallback ru
- countryToLocale: default ru when no country or unknown country

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
home
2026-02-23 15:10:38 +03:00
parent 8fc82a3b90
commit cd6b7857ba
606 changed files with 26148 additions and 14297 deletions

View File

@@ -0,0 +1,51 @@
import z from 'zod';
import type { ToolDef } from './types.js';
const SEARCH_SVC = process.env.SEARCH_SVC_URL?.trim() ?? '';
const SEARXNG = process.env.SEARXNG_URL?.trim() ?? 'https://searx.tiekoetter.com';
const schema = z.object({
queries: z.array(z.string()).max(3).describe('Search queries (keywords, SEO-friendly)'),
});
async function doSearch(q: string): Promise<{ results: { title: string; url: string; content?: string }[] }> {
if (SEARCH_SVC) {
const url = `${SEARCH_SVC.replace(/\/$/, '')}/api/v1/search?q=${encodeURIComponent(q)}`;
const res = await fetch(url, { signal: AbortSignal.timeout(15000) });
if (!res.ok) throw new Error(`Search HTTP ${res.status}`);
const data = (await res.json()) as { results?: { title?: string; url?: string; content?: string }[] };
return {
results: (data.results ?? []).map((r) => ({
title: r.title ?? '',
url: r.url ?? '',
content: r.content ?? '',
})),
};
}
const url = `${SEARXNG}/search?format=json&q=${encodeURIComponent(q)}`;
const res = await fetch(url, { signal: AbortSignal.timeout(15000) });
const data = (await res.json()) as { results?: { title?: string; url?: string; content?: string }[] };
return {
results: (data.results ?? []).map((r) => ({
title: r.title ?? '',
url: r.url ?? '',
content: r.content ?? '',
})),
};
}
export const webSearchTool: ToolDef = {
name: 'web_search',
description: 'Search the web for information. Use SEO-friendly keywords. Up to 3 queries per call.',
schema,
execute: async (params, _ctx) => {
const { queries } = schema.parse(params);
const results = await Promise.all(queries.map(doSearch));
const all = results.flatMap((r) => r.results).slice(0, 15);
return JSON.stringify(
all.map((r) => ({ title: r.title, url: r.url, snippet: (r.content ?? '').slice(0, 200) })),
null,
2,
);
},
};