Skip to main content

What is Plexa

Plexa is the orchestration layer above SCP. It runs a tick loop, packs every body’s state into a brain prompt, applies safety rules, dispatches the brain’s tool intent as a direct method call, and remembers what worked across sessions.
npm install @srk0102/plexa
If you only have one body, use scp-protocol directly. Plexa starts paying for itself when you have two or more.

SCP vs Plexa

scp-protocol@srk0102/plexa
Scopeone bodymany bodies under one brain
Roleprotocol + body SDKorchestrator
Memorypattern store + adaptive memory (per body)adds vertical memory (per space, cross-session)
Safetyreflex rules in the bodyadds safety gate + approval hook + injection sanitizer
Cost trackingper-bridge countersper-space USD totals + cache savings
Lateral eventsnot applicablespace.link(from, to, types)

When to use which

Use scp-protocol when:
  • You have one body.
  • You want full control over the tick loop.
  • You do not need cross-session memory at the orchestrator level.
Use Plexa when:
  • You have several bodies and want one LLM coordinating them.
  • You need cross-session memory that the brain can search before deciding.
  • You want a hard safety gate that cannot be bypassed by the LLM.
  • You want bodies to talk to each other directly without going through the brain.

Quick start

const { Space, BodyAdapter, VerticalMemory } = require("@srk0102/plexa")
const { OllamaBrain } = require("@srk0102/plexa/bridges/ollama")

class Cart extends BodyAdapter {
  static bodyName = "cart"
  static tools = {
    apply_force: {
      description: "push the cart",
      parameters: {
        direction: { type: "string", enum: ["left", "right"], required: true },
        magnitude: { type: "number", min: 0, max: 1, required: true },
      },
    },
  }
  async apply_force({ direction, magnitude }) { /* drive hardware */ }
}

const space = new Space("balancer", {
  verticalMemory: new VerticalMemory({ spaceName: "balancer", dbPath: "./plexa.db" }),
})
space.addBody(new Cart())
space.setBrain(new OllamaBrain({ model: "llama3.2" }))
space.installShutdownHandlers()
await space.run()

The starfish

Plexa’s logo is a starfish. A starfish has no central brain; it has a ring of nerves that coordinate many independent arms. Each arm decides locally; the ring coordinates when an action needs more than one arm. That is the same shape as a Plexa Space coordinating many SCP bodies.