agent-nodejs
agent-nodejs copied to clipboard
feat(ai-proxy): add Zod validation for route bodies
Summary
- Add
schemas.tswith Zod schemas for runtime route validation - Validate
dispatchBody(ai-query route) - requiresmessagesarray with at least one message - Validate
invokeRemoteToolBody- requiresinputsarray with at least one message - Validate
invokeToolQuery- requirestool-nameparameter - Use permissive validation with
.passthrough()- validates structure, lets OpenAI SDK handle field details - Throw
AIUnprocessableErrorwith clear messages on validation failure
Files
-
New:
packages/ai-proxy/src/schemas.ts- Zod schemas -
New:
packages/ai-proxy/test/schemas.test.ts- 12 unit tests -
Modified:
packages/ai-proxy/src/router.ts- Integrate validation -
Modified:
packages/ai-proxy/package.json- Add zod dependency
Test plan
- [x] All unit tests pass (
yarn workspace @forestadmin/ai-proxy test) - [x] Lint passes (
yarn workspace @forestadmin/ai-proxy lint) - [x] Build passes (
yarn workspace @forestadmin/ai-proxy build)
🤖 Generated with Claude Code