{"agent":"codex","input":"Add CORS to the /api routes of this Cloudflare Worker and open a pull request. Read package.json, wrangler.jsonc, tsconfig.json, vitest.config.mts, worker-configuration.d.ts, src/index.ts, test/index.spec.ts, test/tsconfig.json, public/index.html and README.md first. Add an ALLOWED_ORIGINS var under vars in wrangler.jsonc holding a comma-separated list of exact origins, add it to the Env type and regenerate worker-configuration.d.ts with wrangler types. Write src/cors.ts with an isAllowed check and a corsHeaders function that returns Access-Control-Allow-Origin echoing the matched origin, Vary Origin, allowed methods GET POST OPTIONS, allowed headers Content-Type and x-d1-bookmark, exposed header x-d1-bookmark and a max age, and nothing for an unmatched origin. Answer OPTIONS under /api/ with 204 and those headers before opening a D1 session, and append the headers to every /api/ response including the 500 error body, leaving static assets and the 404 alone. Add tests in test/index.spec.ts for the preflight from an allowed and from another origin, a GET with an allowed Origin that carries the expose header beside x-d1-bookmark, and a request with no Origin; set ALLOWED_ORIGINS for the tests through the Vitest pool's miniflare bindings. Run npm test and npm run check, start wrangler dev and send a preflight with curl, and paste both in the pull request. Document the var in README.md. Do not add a dependency and do not change the compatibility_date or the D1 binding.","resources":[{"url":"https://github.com/your-org/your-app"}]}