kyush-llm-router/shared
JellyBrick db58054fdb fix(shared): accept tool role and multimodal content in chat schemas
The v1 chat completion proxy rejected requests with `role: "tool"` or
array-typed `content` (multimodal image/video payloads) because the
shared zod schemas were too restrictive:

- `ChatRoleSchema` was `z.enum(['system','user','assistant'])` — now
  `z.string()` so any role the backend supports passes through. The
  router is a proxy and has no reason to constrain which roles are
  valid; the upstream provider decides that.

- `ChatMessageSchema.content` was `z.string()` — now
  `z.union([z.string(), z.array(z.any()), z.null()]).optional()` to
  accept the three shapes the OpenAI spec defines: plain text, an
  array of content-part objects (images, video frames, etc.), or null
  (e.g. assistant messages that only carry tool_calls). `.passthrough()`
  on the message object ensures extra fields like `tool_call_id`,
  `name`, `tool_calls`, etc. are forwarded untouched.

- `ChatCompletionChoiceSchema.finish_reason` was `z.string()` — now
  `z.string().nullable().optional()` since some providers return null
  for streaming chunks or incomplete generations.

Fixes #2, Fixes #3

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-11 18:36:27 +09:00
..
index.ts refactor: extensionless server imports + auth.tsx onMount fix 2026-04-08 02:15:46 +09:00
package.json refactor: extensionless server imports + auth.tsx onMount fix 2026-04-08 02:15:46 +09:00
schemas.ts fix(shared): accept tool role and multimodal content in chat schemas 2026-04-11 18:36:27 +09:00
tsconfig.json refactor: shared zod, tanstack-query auth, env module, primitives, lucide icons 2026-04-08 01:52:10 +09:00
types.ts feat(Users): add api_key support for user creation and updates 2026-03-27 02:15:44 +09:00