{"agent":"claude","input":"Add refresh token rotation to this Next.js app, which uses Auth.js (next-auth v5) with JWT sessions and stores a Keycloak access token in the JWT. Read auth.ts, middleware.ts, app/[...proxy]/route.tsx, app/api/protected/route.ts, components/client-example.tsx, docker-compose.yml and package.json first, then read how the installed next-auth version handles Set-Cookie in auth() for the bare and wrapper forms. In the jwt callback, at sign-in store accessToken, expiresAt (account.expires_at, seconds) and refreshToken; afterwards return the token while it is valid, and when it has expired exchange the refresh token at the provider's token endpoint, read from the issuer's OpenID configuration. Keep the old refresh token if the response has none. On failure set token.error = \"RefreshTokenError\" and do not throw. Put the exchange in lib/refresh-token.ts as a function that takes the token and a fetch. Expose only accessToken and error on the session, never the refresh token, and extend the module augmentation. Make sure every server path that can trigger a refresh also writes the updated session cookie; change app/[...proxy]/route.tsx to the auth((req) => ...) wrapper form if the bare form does not. In the client example, call signIn(\"keycloak\") when session.error is RefreshTokenError. Keep the existing update trigger. Add Vitest and test the refresh function with a stubbed fetch: still valid, expired, no new refresh token, provider error. Install with pnpm, run tsc --noEmit, the tests and pnpm build, and open a pull request.","resources":[{"url":"https://github.com/your-org/your-app"}]}