# yan-930521/supernova architecture

> Architecture diagram of the GitHub repository yan-930521/supernova, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yan-930521/supernova
- Repository: https://github.com/yan-930521/supernova

## Overview

1. **Project purpose**
   SuperNova is a TypeScript AI runtime prototype focused on separating **conversation state** from **execution state**. The architecture is built to keep long-running agent work from polluting the user-facing dialogue context.

2. **Top-level orchestration boundary**
   The core runtime appears to be centered on `src/runtime/GlobalRuntime.ts`, which likely wires together configuration, managers, storage, tools, and eventing. This is the main composition boundary of the system.

3. **Dual-state management**
   The README’s main architectural distinction is enforced in code by two manager families:
   - `SessionManager` for user conversation continuity
   - `TaskManager` for planning, execution, and task-graph state  
   This is the key separation to draw in any diagram.

4. **Domain model layer**
   `src/models` defines the shared data contracts: `Session`, `Task`, `TaskGraph`, `User`, `AgentState`, `Event`, and `MutationRequest`. These models are the canonical payloads passed between managers, agents, and storage.

5. **Agent hierarchy**
   `src/agent` contains `BaseAgent`, `MainAgent`, and `WorkerAgent`. The README describes a recursive orchestration model: `MainAgent` can directly interact with tools, delegate work to `WorkerAgent`, and even assign tasks to another `MainAgent` when needed.

6. **Planning and task decomposition**
   `src/task/TaskPlanner.ts` is the entry point for turning a goal into staged work. Combined with `TaskManager`, it supports milestone planning and incremental task expansion, matching the README’s “planning → review → expansion” flow.

7. **Task orchestration tools**
   `src/tool/core` contains the orchestration primitives: task create, assign, list, info, dispatch, and agent registration/listing. These are the internal control plane for the runtime, distinct from general-purpose tools.

8. **General-purpose tool layer**
   `src/tool/common` and `src/tool/file` provide the agent’s action surface:
   - reasoning/support tools like deep thinking, summarization, math, time, unit conversion, system info
   - external-data tools like search and web fetch
   - file operations for local workspace interaction
   - code execution for runtime work  
   This layer is what agents use to produce side effects or gather information.

9. **Event-driven coordination**
   `src/infra/EventBus.ts` is the main decoupling mechanism. The README explicitly calls out asynchronous event-based communication, so task completion, summary propagation, and state updates are probably mediated through events rather than direct manager coupling.

10. **Persistence and repository boundary**
   Persistence is filesystem-based for now:
   - `FileSystemUserRepository`
   - `FileSystemSessionRepository`
   - `FileSystemTaskRepository`
   - `FileSystemAgentRepository`  
   This indicates a symmetric repository pattern across core entities, with local file storage under `workspace` rather than a database.

11. **Infrastructure services**
   `src/infra` also includes `LogManager`, `HookRegistry`, `ModelRegistry`, and `MutationValidator`. These suggest cross-cutting services for observability, extensibility, model selection/registration, and safe state mutation validation.

12. **Configuration and prompt assets**
   Runtime behavior is driven by `src/config` plus prompt files under `prompts/`. Agent identities and behaviors are externalized in markdown prompts, while `agents/*.json` likely defines concrete agent profiles. This makes prompt behavior part of the architecture, not just content.

13. **Structured agent outputs**
   `src/schemas/agent/AgentOutputSchemas.ts` implies agent responses are validated as structured outputs, which supports the repository’s emphasis on controlled orchestration rather than free-form chat.

14. **Local execution and developer surface**
   `scripts/chat-demo.ts` is the visible entry point for experimenting with the runtime locally. `jest.config.js` and the TypeScript config indicate a Node.js-based development/runtime environment with test support, but the architectural center remains the agent runtime, not a web server.

15. **End-to-end flow to diagram**
   The main flow is: user goal enters a session, `SessionManager` records communication state, `TaskPlanner` decomposes the goal, `TaskManager` expands and dispatches tasks, agents execute tools, results are persisted and published on the event bus, and summaries are folded back into the session history. That loop is the core system behavior.

Main entry points: [`src/manager/TaskManager.ts`](https://github.com/yan-930521/supernova/blob/main/src/manager/TaskManager.ts) (Task manager), [`src/runtime/GlobalRuntime.ts`](https://github.com/yan-930521/supernova/blob/main/src/runtime/GlobalRuntime.ts) (Global runtime), [`src/agent/MainAgent.ts`](https://github.com/yan-930521/supernova/blob/main/src/agent/MainAgent.ts) (Main agent), [`src/tool/ToolRegistry.ts`](https://github.com/yan-930521/supernova/blob/main/src/tool/ToolRegistry.ts) (Tool registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime core"]
  node_global_runtime["Global runtime<br/>composition root<br/>[GlobalRuntime.ts]"]
  node_session_manager["Session manager<br/>conversation state<br/>[SessionManager.ts]"]
  node_task_manager["Task manager<br/>execution state<br/>[TaskManager.ts]"]
  node_session_model["Session<br/>domain model<br/>[Session.ts]"]
  node_config["Config<br/>[Config.ts]"]
end

subgraph group_execution["Agents and tasks"]
  node_task_planner["Task planner<br/>goal decomposition<br/>[TaskPlanner.ts]"]
  node_main_agent["Main agent<br/>orchestrator agent<br/>[MainAgent.ts]"]
  node_worker_agent["Worker agent<br/>execution agent<br/>[WorkerAgent.ts]"]
  node_base_agent["Base agent<br/>agent base<br/>[BaseAgent.ts]"]
  node_task_graph["Task graph<br/>domain model<br/>[TaskGraph.ts]"]
  node_task_model["Task<br/>domain model<br/>[Task.ts]"]
end

subgraph group_support["Infra and tools"]
  node_event_bus(("Event bus<br/>coordination bus<br/>[EventBus.ts]"))
  node_mutation_validator{{"Mutation validator<br/>state guard"}}
  node_log_manager["Log manager<br/>observability<br/>[LogManager.ts]"]
  node_task_repository[("Task repo<br/>filesystem persistence")]
  node_session_repository[("Session repo<br/>filesystem persistence")]
  node_agent_repository[("Agent repo<br/>filesystem persistence")]
  node_tool_registry["Tool registry<br/>tool catalog<br/>[ToolRegistry.ts]"]
  node_core_tools["Core tools<br/>orchestration tools"]
  node_common_tools["Common tools<br/>general tools"]
  node_file_tools["File tools<br/>workspace tools"]
end

subgraph group_assets["Prompts and profiles"]
  node_prompt_assets["Prompt assets<br/>prompt library"]
  node_agent_profiles["Agent profiles<br/>agent configs"]
end

node_global_runtime -->|"loads"| node_config
node_global_runtime -->|"wires"| node_session_manager
node_global_runtime -->|"wires"| node_task_manager
node_global_runtime -->|"wires"| node_tool_registry
node_global_runtime -->|"wires"| node_event_bus
node_global_runtime -->|"wires"| node_log_manager
node_session_manager -->|"stores"| node_session_model
node_session_manager -->|"persists"| node_session_repository
node_task_manager -->|"stores"| node_task_model
node_task_manager -->|"tracks"| node_task_graph
node_task_manager -->|"persists"| node_task_repository
node_task_manager -->|"validates"| node_mutation_validator
node_task_planner -->|"produces"| node_task_graph
node_main_agent -->|"extends"| node_base_agent
node_worker_agent -->|"extends"| node_base_agent
node_main_agent -->|"plans"| node_task_planner
node_main_agent -->|"delegates"| node_worker_agent
node_main_agent -->|"uses"| node_tool_registry
node_worker_agent -->|"uses"| node_tool_registry
node_tool_registry -->|"contains"| node_core_tools
node_tool_registry -->|"contains"| node_common_tools
node_tool_registry -->|"contains"| node_file_tools
node_core_tools -->|"controls"| node_task_manager
node_core_tools -->|"reads"| node_agent_repository
node_event_bus -->|"publishes"| node_session_manager
node_event_bus -->|"publishes"| node_task_manager
node_task_manager -->|"emits"| node_event_bus
node_session_manager -->|"emits"| node_event_bus
node_agent_profiles -->|"configures"| node_main_agent
node_prompt_assets -->|"guides"| node_main_agent

click node_global_runtime "https://github.com/yan-930521/supernova/blob/main/src/runtime/GlobalRuntime.ts"
click node_session_manager "https://github.com/yan-930521/supernova/blob/main/src/manager/SessionManager.ts"
click node_task_manager "https://github.com/yan-930521/supernova/blob/main/src/manager/TaskManager.ts"
click node_task_planner "https://github.com/yan-930521/supernova/blob/main/src/task/TaskPlanner.ts"
click node_main_agent "https://github.com/yan-930521/supernova/blob/main/src/agent/MainAgent.ts"
click node_worker_agent "https://github.com/yan-930521/supernova/blob/main/src/agent/WorkerAgent.ts"
click node_base_agent "https://github.com/yan-930521/supernova/blob/main/src/agent/BaseAgent.ts"
click node_task_graph "https://github.com/yan-930521/supernova/blob/main/src/models/TaskGraph.ts"
click node_session_model "https://github.com/yan-930521/supernova/blob/main/src/models/Session.ts"
click node_task_model "https://github.com/yan-930521/supernova/blob/main/src/models/Task.ts"
click node_event_bus "https://github.com/yan-930521/supernova/blob/main/src/infra/EventBus.ts"
click node_mutation_validator "https://github.com/yan-930521/supernova/blob/main/src/infra/MutationValidator.ts"
click node_log_manager "https://github.com/yan-930521/supernova/blob/main/src/infra/LogManager.ts"
click node_task_repository "https://github.com/yan-930521/supernova/blob/main/src/infra/storage/FileSystemTaskRepository.ts"
click node_session_repository "https://github.com/yan-930521/supernova/blob/main/src/infra/storage/FileSystemSessionRepository.ts"
click node_agent_repository "https://github.com/yan-930521/supernova/blob/main/src/infra/storage/FileSystemAgentRepository.ts"
click node_tool_registry "https://github.com/yan-930521/supernova/blob/main/src/tool/ToolRegistry.ts"
click node_core_tools "https://github.com/yan-930521/supernova/tree/main/src/tool/core"
click node_common_tools "https://github.com/yan-930521/supernova/tree/main/src/tool/common"
click node_file_tools "https://github.com/yan-930521/supernova/tree/main/src/tool/file"
click node_prompt_assets "https://github.com/yan-930521/supernova/tree/main/prompts"
click node_agent_profiles "https://github.com/yan-930521/supernova/tree/main/agents"
click node_config "https://github.com/yan-930521/supernova/blob/main/src/config/Config.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_global_runtime,node_session_manager,node_task_manager,node_session_model,node_config toneBlue
class node_task_planner,node_main_agent,node_worker_agent,node_base_agent,node_task_graph,node_task_model toneAmber
class node_event_bus,node_mutation_validator,node_log_manager,node_task_repository,node_session_repository,node_agent_repository,node_tool_registry,node_core_tools,node_common_tools,node_file_tools toneMint
class node_prompt_assets,node_agent_profiles toneRose
```

## Components

### Runtime core

Top-level composition and state management boundaries.

- [Global runtime](https://github.com/yan-930521/supernova/blob/main/src/runtime/GlobalRuntime.ts): composition root · Wires configuration, managers, storage, tools, and events. · `src/runtime/GlobalRuntime.ts`
- [Session manager](https://github.com/yan-930521/supernova/blob/main/src/manager/SessionManager.ts): conversation state · Owns user-facing dialogue continuity and session updates. · `src/manager/SessionManager.ts`
- [Task manager](https://github.com/yan-930521/supernova/blob/main/src/manager/TaskManager.ts): execution state · Tracks task graphs, expansion, dispatch, and work state. · `src/manager/TaskManager.ts`
- [Session](https://github.com/yan-930521/supernova/blob/main/src/models/Session.ts): domain model · Conversation state contract. · `src/models/Session.ts`
- [Config](https://github.com/yan-930521/supernova/blob/main/src/config/Config.ts): runtime config · Loads and supplies runtime configuration. · `src/config/Config.ts`

### Agents and tasks

Planning, decomposition, and execution of work.

- [Task planner](https://github.com/yan-930521/supernova/blob/main/src/task/TaskPlanner.ts): goal decomposition · Turns a goal into staged planning and incremental task expansion. · `src/task/TaskPlanner.ts`
- [Main agent](https://github.com/yan-930521/supernova/blob/main/src/agent/MainAgent.ts): orchestrator agent · Coordinates tools and delegates work to workers or other agents. · `src/agent/MainAgent.ts`
- [Worker agent](https://github.com/yan-930521/supernova/blob/main/src/agent/WorkerAgent.ts): execution agent · Carries out delegated tasks and tool-using work. · `src/agent/WorkerAgent.ts`
- [Base agent](https://github.com/yan-930521/supernova/blob/main/src/agent/BaseAgent.ts): agent base · Shared agent behavior and execution contract. · `src/agent/BaseAgent.ts`
- [Task graph](https://github.com/yan-930521/supernova/blob/main/src/models/TaskGraph.ts): domain model · Canonical structure for decomposed tasks and dependencies. · `src/models/TaskGraph.ts`
- [Task](https://github.com/yan-930521/supernova/blob/main/src/models/Task.ts): domain model · Execution unit contract used by managers and agents. · `src/models/Task.ts`

### Infra and tools

Persistence, events, registries, and tool surfaces.

- [Event bus](https://github.com/yan-930521/supernova/blob/main/src/infra/EventBus.ts): coordination bus · Asynchronous coordination channel between runtime components. · `src/infra/EventBus.ts`
- [Mutation validator](https://github.com/yan-930521/supernova/blob/main/src/infra/MutationValidator.ts): state guard · Checks state changes before they are applied. · `src/infra/MutationValidator.ts`
- [Log manager](https://github.com/yan-930521/supernova/blob/main/src/infra/LogManager.ts): observability · Central logging and operational visibility. · `src/infra/LogManager.ts`
- [Task repo](https://github.com/yan-930521/supernova/blob/main/src/infra/storage/FileSystemTaskRepository.ts): filesystem persistence · Filesystem-backed persistence for task state. · `src/infra/storage/FileSystemTaskRepository.ts`
- [Session repo](https://github.com/yan-930521/supernova/blob/main/src/infra/storage/FileSystemSessionRepository.ts): filesystem persistence · Filesystem-backed persistence for session state. · `src/infra/storage/FileSystemSessionRepository.ts`
- [Agent repo](https://github.com/yan-930521/supernova/blob/main/src/infra/storage/FileSystemAgentRepository.ts): filesystem persistence · Filesystem-backed persistence for agent definitions and state. · `src/infra/storage/FileSystemAgentRepository.ts`
- [Tool registry](https://github.com/yan-930521/supernova/blob/main/src/tool/ToolRegistry.ts): tool catalog · Registers and resolves available tools. · `src/tool/ToolRegistry.ts`
- [Core tools](https://github.com/yan-930521/supernova/tree/main/src/tool/core): orchestration tools · Task creation, assignment, listing, and agent registration control plane. · `src/tool/core`
- [Common tools](https://github.com/yan-930521/supernova/tree/main/src/tool/common): general tools · Reasoning, search, fetch, math, time, and code execution tools. · `src/tool/common`
- [File tools](https://github.com/yan-930521/supernova/tree/main/src/tool/file): workspace tools · Local workspace file operations. · `src/tool/file`

### Prompts and profiles

Externalized prompts and agent identity definitions.

- [Prompt assets](https://github.com/yan-930521/supernova/tree/main/prompts): prompt library · Identity, planning, reasoning, and context projection prompts. · `prompts`
- [Agent profiles](https://github.com/yan-930521/supernova/tree/main/agents): agent configs · Concrete agent definitions and roles. · `agents`

## Connections

- Global runtime → Config: loads · Bootstraps configuration for the runtime.
- Global runtime → Session manager: wires · Composes conversation-state management.
- Global runtime → Task manager: wires · Composes execution-state management.
- Global runtime → Tool registry: wires · Registers available tools into the runtime.
- Global runtime → Event bus: wires · Connects asynchronous coordination.
- Global runtime → Log manager: wires · Sets up logging and diagnostics.
- Session manager → Session: stores · Persists and updates session state.
- Session manager → Session repo: persists · Uses filesystem-backed session storage.
- Task manager → Task: stores · Maintains task state.
- Task manager → Task graph: tracks · Maintains decomposition and dependencies.
- Task manager → Task repo: persists · Uses filesystem-backed task storage.
- Task manager → Mutation validator: validates · Guards task state changes.
- Task planner → Task graph: produces · Creates staged plans and expansions.
- Main agent → Base agent: extends · Shares the common agent contract.
- Worker agent → Base agent: extends · Shares the common agent contract.
- Main agent → Task planner: plans · Decomposes goals into executable work.
- Main agent → Worker agent: delegates · Hands off work to workers.
- Main agent → Tool registry: uses · Invokes tools through the registry.
- Worker agent → Tool registry: uses · Invokes tools through the registry.
- Tool registry → Core tools: contains · Registers orchestration primitives.
- Tool registry → Common tools: contains · Registers general-purpose tools.
- Tool registry → File tools: contains · Registers workspace file tools.
- Core tools → Task manager: controls · Creates, assigns, lists, and dispatches tasks.
- Core tools → Agent repo: reads · Looks up registered agents.
- Event bus → Session manager: publishes · Propagates session-related events.
- Event bus → Task manager: publishes · Propagates task lifecycle events.
- Task manager → Event bus: emits · Publishes task completion and update events.
- Session manager → Event bus: emits · Publishes conversation state events.
- Agent profiles → Main agent: configures · Provides concrete agent identity and behavior.
- Prompt assets → Main agent: guides · Supplies prompt-driven behavior and planning context.
