Commit e890de1
authored
feat(examples): add TanStack AI and Claude Agent SDK integrations with E2E tests (#222)
* chore: remove unused sample-document
* chore: remove fetch tools example
* Revert "chore: remove fetch tools example"
This reverts commit e7372a4.
* feat(example): update interactive fetchTool debug
* refactor(types): replace json-schema library with custom JSONSchema type
- 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.
* refactor(tool): use toJsonSchema() in toAISDK method
Consolidate schema generation by reusing toJsonSchema() instead of
manually constructing the schema object. This reduces duplication
and ensures consistency across all conversion methods.
* refactor(tool): add type-safe schema validation for AI SDK
- 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
* refactor(utils): add tryImport utility for optional dependencies
- 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(utils): add tests for tryImport utility
- Test successful import of existing modules
- Test StackOneError is thrown for non-existent modules
- Verify error message includes module name and install hint
* refactor(tool): clean up toAISDK method
- 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
* chore(oxfmt): ignore .claude/settings.local.json
* chore(deps): move @ai-sdk/provider to catalog:dev
* docs: tanstack ai jsonschema
* test(examples): add E2E tests for example integrations
Add comprehensive E2E tests for all example files using MSW mocks:
- fetch-tools.test.ts: tests tool fetching, filtering, and execution
- ai-sdk-integration.test.ts: tests AI SDK with OpenAI provider
- openai-integration.test.ts: tests OpenAI Chat Completions API
- openai-responses-integration.test.ts: tests OpenAI Responses API
These tests verify the examples work correctly with mocked API responses,
ensuring documentation examples remain functional.
* refactor(mocks): add MSW handlers for examples E2E tests
- Add exampleBamboohrTools with list, get, and create employee tools
- Register example account IDs in MCP handlers
- Add OpenAI Responses API handler for employee lookup pattern
- Fix extractTextFromInput to handle plain string input
These mock handlers support the new E2E tests for example files.
* refactor(examples): reorganise dependencies and remove redundant index.ts
- Move runtime dependencies (openai, ai, @ai-sdk/openai) to dependencies
- Add msw to devDependencies for testing
- Remove unused zod dependency
- Add vitest/globals types for test file support
- Delete redundant index.ts (duplicates fetch-tools.ts functionality)
The dependency reorganisation reflects actual usage: runtime deps are
used by example scripts, while msw is only needed for testing.
* refactor(vitest): consolidate setupFiles and simplify coverage config
- Move setupFiles to root level (inherited via extends: true)
- Limit coverage to src/**/*.ts only (examples are documentation)
- Remove redundant per-project setupFiles configuration
The setupFiles change reduces duplication since both root and examples
projects use the same MSW setup. Coverage excludes examples since they
are documentation files, not library code.
* chore: update knip config and package.json
- Add *.test.ts to examples entry points in knip config
- Remove lefthook from ignoreDependencies (no longer needed)
- Add examples/*.ts to package.json files for distribution
- Exclude example test files from distribution
* feat(deps): add TanStack AI and Claude Agent SDK to examples catalog
- Create new 'examples' catalog for example-specific dependencies
- Add @tanstack/ai and @tanstack/ai-openai for TanStack AI integration
- Add @anthropic-ai/claude-agent-sdk for Claude Agent SDK integration
- Configure minimumReleaseAgeExclude for newly released packages
- Update examples/package.json to use catalog:examples references
* feat(examples): add TanStack AI integration example and tests
- Add tanstack-ai-integration.ts demonstrating StackOne tools with TanStack AI
- TanStack AI requires Zod schemas for tool input validation
- Add E2E tests for tool setup and direct execution
- The adapter reads OPENAI_API_KEY from environment automatically
* feat(examples): add Claude Agent SDK integration example and tests
- Add claude-agent-sdk-integration.ts demonstrating StackOne tools with Claude Agent SDK
- Create custom MCP server using createSdkMcpServer() with StackOne tools
- Wrap StackOne tools using tool() function with Zod schemas
- Add E2E tests for tool wrapper, MCP server creation, and direct execution
- Note: Actual query execution requires ANTHROPIC_API_KEY and claude-code installation
* docs(examples): clarify AI SDK agent pattern in comments
- Document that stepCountIs() creates an agent-like multi-step tool loop
- Reference AI SDK v6+ ToolLoopAgent for explicit agent functionality
* docs(readme): add TanStack AI and Claude Agent SDK integration examples
- Add TanStack AI integration section with Zod schema example
- Add Claude Agent SDK integration section with MCP server example
- Remove obsolete link to deleted examples/index.ts
* docs:1 parent 134b0c2 commit e890de1
File tree
27 files changed
+1506
-280
lines changed- examples
- mocks
- src
27 files changed
+1506
-280
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
116 | 210 | | |
117 | 211 | | |
118 | 212 | | |
| |||
128 | 222 | | |
129 | 223 | | |
130 | 224 | | |
131 | | - | |
132 | | - | |
133 | 225 | | |
134 | 226 | | |
135 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
3 | 11 | | |
4 | 12 | | |
5 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
0 commit comments