import { tool } from '@strands-agents/sdk' import { z } from 'zod' export const currentTimeTool = tool({ name: 'current_time', description: 'Get current date/time (ISO + locale)', inputSchema: z.object({ timezone: z.string().optional() }), callback: (input) => { const d = new Date() return JSON.stringify({ iso: d.toISOString(), locale: d.toLocaleString(undefined, input.timezone ? { timeZone: input.timezone } : undefined), timestamp: d.getTime(), timezone: input.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone, }) }, }) export const updateUIConfigTool = tool({ name: 'update_ui_config', description: 'Update UI settings (fontSize, debounceMs, theme)', inputSchema: z.object({ fontSize: z.number().optional(), debounceMs: z.number().optional(), theme: z.enum(['dark', 'light']).optional(), }), callback: (input) => { try { const raw = localStorage.getItem('careless-v2-settings') const s = raw ? JSON.parse(raw) : {} Object.assign(s, input) localStorage.setItem('careless-v2-settings', JSON.stringify(s)) if (input.theme) { document.documentElement.setAttribute('data-theme', input.theme) localStorage.setItem('careless-v2-theme', input.theme) } window.dispatchEvent(new CustomEvent('careless:settings-updated', { detail: s })) return JSON.stringify({ status: 'success', applied: input }) } catch (err: unknown) { return JSON.stringify({ status: 'error', error: (err as Error).message }) } }, }) export const WRITING_TOOLS = [currentTimeTool, updateUIConfigTool]