Skip to content

feat(sdk-ts): accept Standard Schema validators for tool input/output schema - #133

Open
vishnu-77 wants to merge 1 commit into
ratel-ai:mainfrom
vishnu-77:feat/sdk-ts-standard-schema
Open

feat(sdk-ts): accept Standard Schema validators for tool input/output schema#133
vishnu-77 wants to merge 1 commit into
ratel-ai:mainfrom
vishnu-77:feat/sdk-ts-standard-schema

Conversation

@vishnu-77

Copy link
Copy Markdown

Summary

Closes #53. ToolCatalog.register() (and the ExecutableTool type) only accepted a bare JSON Schema object for inputSchema/outputSchema. A caller using Zod, Effect Schema, or any Standard Schema-compliant validator had no conversion path when using ToolCatalog directly.

Both framework adapters (@ratel-ai/mastra, @ratel-ai/vercel-ai-sdk) already solved this internally (toJsonSchema() reading schema["~standard"].jsonSchema.input(...)), but the fix never made it into the shared catalog layer. This generalizes that same pattern into ToolCatalog.

Changes

  • ExecutableTool.inputSchema/outputSchema widened from JSONSchema7 to a new ToolSchema = JSONSchema7 | StandardJsonSchema union.
  • New toJsonSchema() helper in catalog.ts, called once in register() and reused for both the native registry and the catalog's internal metadata cache — so catalog.get(id) never leaks a raw Zod/validator object back to a caller.
  • Additive and non-breaking: a plain JSON Schema object has no ~standard key, so it passes through the helper unchanged. Existing bare-JSON-Schema callers are unaffected.
  • ToolSchema/StandardJsonSchema exported from the package's public entrypoint.
  • Test in catalog.test.ts registering a tool with a real zod schema, asserting it's searchable and that the stored/indexed metadata is plain JSON Schema.

Test plan

  • pnpm typecheck && pnpm lint && pnpm test scoped to src/sdk/ts
  • pnpm -r typecheck && pnpm -r lint && pnpm -r test from repo root (no regressions elsewhere)
  • cargo build/clippy/fmt/test --workspace (no Rust files touched; confirms no regression)

… schema

ToolCatalog.register() now accepts a Zod/Effect Schema (or any Standard
Schema-compliant validator) as inputSchema/outputSchema, not just a bare
JSON Schema object. Generalizes the ~standard.jsonSchema conversion the
mastra and vercel-ai-sdk adapters already did internally into the shared
catalog layer.

Closes ratel-ai#53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: support Standard JSON Schema in the TypeScript SDK

1 participant