refactor: improve type safety and code quality for 9.0 score

Type Safety Improvements:
- Add isErrorResult() type guard for API responses (domain-tool.ts)
- Replace `any` with `unknown` in executeTool args (tools/index.ts)
- Add JSON.parse error handling in function calling (openai-service.ts)
- Fix nullable price handling with nullish coalescing
- Add array type guard for nameservers validation

Code Quality Improvements:
- Extract convertNamecheapDate() to eliminate duplicate functions
- Move hardcoded bank account info to environment variables
- Add JSDoc documentation to executeDepositFunction
- Fix unused variables in optimistic-lock.ts
- Handle Error.captureStackTrace for Workers environment

All TypeScript strict mode checks now pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-19 23:33:35 +09:00
parent f5df0c0ffe
commit 61e5185916
5 changed files with 96 additions and 50 deletions

View File

@@ -117,7 +117,7 @@ export function selectToolsForMessage(message: string): typeof tools {
// Tool execution dispatcher with validation
export async function executeTool(
name: string,
args: Record<string, any>,
args: Record<string, unknown>,
env?: Env,
telegramUserId?: string,
db?: D1Database