feat(agent): add server entry, complete pipeline, and Brave client tests#20
Open
macan88 wants to merge 3 commits intolangoustine69:mainfrom
Open
feat(agent): add server entry, complete pipeline, and Brave client tests#20macan88 wants to merge 3 commits intolangoustine69:mainfrom
macan88 wants to merge 3 commits intolangoustine69:mainfrom
Conversation
7 tasks
Author
|
Hi 👋 Just checking in on this PR — the implementation is complete and the branch is clean/ready to merge. Happy to address any feedback if needed! Thanks! |
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
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.
Problem
The repository had no server entry point (
src/index.ts), leaving the four required HTTP endpoints unimplemented and the Brave/rank/synth logic disconnected from any transport. Additionally, the existing logic files lacked test coverage, making correctness unverifiable.Solution
Added
src/index.tswhich bootstraps a Hono server, wires the shared in-memory cache, and implements all four endpoints (GET /health,GET /v1/search,GET /v1/search/news,POST /v1/search/deep) by composingbraveSearch → rank → synthesisein sequence. The deep-search endpoint fetches web and news results in parallel then merges before ranking, maximising source diversity. A.env.exampledocuments all required environment variables. Focused unit tests forbrave.tscover the web-result normalisation contract, news-result normalisation, the 429 →BraveRateLimitErrorerror path, and the fast-fail behaviour whenBRAVE_API_KEYis absent — all using inlinefetchmocks so no real network calls are made.Testing
src/logic/brave.test.tswith 4 focused cases (web normalisation, news normalisation, rate-limit error, missing-key fast-fail)bun test src/logic/brave.test.tsBRAVE_API_KEY=x OPENAI_API_KEY=y bun run src/index.tsthencurl localhost:3000/healthCloses #1