Last verified: 2026-01-20 (Grounding: 2026-01-20)
Agent Zero now operates as the L5 Protocol Bridge for the terminals.tech ecosystem.
- L1 (Core):
SignalandTokennow supportshapeHash(deterministic structural fingerprints). - L2 (Machine):
HVMClientprovides symbolic steering via logit bias mapping. - L3 (Mesh):
ResearchAgentemits isomorphicMeshEventformatted tokens. - L4 (Brain): Research cycles use
CognitiveContextprimitives. - L5 (Protocol): MCP implementation serves as the bridge between terminals.tech and external models.
- Node 25 Auto-Heal:
dbClient.jsautomatically enables "Resilient In-Memory Mode" on Node 25/macOS to prevent WASM mutex crashes. - Isomorphic Reduction: All signals are now reduced to deterministic hashes for structural integrity verification.
- High-Fidelity Ensemble:
HYPER_MODEenabled withENSEMBLE_SIZE=3for high-fidelity technical research.
Install:
npm install
Run server (STDIO default for MCP clients):
npm startnpm run stdio
Dev (watch):
npm run dev
Tests (unit + auth + config):
npm test
Single test (direct node entrypoints):
node tests/unit/core.test.jsnode tests/unit/config.test.jsnode tests/unit/auth.test.jsnode tests/integration/orchestration/mic-drop.test.jsDRY_RUN=true node tests/integration/orchestration/mic-drop.test.js
Note: Some tests use Jest APIs (describe, test, expect) but are not
wired into npm test. Run them directly with node only if they do not
require a Jest runner. If a test uses Jest globals, install/run Jest locally.
Docs generation:
npm run gen:docsnpm run gen:examplesnpm run gen:diagram
src/server/MCP server, tool registration, handlers, transports.src/agents/research, planning, zero protocol, context agents.src/core/core abstractions: signal, rail, context, normalize.src/utils/infra helpers: logging, errors, db, diagnostics.tests/unit + integration tests (mostly node scripts).docs/product docs and guides.
Language: Node.js (CommonJS modules), no TypeScript.
- Use
const x = require('module'). - Group core/third-party imports before local modules.
- Keep import lists tidy; avoid deep destructuring unless used.
- 2-space indentation.
- Single quotes for strings.
- Semicolons are used consistently.
- Blank lines separate logical sections.
- Align multi-line object literals for readability.
- Files: lowerCamelCase for JS modules (
openRouterClient.js). - Classes: PascalCase (
MCPLogger,Signal). - Functions/vars: lowerCamelCase (
formatActionableError). - Constants/enums: UPPER_SNAKE_CASE or Capitalized objects (
LogLevel).
- Prefer runtime validation via Zod schemas for tool inputs.
- Use structured error types (see
src/utils/errors.js). - Return plain objects for tool outputs; avoid classes in API boundaries.
Use the Semantic Error Taxonomy (src/core/errors/) for all error handling:
const errors = require('./src/core/errors');
// Wrap any error for semantic classification
const semantic = errors.wrapError(rawError);
// → { category, severity, tripDecision, suggestedFix }
// Record to trace history (auto-persists to DB)
await errors.recordTrace(error, { operation: 'research' }, sessionId);
// Export full state for debugging
const state = errors.exportTaxonomyState();Error Categories and Circuit Breaker Decisions:
| Category | Trip on... | Action |
|---|---|---|
network |
3 errors/min | Trip circuit |
rate_limit |
Any occurrence | Always trip |
auth, config, resource |
Any occurrence | Escalate (fatal) |
timeout, execution |
3-5 errors/min | Trip circuit |
validation, schema, not_found |
Never | Ignore (client error) |
unknown |
10 errors/min | Trip after threshold |
Best Practices:
- Wrap errors with
wrapError()or throwSemanticError - Record all errors with
recordTrace()for debugging - Use
exportTaxonomyState()for AI-assisted improvement - Learn new patterns with
learnPattern(pattern, category, severity) - Check
error_tracetable in DB for historical analysis
Self-Improvement Loop:
Errors are auto-classified and persisted. When an unknown error appears frequently,
suggestedPattern is generated. AI/operators can review traces and teach new patterns
that will be applied to future errors automatically.
- Use
src/utils/logger(structured, MCP-compliant). - Respect
LOG_LEVEL,LOG_OUTPUT, and--stdiobehavior. - Avoid writing to stdout in STDIO mode.
- Prefer async/await; avoid unhandled promises.
- Use explicit timeouts when hitting external services.
- Read from
config.jsandsrc/config/*. - Do not inline env access in feature modules unless necessary.
- Always handle missing config with actionable errors.
- Unit tests are plain Node scripts using
assert. - Integration test
mic-dropcan be dry-run withDRY_RUN=true. - When adding tests, match the existing pattern (standalone runner).
- No ESLint/Prettier config is present.
- Keep formatting consistent with existing files.
- Update
README.mdanddocs/CHANGELOG.mdif behavior changes. - Follow
.github/pull_request_template.mdchecklist when preparing PRs.
- No
.cursor/rules/,.cursorrules, or.github/copilot-instructions.mddetected in this repository.
- MCP tools and schemas live in
src/server/tools.jsandsrc/config/schema.js. - Protocol features (Task/Sampling/Elicitation/Rail) are centralized in
src/server/*andsrc/core/rail/*. - Maintain structured diagnostics in
src/utils/diagnosticsand actionable error returns insrc/utils/errors.
Think of the codebase as a layered, isomorphic pipeline:
- Inputs: External requests (HTTP/STDIO) or internal agent tasks.
- Normalization: Parameter normalization + schema validation.
- Execution: Tool handlers + core abstractions (Signal/Rail/Context).
- Persistence: DB + indexers + knowledge graph.
- Outputs: Structured responses + logs + notifications.
Each layer transforms data but preserves shape: a request becomes a validated tool call; a tool call yields a structured response; errors are always wrapped into MCPError-compatible forms. This symmetry is the isomorphic “abstraction” agents should preserve when adding new capabilities.
- Place new tool handlers in
src/server/handlers/with Zod schemas. - Wire new tools in
src/server/tools.jsand expose viamcpServer.js. - Keep error paths explicit and structured (retryable vs terminal).
- Avoid global state; use lazy init for integrations.