OpenWork Examples Directory: Purpose, Structure, and How to Use It
The examples directory in the OpenWork repository contains self‑contained, runnable demonstration projects that showcase how to use OpenWork's core SDKs and runtime components in real‑world scenarios.
Located under the dev branch of different-ai/openwork, the examples directory serves as a curated reference library for developers. It separates instructional material from production code, making it easy to find proven patterns without cluttering the main application.
What the Examples Directory Provides
Each example in the examples folder is a minimal, complete codebase designed for three core purposes:
- Illustrate specific features or integrations — For instance, the
microsandbox-openwork-rustproject demonstrates sandbox startup, persistence configuration, and HTTP API interaction. - Deliver reproducible end‑to‑end usage — Every example includes a
Cargo.tomlwith dependencies, aREADME.mdwith step‑by‑step instructions, and a full source file implementing the runtime logic. - Act as a test harness — The example ships with an ignored integration test that boots the sandbox, checks health, validates authentication, and creates an OpenCode session.
Key Files in the Microsandbox Rust Example
The microsandbox-openwork-rust example demonstrates the standard structure you can expect across OpenWork examples:
| File | Role |
|---|---|
examples/microsandbox-openwork-rust/README.md |
High‑level description, usage instructions, environment variable documentation, and testing guidance. |
examples/microsandbox-openwork-rust/Cargo.toml |
Cargo configuration declaring the microsandbox SDK dependency and build metadata. |
examples/microsandbox-openwork-rust/src/main.rs |
Full implementation: parses env vars, creates the sandbox, streams logs, performs health checks, validates authentication, and runs a Ctrl‑C‑driven shutdown loop. |
Running the Rust Microsandbox Example
To build and run the example directly from the repository root:
# Clone the repository
git clone https://github.com/different-ai/openwork.git
cd openwork
# Build and run the example
cargo run --manifest-path examples/microsandbox-openwork-rust/Cargo.toml
Customizing with Environment Variables
Override defaults to match your deployment environment:
OPENWORK_MICROSANDBOX_IMAGE=ghcr.io/example/openwork-microsandbox:dev \
OPENWORK_CONNECT_HOST=127.0.0.1 \
OPENWORK_TOKEN=my-secret-token \
cargo run --manifest-path examples/microsandbox-openwork-rust/Cargo.toml
Running the Integration Test
The included integration test requires a pullable OCI image. Execute it with:
OPENWORK_MICROSANDBOX_IMAGE=ttl.sh/openwork-microsandbox-11559:1d \
cargo test --manifest-path examples/microsandbox-openwork-rust/Cargo.toml \
-- --ignored --nocapture
This test boots the sandbox, verifies health endpoints, confirms authentication flows, and spins up an OpenCode session — providing a complete sanity check for your environment.
How the Examples Directory Fits Into OpenWork Development
According to the OpenWork source code, the examples directory follows a deliberate architectural pattern:
- Separation of concerns — Production code remains focused and uncluttered by tutorial or demo logic.
- Discoverability — New contributors immediately see where to find reference implementations.
- Extensibility — Developers can copy an example as a starting point for new features, adapting proven patterns rather than building from scratch.
The examples/microsandbox-openwork-rust/src/main.rs implementation specifically shows this pattern in action: it handles environment parsing, sandbox lifecycle management, log streaming, graceful shutdown on Ctrl‑C, and health check validation — all in one file that can be read, run, and modified.
Summary
- The OpenWork
examplesdirectory houses runnable, self‑contained projects demonstrating SDK and runtime usage. - Each example includes full source code, dependency manifests, instructions, and integration tests.
- The
microsandbox-openwork-rustexample atexamples/microsandbox-openwork-rust/shows sandbox orchestration, health checks, and OpenCode session creation. - Examples serve as reference implementations, test harnesses, and starting points for new development.
- Run examples with
cargo run --manifest-pathand customize behavior via environment variables.
Frequently Asked Questions
What is inside the OpenWork examples directory?
Each subdirectory contains a complete, minimal project with source code, build configuration, documentation, and tests. The microsandbox-openwork-rust example, for instance, includes Cargo.toml, README.md, and src/main.rs files that together demonstrate sandbox management and API interaction.
How do I run an OpenWork example locally?
Navigate to the repository root and execute cargo run --manifest-path examples/<example-name>/Cargo.toml. For the Rust microsandbox example, use cargo run --manifest-path examples/microsandbox-openwork-rust/Cargo.toml.
Can I use OpenWork examples as templates for my own projects?
Yes. The examples are explicitly designed as starting points. Copy the directory, modify the Cargo.toml dependencies and src/main.rs logic to match your use case, and extend the provided patterns.
What does the integration test in the microsandbox example verify?
The ignored test at examples/microsandbox-openwork-rust/ boots an actual sandbox instance, performs health checks, validates authentication with your provided token, and creates an OpenCode session — confirming that your environment can successfully interact with OpenWork services.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →