Skip to content

Conversation

@ryoppippi
Copy link
Member

@ryoppippi ryoppippi commented Dec 12, 2025

Summary

  • Define comprehensive JSONSchema interface in types.ts covering all JSON Schema draft-07 properties
  • Add toJsonSchema() method to BaseTool and Tools classes for framework-agnostic schema export
  • Refactor toOpenAI(), toAnthropic(), and toOpenAIResponses() to use toJsonSchema() internally
  • Remove json-schema and @types/json-schema dependencies

Why

This reduces external dependencies while providing a more flexible JSONSchema type that works seamlessly with OpenAI, Anthropic, and other LLM providers. The custom type also uses type-fest's OverrideProperties for cleaner type narrowing (ObjectJSONSchema).

The toJsonSchema() method enables integration with any framework that accepts standard JSON Schema for tool definitions, such as:

  • TanStack AI - uses JSON Schema directly for tool parameters
  • Custom LLM integrations
  • Other AI frameworks that follow JSON Schema conventions

Test plan

  • All existing tests pass
  • Build succeeds
  • Type checking passes

- Define comprehensive JSONSchema interface in types.ts covering all
  JSON Schema draft-07 properties
- Add toJsonSchema() method to BaseTool and Tools classes for
  framework-agnostic schema export
- Refactor toOpenAI(), toAnthropic(), and toOpenAIResponses() to use
  toJsonSchema() internally, reducing code duplication
- Use type-fest OverrideProperties for ObjectJSONSchema type to ensure
  type: 'object' is always set
- Remove json-schema and @types/json-schema dependencies

This reduces external dependencies while providing a more flexible
JSONSchema type that works seamlessly with OpenAI, Anthropic, and
other LLM providers.
@ryoppippi ryoppippi requested a review from a team as a code owner December 12, 2025 13:01
Copilot AI review requested due to automatic review settings December 12, 2025 13:01
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 12, 2025

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@220

commit: fafd7ff

Consolidate schema generation by reusing toJsonSchema() instead of
manually constructing the schema object. This reduces duplication
and ensures consistency across all conversion methods.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes external JSON Schema dependencies (json-schema and @types/json-schema) in favor of a custom JSONSchema interface, reducing external dependencies while maintaining full compatibility with OpenAI, Anthropic, and other LLM providers.

Key Changes:

  • Introduced a comprehensive custom JSONSchema interface covering all JSON Schema draft-07 properties
  • Added toJsonSchema() methods to BaseTool and Tools classes for framework-agnostic schema export
  • Refactored existing methods (toOpenAI(), toAnthropic(), toOpenAIResponses()) to use the new toJsonSchema() internally

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/types.ts Defines custom JSONSchema interface with all draft-07 properties and updates type references
src/tool.ts Adds ObjectJSONSchema type and toJsonSchema() methods; refactors conversion methods to use it
src/tool.test.ts Updates type imports and test assertions from JSONSchema7 to custom JSONSchema
pnpm-workspace.yaml Removes json-schema and @types/json-schema from catalog dependencies
pnpm-lock.yaml Removes dependency resolution entries for json-schema and @types/json-schema
package.json Removes json-schema and @types/json-schema from dependencies and devDependencies
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

- Import JSONSchema7 type from @ai-sdk/provider as AISDKJSONSchema
- Use satisfies AISDKJSONSchema to validate schema at compile time
- Move jsonSchema type import to top-level for cleaner code
- Add @ai-sdk/provider as dev dependency for type checking
- Create tryImport() helper function for dynamic imports with friendly
  error messages when optional dependencies are not installed
- Refactor toAISDK() to use tryImport() for cleaner code
- Remove unused jsonSchema type import from top-level
- Test successful import of existing modules
- Test StackOneError is thrown for non-existent modules
- Verify error message includes module name and install hint
- Remove deprecated v4 parameters property
- Use satisfies for type-safe tool definition
- Remove outdated TODO comment about ts-ignore
- Simplify tool definition by constructing all properties upfront
@ryoppippi ryoppippi force-pushed the refactor/remove-json-schema-dependency branch from 468aea6 to fafd7ff Compare December 12, 2025 16:09
Copy link
Contributor

@glebedel glebedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ryoppippi ryoppippi merged commit 134b0c2 into main Dec 12, 2025
9 checks passed
@ryoppippi ryoppippi deleted the refactor/remove-json-schema-dependency branch December 12, 2025 16:18
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.

3 participants