-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add strongly typed tools with createTool helpers #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add tool() function for creating tools with full type inference from Zod schemas - Auto-detect tool type based on configuration (generator, regular, or manual) - Add type inference helpers: InferToolInput, InferToolOutput, InferToolEvent - Add TypedToolCall and TypedToolCallUnion for typed tool call handling - Add generic type parameters to event types for typed streaming - Export all tool types and helpers from main index - Add comprehensive unit tests for create-tool - Add typed-tool-calling example demonstrating the new API 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
91046c3 to
81fa1dd
Compare
- Split RegularToolConfig into two types: with and without outputSchema - Tools without outputSchema now correctly infer return type from execute function - Fixes 'result' is of type 'unknown' error in tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Export all Claude message types from models/index.ts and src/index.ts - Export CallModelInput type from call-model.ts - Simplify sdk.ts callModel signature to use CallModelInput type - Remove unused imports from sdk.ts Fixes TypeScript compilation errors in CI
Update all E2E tests to explicitly use fromChatMessages() and fromClaudeMessages() conversion functions instead of passing raw message arrays directly. This fixes CI validation failures caused by removal of automatic message format conversion. Now all tests properly demonstrate the required usage pattern: - Chat-style messages → fromChatMessages() - Claude-style messages → fromClaudeMessages() Changes: - Add imports for fromChatMessages and fromClaudeMessages - Update ~35 test cases to wrap message arrays in conversion functions - Fix syntax error (trailing comma) from bulk replacement Fixes validation errors: "Invalid input: expected string, received array"
Update E2E tests to use fromChatMessages() and fromClaudeMessages() wrappers for all message array inputs. This fixes CI validation failures by ensuring all tests explicitly convert message formats before passing to callModel(). Changes: - Add imports for fromChatMessages and fromClaudeMessages - Use Python script to automatically wrap input: [...] patterns with fromChatMessages([...]) - Manually wrap Claude message variables with fromClaudeMessages() - All ~40 test cases now properly use conversion functions This ensures tests demonstrate the correct SDK usage pattern and pass validation.
subtleGradient
approved these changes
Dec 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
toolfactory function for creating typed tool definitionsInferToolInput,InferToolOutput,InferToolEvent,InferToolEventsUnionTypedToolCallandTypedToolCallUnionfor typed tool call resultsResponseWrappergeneric withTToolsparameter to preserve type informationcallModelgeneric to flow tool types through the call chainToolStreamEvent<TEvent>,ChatStreamEvent<TEvent>, etc.) for typed preliminary resultsindex.tsHow It Works
When using
as constwith the tools array, all type information flows through:Test plan
npm run build)npm run lint)npx vitest run tests/unit)as const