-
Notifications
You must be signed in to change notification settings - Fork 10
feat(ai-proxy): add HTTP client for frontend and agent-client usage #1436
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
base: main
Are you sure you want to change the base?
Conversation
2 new issues
|
657874e to
87fbd66
Compare
|
Coverage Impact This PR will not change total coverage. 🚦 See full report on Qlty Cloud »🛟 Help
|
c3a1199 to
544d9ee
Compare
Add AiProxyClient class with a clean, UX-friendly API: - chat(input): accepts a simple string or ChatInput object - getTools(): list available remote tools - callTool(name, inputs): execute a specific tool API improvements: - Simplified chat() that accepts just a string for common use cases - Consistent camelCase naming (toolChoice, aiName) - Renamed apiKey (more generic than openAiApiKey) - Clear method names: chat(), getTools(), callTool() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
544d9ee to
ba3bcac
Compare
Create a single source of truth for API types by introducing routes.ts. This file defines types for all routes (ai-query, invoke-remote-tool, remote-tools) and is imported by both server and client code. - Add src/routes.ts with shared OpenAI and route types - Update router.ts to use AiQueryRequest and InvokeToolRequest - Update provider-dispatcher.ts to import from routes.ts - Update remote-tools.ts to use RemoteToolDefinition - Update client/types.ts to re-export from routes.ts - Maintain backwards compatibility with legacy type aliases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The dependency is only used for type imports (Logger type), so it doesn't need to be installed by consumers at runtime. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove legacy type exports (DispatchBody, ChatCompletionResponse, etc.) since there are no external consumers yet. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Object.setPrototypeOf for proper Error subclass behavior - Add cause property to preserve original error stack traces - Add error categorization helpers (isNetworkError, isClientError, isServerError) - Fail fast when auth required but no apiKey configured - Handle JSON parse errors on successful responses properly - Add request context (method, path) to all error messages - Add tests for edge cases: both json/text fail, non-Error exceptions, invalid JSON on success, error cause preservation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Not needed since Node 18+ is the minimum supported version. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Better reflects that this file contains type definitions, not routing logic. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Authentication is handled at a different layer. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
AiProxyClientConfig now uses a union type where fetch and baseUrl are
mutually exclusive:
- Custom fetch mode: { fetch, timeout? }
- Simple mode: { baseUrl, headers?, timeout? }
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Document mutually exclusive config modes (baseUrl vs fetch) - Remove outdated apiKey references - Add complex tool example with nested objects, arrays, and enums - Document error categorization helpers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Quick Start section at the top - Remove redundant API Reference and TypeScript sections - Simplify error handling documentation - Focus on time-to-first-success Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use toBeInstanceOf(AiProxyClientError) instead of toMatchObject - Add return value assertions to all tests - Add tests for default timeout (30s) - Add tests for empty aiName - Add tests for URL encoding special characters in aiName/toolName - Add tests for custom headers overriding Content-Type - Add tests for concurrent requests with independent abort signals - Replace expect.anything() with specific assertions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Summary
AiProxyClientclass with a clean, UX-friendly API to interact with ai-proxy from frontend or agent-client@forestadmin/ai-proxy/client- zero dependenciesLangchain packages are now optional peer dependencies. Users of the server-side features (Router, ProviderDispatcher) must install them manually:
Users who only use the client don't need to install anything extra.
API
Package Structure
@forestadmin/ai-proxy@forestadmin/ai-proxy/clientTest plan
🤖 Generated with Claude Code