style: apply oxfmt

This commit is contained in:
Peter Steinberger
2026-01-18 02:19:35 +00:00
parent b659db0a5b
commit 0c93b9b7bb
21 changed files with 87 additions and 89 deletions

View File

@@ -68,7 +68,10 @@ export function markdownToText(markdown: string): string {
return normalizeWhitespace(text);
}
export function truncateText(value: string, maxChars: number): { text: string; truncated: boolean } {
export function truncateText(
value: string,
maxChars: number,
): { text: string; truncated: boolean } {
if (value.length <= maxChars) return { text: value, truncated: false };
return { text: value.slice(0, maxChars), truncated: true };
}

View File

@@ -79,11 +79,7 @@ type PerplexityConfig = {
model?: string;
};
type PerplexityApiKeySource =
| "config"
| "perplexity_env"
| "openrouter_env"
| "none";
type PerplexityApiKeySource = "config" | "perplexity_env" | "openrouter_env" | "none";
type PerplexitySearchResponse = {
choices?: Array<{

View File

@@ -36,7 +36,12 @@ export function readCache<T>(
return { value: entry.value, cached: true };
}
export function writeCache<T>(cache: Map<string, CacheEntry<T>>, key: string, value: T, ttlMs: number) {
export function writeCache<T>(
cache: Map<string, CacheEntry<T>>,
key: string,
value: T,
ttlMs: number,
) {
if (ttlMs <= 0) return;
if (cache.size >= DEFAULT_CACHE_MAX_ENTRIES) {
const oldest = cache.keys().next();

View File

@@ -104,8 +104,7 @@ describe("web_search perplexity baseUrl defaults", () => {
const mockFetch = vi.fn(() =>
Promise.resolve({
ok: true,
json: () =>
Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
} as Response),
);
// @ts-expect-error mock fetch
@@ -127,8 +126,7 @@ describe("web_search perplexity baseUrl defaults", () => {
const mockFetch = vi.fn(() =>
Promise.resolve({
ok: true,
json: () =>
Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
} as Response),
);
// @ts-expect-error mock fetch
@@ -150,8 +148,7 @@ describe("web_search perplexity baseUrl defaults", () => {
const mockFetch = vi.fn(() =>
Promise.resolve({
ok: true,
json: () =>
Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
} as Response),
);
// @ts-expect-error mock fetch
@@ -172,8 +169,7 @@ describe("web_search perplexity baseUrl defaults", () => {
const mockFetch = vi.fn(() =>
Promise.resolve({
ok: true,
json: () =>
Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
} as Response),
);
// @ts-expect-error mock fetch
@@ -202,8 +198,7 @@ describe("web_search perplexity baseUrl defaults", () => {
const mockFetch = vi.fn(() =>
Promise.resolve({
ok: true,
json: () =>
Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
json: () => Promise.resolve({ choices: [{ message: { content: "ok" } }], citations: [] }),
} as Response),
);
// @ts-expect-error mock fetch