# cosmicstack-labs/mercury-agent — AlpLab Radar Static Code Audit

- Ring: `adopt`
- Category: `agents`
- Overall score: `3.8/5`
- Implementation check: `verified`
- Maturity: `active`
- Audited commit: `0e55a5e4d624` (read-only; nothing from the repository was executed)
- Reviewed at: 2026-11-30T12:43:25Z
- Repository: https://github.com/cosmicstack-labs/mercury-agent
- Radar entry: https://radar.alplab.co/#repo/cosmicstack-labs/mercury-agent
- License: `MIT`
- CI workflows: `.github/workflows`
- Tags: `ai-agent`, `personal-assistant`, `permissions`, `memory`, `telegram`, `ssrf`

## Summary

A local-first personal AI agent runtime (Node/TypeScript) with a permission-hardened tool layer, SQLite 'Second Brain' memory, token budgets, and Telegram/Discord/Slack/Signal/web/CLI channels, shipped as npm package and standalone binaries.

## Implementation Check

The headline claims are implemented in code, not just described: permission system (src/capabilities/permissions.ts: fs scopes with symlink/hardlink TOCTOU checks, argv vs approval shell lanes, fail-closed bot mode), non-overridable shell blocklist (src/capabilities/shell/blocklist.ts incl. PowerShell variants), SSRF guard with DNS fail-closed + address pinning + per-hop redirect validation (src/utils/ssrf.ts) wired into fetch_url/install_skill/web-search/MCP/plugins, secret redaction (src/utils/redact.ts + src/utils/logger.ts pino serializer), SQLite+FTS5 memory (src/memory/second-brain-db.ts, src/utils/sqlite-driver.ts), and real channel implementations (src/channels/telegram.ts 74KB, discord.ts 44KB, slack.ts 31KB, signal.ts 37KB).

## When to Use

Reach for it when you want an always-on personal agent you talk to from chat channels, with explicit approval gates and local memory — and you accept reviewing what it does in Allow All mode. Not for enterprise/managed fleet use, and not if you need an audited OS-level sandbox rather than an in-process permission layer.

## Sub-scores

| Dimension | Score |
|---|---|
| quality | 4.0/5 |
| usability | 4.0/5 |
| reliability | 3.0/5 |
| security | 4.0/5 |
| integration | 4.0/5 |

## Code Evidence

src/utils/ssrf.ts implements loopback/RFC1918/link-local/metadata blocking, fail-closed on mixed DNS answers, pinned-address connect (DNS rebinding defense) and manual-redirect re-validation — matching docs/security/ssrf-108-response.md, a fixed responsible-disclosure (#108). src/capabilities/shell/run-command.ts routes auto-approved commands through execFile with minimal env and redacts echoed output; git helpers are tested to never use execSync (src/capabilities/git/git-helpers.test.ts). Test coverage is unusually deep for this category (src/capabilities/permissions.test.ts 48KB, src/bots/bot-manager.test.ts 69KB, ssrf/blocklist/argv-lane suites) and .github/workflows/ci.yml runs a 4-OS typecheck/test matrix, binary smoke, installer dry-runs against a fake release with checksum-tamper tests, an eval harness, and a Termux job. SECURITY.md documents a real disclosure process and the argv/approval lane threat model honestly, including what it does not cover.

## Issues Found

Monolithic hotspots hurt maintainability: src/core/agent.ts (364KB), src/index.ts (245KB), src/bots/bot-manager.ts (132KB), src/channels/cli.ts (127KB). The npm publish CI job is commented out as broken (.github/workflows/ci.yml 'TEMPORARILY DISABLED'), so releases lean on the separate release.yml. Both package-lock.json and pnpm-lock.yaml are committed (mixed package-manager hygiene). The docs/ directory carries a full built website (several MB of HTML/JS) inside the repo. docs/js/plausible-init.js is website-only analytics; the agent runtime itself shows no telemetry.

## Key Risks

Nothing was executed, so no behavior is proven to work — only what the code shows (hence reliability stays at 3). Release binaries are unsigned per README. The project's own docs flag that scheduled tasks run Allow All for their turn (weakest point) and that community skills are unaudited. The reviewed X post ('custom habitat engine') describes something that appears nowhere in this repo — treat it as unrelated marketing. Token budget and provider keys mean cost and key handling are user responsibilities.

## Reviewed Files

- `README.md`
- `package.json`
- `.env.example`
- `.github/workflows/ci.yml`
- `SECURITY.md`
- `docs/security/ssrf-108-response.md`
- `src/utils/ssrf.ts`
- `src/utils/redact.ts`
- `src/utils/logger.ts`
- `src/utils/sqlite-driver.ts`
- `src/capabilities/permissions.ts`
- `src/capabilities/shell/blocklist.ts`
- `src/capabilities/shell/run-command.ts`
- `src/capabilities/web/fetch-url.ts`
- `src/capabilities/skills/install-skill.ts`
- `src/memory/second-brain-db.ts`
