xonecas.io
53129
Pa

PAT / commit 0f2cbc5

chore: enable TypeScript strict mode and fix type errors

xonecas2025-12-19 0f2cbc5964e476f0eb609996efb33b84c7bb07e8 parent b71e5fc

4 files changed

src/lib/cache/index.ts+6−1
@@ -2,7 +2,12 @@
22
33 import ValKey from "iovalkey";
44
5-const valkey = new ValKey(process.env.VALKEY_URL);
5+const valkeyUrl = process.env.VALKEY_URL;
6+if (!valkeyUrl) {
7+ throw new Error("VALKEY_URL environment variable is not set");
8+}
9+
10+const valkey = new ValKey(valkeyUrl);
611
712 /**
813 * Sets a value in the cache with an optional TTL (time-to-live).
src/lib/ollama/chat/assistant-response.ts+1−1
@@ -68,7 +68,7 @@ export function streamAssistantResponse({
6868 const result = await OllamaChat(
6969 ollamaMessages,
7070 onChunk,
71- threadModel,
71+ threadModel ?? "",
7272 signal,
7373 threadMaxPromptLength
7474 );
src/lib/ollama/tools/tool-runner.ts+5−2
@@ -19,7 +19,8 @@ export async function executeToolCall(toolCall: ToolCall): Promise<Message> {
1919 forecastDays?: number;
2020 };
2121
22- const tools = {
22+ type ToolName = "query_web_search" | "query_weather" | "query_duckduckgo" | "fetch_page";
23+ const tools: Record<ToolName, (query: string) => Promise<string>> = {
2324 query_web_search: queryWebSearch,
2425 query_weather: queryWeather,
2526 query_duckduckgo: queryDuckDuckGo,
@@ -32,8 +33,10 @@ export async function executeToolCall(toolCall: ToolCall): Promise<Message> {
3233 result = await queryWeather(query!, timezone, forecastDays);
3334 } else if (name === "fetch_page") {
3435 result = await fetchPage(url!);
36+ } else if (name in tools) {
37+ result = await tools[name as ToolName](query!);
3538 } else {
36- result = await tools[name](query!);
39+ throw new Error(`Unknown tool: ${name}`);
3740 }
3841 debug(`[Tool] ${name} completed (${result.length} chars)`);
3942 } catch (error) {
tsconfig.json+1−1
@@ -4,7 +4,7 @@
44 "lib": ["dom", "dom.iterable", "esnext"],
55 "allowJs": true,
66 "skipLibCheck": true,
7- "strict": false,
7+ "strict": true,
88 "noEmit": true,
99 "incremental": true,
1010 "module": "esnext",