feat: add nansen web search and nansen web fetch commands (ECINT-6393)#295
feat: add nansen web search and nansen web fetch commands (ECINT-6393)#295
nansen web search and nansen web fetch commands (ECINT-6393)#295Conversation
…6393) - POST /api/v1/search/web-search — parallel web search via Serper - POST /api/v1/search/web-fetch — fetch + AI analysis of URLs via Gemini - Both commands accept positional args or --query/--url flags - web-search: supports --num-results (1-20, default 10) - web-fetch: requires --question for AI analysis prompt - Updated schema.json, HELP banner, telemetry tracking tests, changeset
pr-reviewer Summary📝 2 findings Review completed. Please address the findings below. Findings by Severity
Review effort: 3/5 (Moderate) SummaryThis PR adds Findings
|
src/cli.js
Outdated
| trade quote, execute | ||
| wallet create, list, show, export, default, delete, forget-password | ||
| alerts list, create, update, toggle, delete | ||
| web-search Search the web for one or more queries |
There was a problem hiding this comment.
💭 How about web with web search and web fetch?
Per Tim's feedback: replace flat top-level `web-search`/`web-fetch` commands
with a `web` group: `nansen web search` / `nansen web fetch`.
Also adds --num-results range validation (1-20) with INVALID_PARAM error for
out-of-range values (previously passed through to API silently).
Changes:
- src/cli.js: `web` handler with `search` and `fetch` subcommands; range check
- src/schema.json: `web.subcommands.{search,fetch}` structure
- src/__tests__/cli.internal.test.js: updated tests + 2 new range tests
- src/__tests__/telemetry-tracking.test.js: updated command references
- skills/nansen-web-{search,fetch}/SKILL.md: updated command syntax
0xlaveen
left a comment
There was a problem hiding this comment.
Nice clean PR! Tested the tools end-to-end and everything works well. A few minor nits for polish:
1. Empty string query passes client validation
nansen web search "" passes the queries.length === 0 check (length is 1) and gets a 422 from the API. Suggestion: queries = queries.filter(q => q.trim()) before the length check.
2. Invalid URLs not validated client side
nansen web fetch "not-a-url" --question "test" passes the CLI and gets a generic 422. A quick new URL(u) try/catch or startsWith('http') guard would give a clearer local error.
3. Wrong error code for --num-results out of range
nansen web search "test" --num-results 0 returns "code":"UNKNOWN" instead of INVALID_PARAM. The throw uses ErrorCode.INVALID_PARAM but it maps to UNKNOWN in the output. Minor since the message is clear, but worth fixing for programmatic consumers.
4. Whitespace only --question passes validation (API side)
The question field uses min_length=1 which only checks character count. " " (spaces) passes validation, burns a Gemini API call, and returns a useless response. Fix: add strip_whitespace=True to the Pydantic field, or a custom validator that strips then checks length. One liner.
- Filter empty/whitespace queries before length check so 'nansen web search ""' fails with a clear error - Add client-side URL validation via new URL() to catch bare strings like 'not-a-url' before hitting the API - Fix ErrorCode.INVALID_PARAM → ErrorCode.INVALID_PARAMS (trailing s) for --num-results range check - Validate --question is not blank/whitespace-only (client-side guard) - Add 6 new tests covering the above cases (371 total, all passing)
nansen web-search and nansen web-fetch commands (ECINT-6393)nansen web search and nansen web fetch commands (ECINT-6393)
- Remove 'Internal-only endpoint' from both skill descriptions - Update web-fetch reference in nansen-web-search SKILL.md to use correct 'nansen web fetch' command syntax
Summary
Adds two new top-level CLI commands backed by the internal
/api/v1/search/web-searchand/api/v1/search/web-fetchendpoints.Commands
nansen web-searchnansen web-fetchChanges
src/api.js—webSearch()andwebFetch()API methodssrc/cli.js— command handlers + HELP banner entries + NaN guard for--num-resultssrc/schema.json— command metadataskills/nansen-web-search/SKILL.md— agent skill fileskills/nansen-web-fetch/SKILL.md— agent skill filesrc/__tests__/cli.internal.test.js— 18 new tests covering all parameter combinations (incl. NaN guard)src/__tests__/telemetry-tracking.test.js— telemetry coverage for both commands.changeset/add-web-search-web-fetch.md— minor version bumpTest output
Closes ECINT-6393