fix(tools): flatten nested anyOf schemas for Vertex AI compatibility
Claude API on Vertex AI (Cloud Code Assist) rejects nested anyOf schemas as invalid JSON Schema draft 2020-12. This change: - Add tryFlattenLiteralAnyOf() to convert Type.Union([Type.Literal(...)]) patterns from anyOf with const values to flat enum arrays - Update stringEnum helper in bash-tools to use Type.Unsafe with flat enum - Flatten BrowserActSchema from discriminated union to single object - Simplify TelegramToolSchema to use Type.String() for IDs Fixes 400 errors when sending messages through WhatsApp/Telegram providers.
This commit is contained in:
@@ -2,11 +2,14 @@ import { Type } from "@sinclair/typebox";
|
||||
|
||||
import { createReactionSchema } from "./reaction-schema.js";
|
||||
|
||||
// NOTE: chatId and messageId use Type.String() instead of Type.Union([Type.String(), Type.Number()])
|
||||
// because nested anyOf schemas cause JSON Schema validation failures with Claude API on Vertex AI.
|
||||
// Telegram IDs are coerced to strings at runtime in telegram-actions.ts.
|
||||
export const TelegramToolSchema = Type.Union([
|
||||
createReactionSchema({
|
||||
ids: {
|
||||
chatId: Type.Union([Type.String(), Type.Number()]),
|
||||
messageId: Type.Union([Type.String(), Type.Number()]),
|
||||
chatId: Type.String(),
|
||||
messageId: Type.String(),
|
||||
},
|
||||
includeRemove: true,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user