Runtime Module Dependency Diagram
The `@agenc/runtime` package (~90k lines) is organized into 7 dependency layers. Modules may only depend on modules in the same or lower layers.
Runtime Module Dependency Diagram
The @agenc/runtime package (~90k lines) is organized into 7 dependency layers. Modules may only depend on modules in the same or lower layers.
Layer Diagram
| Layer | Modules |
|---|---|
| 7 β API Surface | runtime.ts, builder.ts, idl.ts, index.ts |
| 6 β Specialized | policy/, team/, marketplace/, eval/, replay/, telemetry/ |
| 5 β Workflow | workflow/ β DAGOrchestrator, GoalCompiler, Optimizer |
| 4 β Autonomous | autonomous/ β AutonomousAgent, Scanner, Verifier |
| 3 β Task + AI | task/, memory/, skills/, tools/, llm/ |
| 2 β Core | agent/, proof/, events/, dispute/, connection/ |
| 1 β Foundation | types/, utils/ |
Dependency Flow
Modules may only depend on modules in the same or lower layers. Key cross-layer dependencies:
| From | To | Connection |
|---|---|---|
runtime.ts | autonomous/, agent/, connection/, telemetry/ | Lifecycle wrapper |
builder.ts | llm/, memory/, proof/, tools/, connection/ | Fluent composition |
autonomous/ | task/, llm/, proof/, tools/, events/ | Integration point |
workflow/ | task/, llm/ | DAG orchestration |
task/ | agent/, events/, connection/ | Task operations |
agent/, proof/, events/ | types/, utils/ | Foundation imports |
Module Summary
Layer 1: Foundation
| Module | Primary Export | Error Codes | Tests |
|---|---|---|---|
types/ | RuntimeError, RuntimeErrorCodes, WalletAdapter | 1-37 (all) | ~50 |
utils/ | toUint8Array, Logger, derivePda, fetchTreasury, ensureLazyModule | β | ~30 |
Layer 2: Core
| Module | Primary Export | Error Codes | Tests |
|---|---|---|---|
agent/ | AgentManager, AgentCapabilities | 1-5 | ~80 |
proof/ | ProofEngine | 25-27 | ~37 |
events/ | EventMonitor, event type parsers | β | ~40 |
dispute/ | DisputeOperations | 28-31 | ~56 |
connection/ | ConnectionManager | 36-37 | ~45 |
Layer 3: Task + AI
| Module | Primary Export | Error Codes | Tests |
|---|---|---|---|
task/ | TaskOperations, TaskDiscovery, SpeculativeExecutor | 6-12 | ~120 |
memory/ | InMemoryBackend, SqliteBackend, RedisBackend | 22-24 | ~105 |
skills/ | SkillRegistry, JupiterSkill | β | ~30 |
tools/ | ToolRegistry, createAgencTools, skillToTools | β | ~60 |
llm/ | GrokProvider, OllamaProvider, LLMTaskExecutor | 17-21 | ~80 |
Layer 4: Autonomous
| Module | Primary Export | Error Codes | Tests |
|---|---|---|---|
autonomous/ | AutonomousAgent, TaskScanner, VerifierScheduler | 13-16 | ~150 |
Layer 5: Workflow
| Module | Primary Export | Error Codes | Tests |
|---|---|---|---|
workflow/ | DAGOrchestrator, GoalCompiler, WorkflowOptimizer | 32-35 | ~100 |
Layer 6: Specialized
| Module | Primary Export | Error Codes | Tests |
|---|---|---|---|
policy/ | PolicyEngine | β | ~40 |
team/ | TeamContractEngine, computeTeamPayout | β | ~50 |
marketplace/ | TaskBidMarketplace, bid strategies | β | ~60 |
eval/ | BenchmarkRunner, MutationRunner | β | ~80 |
replay/ | ReplayStore, ReplayProjector, IncidentReconstructor | β | ~70 |
telemetry/ | UnifiedTelemetryCollector, NoopTelemetryCollector | β | ~30 |
Layer 7: API Surface
| Module | Primary Export | Description |
|---|---|---|
runtime.ts | AgentRuntime | Lifecycle wrapper (start/stop) |
builder.ts | AgentBuilder | Fluent composition API |
idl.ts | IDL, createProgram, createReadOnlyProgram | IDL and Program factories |
index.ts | All public exports | Barrel re-exports (~920 lines) |
Dependency Rules
- No circular dependencies β modules only import from same or lower layers
- Foundation is pure β
types/andutils/have zero internal dependencies - Core modules are independent β modules in Layer 2 don't depend on each other (except
dispute/βagent/) - AI modules compose β
llm/usestools/,skills/provides tools,memory/is standalone - Autonomous wraps everything β
autonomous/is the integration point for task + LLM + proof - API surface is thin β
runtime.tsandbuilder.tsonly compose, never implement
Cross-Layer Communication
| Pattern | Example | Mechanism |
|---|---|---|
| Event-driven | Agent registration β EventMonitor callback | WebSocket subscription |
| Dependency injection | AgentBuilder β AutonomousAgent with LLM + tools | Constructor params |
| Shared utilities | All modules β fetchTreasury(), toUint8Array() | Direct import from utils |
| Interface contracts | ProofEngine implements ProofGenerator | TypeScript interface |
| Lazy loading | LLM adapters load SDKs on first use | ensureLazyModule() |