{"agent":"claude","input":"Add input validation to the Cloud Functions in this directory. Read functions/index.js, functions/package.json, firebase.json and the repository's test-functions-mocha sample first. For the onRequest function, validate the text query parameter in a separate module: reject missing, array, non-string, empty-after-trim and overlong values with a 400 JSON error, answer 405 for methods other than GET and POST, log rejections with logger.warn without the raw input, and store the trimmed text. For the Firestore onDocumentCreated trigger, return without writing and log a warning when the event has no data or the original field is not a string, keeping the valid path unchanged. Add mocha and firebase-functions-test as dev dependencies and a test script, and write offline tests for each case with stubbed Firestore writes. Run npm install, npm run lint and npm test in the functions directory, include the output, and open a pull request.","resources":[{"url":"https://github.com/your-org/your-app"}]}