Architecture
proto is organized as an npm workspace with the main work split between two packages: cli and core.
Package structure
packages/
├── cli/ # Terminal UI and user interaction
├── core/ # Backend: API client, tools, subagents, memory
├── sdk-typescript/ # TypeScript SDK (@protolabsai/sdk)
├── test-utils/ # Shared testing utilities
├── vscode-ide-companion/ # VS Code extension
├── webui/ # Web UI components
└── zed-extension/ # Zed editor extensionCore components
packages/cli
Handles all user-facing concerns:
- Input processing — text prompts, slash commands (
/help,/model),@fileincludes,!shellcommands - History management — conversation history, session resumption
- Rendering — syntax highlighting, themes, terminal formatting
- Configuration — loads settings files, environment variables, CLI flags
packages/core
The backend engine:
- API client — communicates with any OpenAI-compatible, Anthropic, or Gemini endpoint
- Prompt construction — builds messages with conversation history, tool schemas, and memory context
- Tool registry — registers built-in and MCP tools; executes them on model request
- Sub-agent system — spawns sub-agents with filtered tool sets and independent
AgentCoreinstances - Memory system — loads and saves per-session and persistent memory files
- Session management — tracks state, chat recording, session IDs
Tools (packages/core/src/tools/)
Individual modules for file system, shell, web fetch/search, LSP, MCP, task management, and more. Each tool has a schema (sent to the model) and an executor (invoked on model request).
Agent harness (packages/core/src/services/)
Safety and reliability services that wrap every sub-agent execution. See Explanation → Agent Harness for details.
Interaction flow
- User input →
packages/cliparses it - cli → core — the request is sent to
AgentCore - Core → API — constructs prompt + tool schemas, sends to model
- Model response — may be a text answer or a tool call request
- Tool execution — core validates the call, confirms with user if needed, executes, returns result to model
- Iteration — the model may make more tool calls before producing a final answer
- core → cli — final response sent back
- Rendering — cli formats and displays the response
Sub-agent isolation
When a sub-agent is spawned via the task tool:
- A new
AgentCoreinstance is created with an independent context and conversation - The tool set is filtered to the agent’s
toolsallowlist (or inherits all tools if no allowlist) - The sub-agent runs to completion and returns its final message
- The result is injected back into the parent’s tool-result stream
Sub-agents do not share state with their parent except through the tool result. The coordinator agent can spawn multiple sub-agents in parallel using run_in_background: true.
Configuration layers
Settings cascade from system defaults → user (~/.proto/settings.json) → project (.proto/settings.json) → environment variables → CLI flags. See Reference → Settings for the full precedence table.
SDK
packages/sdk-typescript wraps the CLI binary with a streaming async iterable interface. See Contributing → TypeScript SDK and Reference → SDK API.