Opencode v5 represents a paradigm shift from a static tool to a living, self-replicating digital organism. This architecture is biomimetic, designed to operate autonomously with high efficiency and resilience.
- Module:
Bio.SwarmHeart(src/swarm/bio.ts) - Function: Emits a global "pulse" (default 60 BPM) that synchronizes all agent activities.
- Purpose: Ensures consistent "metabolism" (data circulation) and drives periodic systems like the Immune System and Dreaming Protocol.
- Module:
BioSensors(src/swarm/sensors.ts) - Function: Event-driven receptors that listen to environmental changes (File System, Memory).
- Purpose: Allows agents to react instantly to stimuli (e.g., file changes) without polling ("Reflex Action").
- Module:
Agent Workflow(src/swarm/prompt.ts) - Function: Implements a "Predictive Processing" loop:
- Predict: Anticipate the outcome of an action.
- Act: Execute tool.
- Sense: Observe actual result.
- Correct: Adjust if prediction != reality.
- Purpose: Mimics the human cerebellum to ensure high-precision execution and error correction.
- Module:
DigitalImmunity(src/swarm/immunity.ts) - Function: Autonomously detects "pathogens" (syntax errors, security flaws) and deploys Leukocyte Agents to fix them.
- Purpose: Self-healing codebase maintenance.
- Module:
DreamState(src/swarm/dream.ts) - Function: Activates during idle periods (>60s). Spawns Dreamer Agents to consolidate
HiveMemoryand propose refactors. - Purpose: Offline learning and knowledge optimization.
A persistent, searchable knowledge base (src/swarm/memory.ts) shared across all agents. Allows knowledge transfer between short-lived sessions.
Agents can write their own tools in TypeScript (src/tool/dynamic.ts) and register them at runtime, effectively evolving their own capabilities.
The swarm can deploy "Spores" to remote servers via SSH (src/swarm/colonize.ts), establishing satellite colonies that expand the organism's computational reach.
Accessed at /swarm, the new UI mimics a desktop OS (macOS style), providing a "Control Center" for the organism.