Systems
A System is a TypeScript class that becomes a virtual object — a persistent, networked instance that feels like writing a local script but lives in the cloud with state that survives, history that streams, and methods you call from anywhere.The Mental Model
Think of a System as a virtual object — a class instance that never dies:count property persists. Close your terminal, come back tomorrow, reconnect — it’s still there. You didn’t configure a database. You didn’t write save/load code. State just persists because that’s what Idyllic does.
Defining a System
A System is any class that:- Has a default export — The CLI discovers it by scanning for default exports
- Lives in
idyllic/— Convention. The filename becomes the system name. - Has async methods — Methods become callable RPC endpoints
State
Properties on your class are state. State persists automatically.makeMove modifies this.board, the change persists. Reconnect tomorrow and the board is as you left it. All connected clients see the update immediately.
History
Systems have a history tree for streaming structured content to clients.Adding Messages
Streaming with Artifacts
Artifacts are typed content that can stream:addArtifact is called. As appendContent runs, content streams to all connected clients. No manual event emission — history sync handles it.
Running Subagents
Pausing for Input
Usethis.confirm() and this.ask() to pause execution and wait for human input:
Calling Other Systems
Systems can create and connect to other systems:Building Context
The history tree contains everything that happened. To call an LLM, you build context from it:buildContext() returns relevant history. Override it to customize:
Environment Variables
Access secrets viathis.env:
.dev.vars for local development:
The Generated API
When you runnpx idyllic dev, the CLI scans your system and generates typed function references:
FAQ
What happens to state when I redeploy?
State persists across deployments. Your Durable Objects keep their data. New code runs against existing state. This is usually what you want — users keep their conversations, projects keep their tasks. If you need to migrate state, handle it in your code. Check for old formats, transform as needed.Can one system call methods on another?
Yes. Useidyllic.create() or idyllic.connect() inside your system methods. Systems are networked objects — they can call each other.
How do I test a system?
For unit tests, instantiate your class directly:npx idyllic dev and test against the real runtime.
What’s the difference between create and connect?
create() makes a new instance with a generated ID. connect() attaches to an existing instance by ID. Use create when starting fresh, connect when resuming.
Can multiple clients connect to the same instance?
Yes. All connected clients see the same state and history. Changes sync automatically. This enables collaborative features without additional code.What’s the difference between state and history?
State is class properties —this.count, this.tasks, etc. It persists and syncs to clients automatically.
History is the tree of events — messages, artifacts, agent runs. It also syncs to all connected clients and drives the UI.
Both sync. Use state for structured data. Use history for streaming content and conversation flow.
Next: History
Understanding the structured record of system activity