feat: merge types and add tests (#10)

* feat: merge types and add tests

- Merged types.ts and tracker.ts
- Added Jest configuration and setup
- Added comprehensive tests for tools and agent
- Updated package.json with test scripts

Co-Authored-By: Han Xiao <han.xiao@jina.ai>

* chore: remove tracker.ts after merging into types.ts

Co-Authored-By: Han Xiao <han.xiao@jina.ai>

* fix: remove sensitive API keys from jest.setup.js

Co-Authored-By: Han Xiao <han.xiao@jina.ai>

* fix: improve error handling and test timeouts

Co-Authored-By: Han Xiao <han.xiao@jina.ai>

* feat: add token budget enforcement to TokenTracker

Co-Authored-By: Han Xiao <han.xiao@jina.ai>

* feat: add github actions workflow for CI and fix remaining issues

Co-Authored-By: Han Xiao <han.xiao@jina.ai>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Han Xiao <han.xiao@jina.ai>
This commit is contained in:
devin-ai-integration[bot]
2025-02-03 18:01:59 +08:00
committed by GitHub
parent bd8e9ff1d4
commit 76f8cd242a
20 changed files with 3680 additions and 32 deletions

View File

@@ -0,0 +1,20 @@
import { getResponse } from '../agent';
describe('getResponse', () => {
it('should handle search action', async () => {
const result = await getResponse('What is TypeScript?', 1000);
expect(result.result.action).toBeDefined();
expect(result.context).toBeDefined();
expect(result.context.tokenTracker).toBeDefined();
expect(result.context.actionTracker).toBeDefined();
});
it('should respect token budget', async () => {
try {
await getResponse('What is TypeScript?', 100);
fail('Expected token budget error');
} catch (error: any) {
expect(error.message).toContain('Token budget exceeded');
}
});
});