{"agent":"claude","input":"Add query timeouts to this Next.js app's Drizzle and postgres.js setup. Read package.json, .env.example, drizzle.config.ts, lib/db/queries.ts, lib/db/migrate.ts, lib/db/schema.ts, lib/errors.ts, app/(chat)/api/history/route.ts, app/(chat)/api/chat/route.ts and playwright.config.ts first. Create lib/db/client.ts that builds the postgres.js client with statement_timeout, idle_timeout and connect_timeout read from environment variables with sensible defaults, passes statement_timeout through the connection option so it applies to every session, and exports it for queries.ts; give migrate.ts its own client with max 1 and a longer statement timeout. Add a timeout error type to lib/errors.ts with a 504 status and a wrapDatabaseError helper that maps SQLSTATE 57014 to timeout:database and everything else to bad_request:database, and use it in every catch in queries.ts. Document the variables in .env.example. Install PostgreSQL in the sandbox, run pnpm db:migrate, add a tsx script under tests/ that proves a pg_sleep past the timeout maps to timeout:database and a normal query still succeeds, run it with pnpm lint and tsc --noEmit, and open a pull request with the output.","resources":[{"url":"https://github.com/your-org/your-app"}]}