-
-
Notifications
You must be signed in to change notification settings - Fork 32
AGENTS
CortexPrism is an open-source agentic harness system built on Deno 2.x + TypeScript strict mode. It hosts, orchestrates, and empowers AI agents with memory, tools, sandboxed code execution, a web UI, reflection, model routing, and layered security.
# Type-check — must exit 0 before any PR
deno task check
# Lint
deno task lint
# Format (auto-fixes)
deno task fmt
# Run all tests
deno task test
# Run a single test file
deno test --allow-all tests/<file>_test.ts
# Run check + lint + fmt in one shot
deno task check && deno task lint && deno task fmtdeno task dev # Interactive chat (dev mode)
deno task serve # HTTP + WebSocket server on :3000
deno task daemon # Run background supervisor (foreground)
deno task migrate # Apply all pending DB migrationssrc/
main.ts # CLI entry point — all commands registered here
cli/ # One file per CLI sub-command
agent/ # Agent loop, reflection, sub-agents, soul (system prompt)
tools/ # Tool registry, executor, types
builtin/ # All built-in tools (file ops, shell, web, code exec, etc.)
workspace/ # File-system tools with undo/redo
db/ # DB client (libsql wrapper), migrations, session store
migrations/ # NNN_description.sql — never edit applied migrations
llm/ # LLM provider adapters (one file per provider)
memory/ # 5-tier memory: episodic, semantic, reflection
security/ # Policy validator, vault (AES-256-GCM), CPL
server/ # HTTP + WebSocket server, router, Web UI HTML
channels/ # Channel adapters (Discord, etc.)
plugins/ # Plugin loader, registry, sandbox, WASM runtime
workflow/ # Workflow engine
skills/ # Built-in skill definitions (Deno modules)
scheduler/ # SQLite-persisted cron
ipc/ # Inter-process communication (validator ↔ executor)
processes/ # Long-running process entry points (daemon workers)
services/ # Micro-service registry + lifecycle
workspace/ # Per-agent workspace paths + git integration
config/ # PATHS constant, version, config schema
model-quartermaster/ # Intelligent LLM selection (MQM)
remote/ # Distributed node (Hub ↔ Node) infrastructure
eval/ # Agent evaluation runner
voice/ # TTS/STT voice pipeline
sandbox/ # Code execution sandbox (Docker / subprocess)
tui/ # Terminal UI (ink-style)
hub/ # Hub coordination layer
mcp/ # MCP server (stdio)
observability/ # Cortex Lens audit log
quartermaster/ # Legacy model router
triggers/ # Trigger system
pipeline/ # Pipeline hook engine
desktop/ # Tauri desktop app entry
tests/ # Deno test files (*_test.ts)
docs/ # Design specs and install guides
.kilo/ # Kilo Code agent plans and specialist agent configs
-
Strict mode — no implicit
any, no!non-null assertions without a comment justifying why -
Async-first — prefer
async/awaitover raw Promise chains -
Fire-and-forget — background tasks (memory write, reflection) use
.catch(() => {})and never block a response - Error handling — catch at call-site boundaries; surface actionable error messages to the user
-
Never hardcode paths — always import
PATHSfromsrc/config/paths.ts - Data dir:
~/.cortex/data/(override viaCORTEX_DATA_DIR) - Config dir:
~/.cortex/(override viaCORTEX_CONFIG_DIR)
- SQL client:
Dbwrapper fromsrc/db/client.ts(libsql) - Migrations in
src/db/migrations/NNN_description.sql— idempotent, never edit once applied - Register new migrations in the
targetsarray insrc/db/migrate.ts
- No hardcoded credentials, API keys, or tokens anywhere in source
- Use
CORTEX_VAULT_KEYenv var; store secrets via the vault module (src/security/vault.ts) - Every tool call is gated through the policy validator (
src/security/validator.ts)
- Create
src/cli/your-cmd.tsexporting aCommandfrom@cliffy/command - Import and register it in
src/main.ts - Document it in
README.mdand add aCHANGELOG.mdentry
- Create
src/tools/builtin/your_tool.tsimplementing theToolinterface fromsrc/tools/types.ts - Register it in
src/tools/registry.ts - Add it to the WebSocket handler in
src/server/ws.tsif needed - Add a policy rule if it executes shell commands or makes network requests
- Create
src/db/migrations/NNN_description.sql(next sequential number) - Add an entry to the
targetsarray insrc/db/migrate.ts - Never edit a migration that has already been applied — create a new one instead
- Use
Deno.Command, neverDeno.run(deprecated)
Always run all three verification steps before staging and committing:
deno task check && deno task lint && deno task fmt-
deno fmtauto-fixes formatting (including markdown in CHANGELOG.md). - If
deno fmtmodified files, re-stage them before committing. - Never skip
deno fmt— CI will reject unformatted files.
Conventional commits:
feat: add discord channel adapter
fix: handle empty response from Ollama
docs: update CLI reference for vault command
chore: bump deno.json dependencies
refactor: extract policy evaluation into pure function
test: add workspace path traversal cases
Anthropic, OpenAI, Google Gemini, Mistral, Groq, DeepSeek, OpenRouter, xAI, Together AI, AWS Bedrock, Cohere, Ollama, Kilo, Cerebras, Fireworks, Perplexity, NVIDIA, Moonshot, Novita, LM Studio, LiteLLM, HuggingFace, Alibaba, Venice (24 total). Provider adapters live in src/llm/.
| File | Purpose |
|---|---|
cortex.db |
Core: sessions, jobs, policies, nodes, services |
memory.db |
5-tier memory (episodic, semantic, reflection, graph) |
lens.db |
Cortex Lens audit log |
vault.db |
Encrypted credential vault |
plugins.db |
Plugin registry |
Dependencies are declared in deno.json under "imports". Key packages:
-
@cliffy/command,@cliffy/prompt— CLI framework -
@std/assert,@std/path,@std/fs,@std/fmt,@std/datetime— Deno standard library -
npm:@anthropic-ai/sdk,npm:openai,npm:@google/generative-ai,npm:@aws-sdk/client-bedrock-runtime— LLM SDKs -
npm:@libsql/client— SQLite/libSQL client
CortexPrism — Open-source agentic AI harness · MIT License · Built with Deno 2.x + TypeScript
- Agent Loop
- Metacognition
- Memory System
- Skills System
- Sub-Agents
- Built-in Tools
- Code Intelligence
- Code Sandbox
- Cross-Agent Context Protocol
- Prompt Lab
- PKM Assistant
- Voice Pipeline
- Computer Use
- Browser Tool
- Git & GitHub
- Scheduler & Jobs
- Dashboard
- Observability
- A2A Protocol
- MCP Gateway
- Distributed Nodes
- Memori Checkpoints
- Eval System
- Workflow Engine
- Triggers
- Projects
- TUI
- Glossary
- Update System