Skip to main content
The SDK and the CLI are two interfaces over the same store. They write the same files, enforce the same rules, and raise the same error codes — so you can mix them freely. Reach for the SDK when you are generating environments programmatically, wiring Silo into a test suite, or building tooling on top.

Silo.open()

Binds to one project root.
cwd defaults to process.cwd(). It is captured once rather than read again further down, so a single process can serve several projects at the same time. Opening a path that is not a directory throws environment_not_found.

Environments

create is silo init. open binds to one that already exists and throws environment_not_found if it does not. A SiloEnvironment exposes name, cwd, the four resource collections, and validate().

Resources

Each resource collection mirrors the matching CLI command family. put has no CLI equivalent — it adds or replaces without caring which, which is what you want in a generator that may run twice.
Mutating methods return the path they wrote, so a generator can log exactly what it produced.

Scaffolding

Both return a ScaffoldResult describing the file created and the barrel entry added. As with the CLI, the generated code compiles and fails on purpose — it never contains business logic.

Validation

Same shape as env validate --json: ok, findings[] and counts. It runs the real TypeScript compiler, not a file-presence check.

Errors

Every failure throws a SiloError with a stable code:
isSiloError is a type guard, so error.code and error.details are typed inside the branch. See Error Codes.

Authoring exports

The SDK also re-exports what environment code itself is written against:
Those are the values your tools/ and verifiers/ files import. They are runtime values, not types, so the package must be installed for an environment to run — not only to type-check.

Running

Running a rollout is currently a CLI concern. To run agents from a script, shell out:
Artifacts land in .silo/runs/<runId>/ either way, and result.json is designed to be read back programmatically — see Run Artifacts.