Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

Refactor protocol parser and structured input

8 months ago

dd4e62b
Authored
mweinbach2/22/2026, 11:26:32 PM
Replace ad-hoc validation with reusable zod helpers and per-type schemas in protocolParser. Introduces helper validators (required/optional strings, booleans, numbers, sessionId), schemaWithType/session helpers, and superRefine usage for custom checks (provider auth, MCP server payload, set_config, harness context, etc.). Switch from a discriminatedUnion options array to a lookup map and update safeParseClientMessage to select schema by type. Refactor structured input parsing to use a zod transform/pipe for JSON parsing and validation, simplify parseStructuredToolInput, and add tests for structured input. Tests updated to assert protocol error code and source fields.

Parentcf8f1a9

4 files changed
  • src/server/protocolParser.ts+385−275
  • src/shared/structuredInput.ts+10−29
  • test/server.test.ts+11−0
  • test/structured-input.test.ts+37−0