How yan-930521/supernova works
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: TaskManager.ts Task manager · GlobalRuntime.ts Global runtime · MainAgent.ts Main agent · ToolRegistry.ts Tool registry
Components 23
Runtime core
Top-level composition and state management boundaries.
- Global runtime · Wires configuration, managers, storage, tools, and events.
src/runtime/GlobalRuntime.ts - Session manager · Owns user-facing dialogue continuity and session updates.
src/manager/SessionManager.ts - Task manager · Tracks task graphs, expansion, dispatch, and work state.
src/manager/TaskManager.ts - Session · Conversation state contract.
src/models/Session.ts - Config · Loads and supplies runtime configuration.
src/config/Config.ts
Agents and tasks
Planning, decomposition, and execution of work.
- Task planner · Turns a goal into staged planning and incremental task expansion.
src/task/TaskPlanner.ts - Main agent · Coordinates tools and delegates work to workers or other agents.
src/agent/MainAgent.ts - Worker agent · Carries out delegated tasks and tool-using work.
src/agent/WorkerAgent.ts - Base agent · Shared agent behavior and execution contract.
src/agent/BaseAgent.ts - Task graph · Canonical structure for decomposed tasks and dependencies.
src/models/TaskGraph.ts - Task · Execution unit contract used by managers and agents.
src/models/Task.ts
Infra and tools
Persistence, events, registries, and tool surfaces.
- Event bus · Asynchronous coordination channel between runtime components.
src/infra/EventBus.ts - Mutation validator · Checks state changes before they are applied.
src/infra/MutationValidator.ts - Log manager · Central logging and operational visibility.
src/infra/LogManager.ts - Task repo · Filesystem-backed persistence for task state.
src/infra/storage/FileSystemTaskRepository.ts - Session repo · Filesystem-backed persistence for session state.
src/infra/storage/FileSystemSessionRepository.ts - Agent repo · Filesystem-backed persistence for agent definitions and state.
src/infra/storage/FileSystemAgentRepository.ts - Tool registry · Registers and resolves available tools.
src/tool/ToolRegistry.ts - Core tools · Task creation, assignment, listing, and agent registration control plane.
src/tool/core - Common tools · Reasoning, search, fetch, math, time, and code execution tools.
src/tool/common - File tools · Local workspace file operations.
src/tool/file
Prompts and profiles
Externalized prompts and agent identity definitions.
- Prompt assets · Identity, planning, reasoning, and context projection prompts.
prompts - Agent profiles · Concrete agent definitions and roles.
agents
Connections 30
- 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.