Skip to content

Commit c453bfc

Browse files
authored
Merge pull request #10 from getlark/vd-20260316-1743
Add examples directory, docs improvements, and dev-publish cleanup
2 parents 4cd2c24 + 9308698 commit c453bfc

16 files changed

Lines changed: 434 additions & 80 deletions

File tree

CONTRIBUTING.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Contributing
2+
3+
Thanks for contributing to `runtimeuse`.
4+
5+
## Prerequisites
6+
7+
- Git
8+
- Node.js 22 or newer
9+
- Python 3.11 or newer recommended
10+
- `npm`
11+
12+
There is no root workspace setup in this repository today, so install dependencies separately in each package you want to work on.
13+
14+
## Clone the Repository
15+
16+
```bash
17+
git clone https://github.com/getlark/runtimeuse.git
18+
cd runtimeuse
19+
```
20+
21+
## Repository Layout
22+
23+
- `packages/runtimeuse` is the TypeScript runtime that runs inside the sandbox.
24+
- `packages/runtimeuse-client-python` is the Python client used outside the sandbox.
25+
- `docs` is the documentation app.
26+
27+
## Environment Files
28+
29+
Two local env files are useful for advanced development flows. They are not required for the basic local test path:
30+
31+
- `packages/runtimeuse/.env` for the runtime package's `npm run dev-publish` flow. Start from `packages/runtimeuse/.env.example`.
32+
- `packages/runtimeuse-client-python/.env` for sandbox and LLM tests. Start from `packages/runtimeuse-client-python/.env.example`.
33+
34+
## TypeScript Runtime Development
35+
36+
Install dependencies:
37+
38+
```bash
39+
cd packages/runtimeuse
40+
npm install
41+
```
42+
43+
Useful commands:
44+
45+
```bash
46+
npm run build
47+
npm run typecheck
48+
npm test
49+
npm run test:integration
50+
```
51+
52+
Notes:
53+
54+
- `npm test` runs the main unit test suite.
55+
- `npm run test:integration` builds first and then runs the integration tests.
56+
- If you want to use the Claude handler locally, install the CLI with `npm install -g @anthropic-ai/claude-code`.
57+
- `npm run dev-publish` runs `scripts/dev-publish.sh`: it builds the runtime, uploads a zip to S3, and prints a presigned download URL plus a ready-to-use `curl ... && node runtimeuse/dist/cli.js` command.
58+
- `npm run dev-publish` reads `packages/runtimeuse/.env` for `S3_BUCKET` and optionally `S3_PREFIX` and `PRESIGN_EXPIRY`.
59+
- `npm run dev-publish` assumes the AWS CLI is installed and already authenticated with permission to upload to the configured S3 bucket and generate presigned URLs.
60+
61+
## Python Client Development
62+
63+
Create and activate a virtual environment, then install the package in editable mode:
64+
65+
```bash
66+
cd packages/runtimeuse-client-python
67+
python -m venv .venv
68+
source .venv/bin/activate
69+
pip install -e ".[dev]" 2>/dev/null || pip install -e .
70+
pip install pytest pytest-asyncio
71+
```
72+
73+
Run the default test suite:
74+
75+
```bash
76+
pytest test/ -m "not sandbox and not llm"
77+
```
78+
79+
Sandbox-only test flow:
80+
81+
```bash
82+
pytest test/ -m sandbox
83+
```
84+
85+
LLM-only test flow:
86+
87+
```bash
88+
pytest test/ -m llm
89+
```
90+
91+
Notes:
92+
93+
- The Python package declares `python >=3.10`, but CI currently tests on Python 3.11 through 3.13.
94+
- If your change touches the runtime protocol or end-to-end behavior, build `packages/runtimeuse` before running Python tests:
95+
96+
```bash
97+
cd packages/runtimeuse
98+
npm install
99+
npm run build
100+
```
101+
102+
- Copy `packages/runtimeuse-client-python/.env.example` to `.env` before running sandbox or LLM tests locally.
103+
- Sandbox tests create an E2B sandbox and require `E2B_API_KEY`.
104+
- LLM tests also create sandboxes by default and require `E2B_API_KEY` plus the relevant provider credentials such as `OPENAI_API_KEY` or `ANTHROPIC_API_KEY`.
105+
- If you already have a runtime server running, set `TEST_WS_URL` to reuse it instead of creating a fresh sandbox.
106+
- Some LLM tests also require `TEST_S3_BUCKET` for artifact upload verification.
107+
- If you want sandbox tests to run against a dev build instead of `npx -y runtimeuse`, set `RUNTIMEUSE_RUN_COMMAND`. A convenient way to get that command is `packages/runtimeuse` -> `npm run dev-publish`.
108+
109+
## Docs Development
110+
111+
Install and run the docs app:
112+
113+
```bash
114+
cd docs
115+
npm install
116+
npm run dev
117+
```
118+
119+
Useful commands:
120+
121+
```bash
122+
npm run build
123+
npm run types:check
124+
npm run lint
125+
```
126+
127+
## Before Opening a PR
128+
129+
Run the checks relevant to the package you changed:
130+
131+
- `packages/runtimeuse`: `npm run typecheck` and `npm test`
132+
- `packages/runtimeuse-client-python`: `pytest test/ -m "not sandbox and not llm"`
133+
- `docs`: `npm run types:check` and `npm run lint`
134+
135+
If you changed behavior shared between the runtime and Python client, run both the TypeScript and Python checks.

README.md

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Twitter Follow](https://img.shields.io/twitter/follow/getlark)](https://twitter.com/getlark)
44

5-
Communicate with AI agents inside sandboxes over WebSocket.
5+
Run AI agents inside sandboxes and communicate with them over WebSocket.
66

77
| Package | Language | Role | Install |
88
| ---------------------------------------------------------- | ---------- | ------------------------------------------ | ------------------------------- |
@@ -14,10 +14,10 @@ Communicate with AI agents inside sandboxes over WebSocket.
1414
### 1. Start the runtime (inside a sandbox)
1515

1616
```bash
17-
npx -y runtimeuse@latest
17+
npx -y runtimeuse
1818
```
1919

20-
This starts a WebSocket server on port 8080 using the OpenAI agent handler by default. Use `--agent claude` for Claude.
20+
This starts a WebSocket server on port 8080 using the OpenAI agent handler by default. Use `--agent claude` for Claude. The Claude handler also requires the `claude` CLI to be installed in the sandbox, for example with `npm install -g @anthropic-ai/claude-code`.
2121

2222
### 2. Connect from Python
2323

@@ -41,33 +41,12 @@ async def main():
4141
asyncio.run(main())
4242
```
4343

44-
### 3. Or use the runtime programmatically (TypeScript)
45-
46-
```typescript
47-
import { RuntimeUseServer, openaiHandler } from "runtimeuse";
48-
49-
const server = new RuntimeUseServer({ handler: openaiHandler, port: 8080 });
50-
await server.startListening();
51-
```
52-
53-
## How It Works
54-
55-
```
56-
Python Client ──> WebSocket ──> Runtime (in sandbox) ──> AgentHandler
57-
├── openai (default)
58-
└── claude
59-
```
44+
See the [runtime README](./packages/runtimeuse/README.md) and [client README](./packages/runtimeuse-client-python/README.md) for full API docs.
6045

61-
1. The client sends an `InvocationMessage` over WebSocket
62-
2. The runtime downloads files and runs pre-commands (if any)
63-
3. The `AgentHandler` executes the agent with the given prompts and model
64-
4. Intermediate `AssistantMessage`s stream back to the client
65-
5. Files in the artifacts directory are auto-detected and uploaded via presigned URL handshake
66-
6. A final `ResultMessage` with structured output is sent back
67-
7. The runtime runs post-commands (if any)
46+
## Contributing
6847

69-
See the [runtime README](./packages/runtimeuse/README.md) and [client README](./packages/runtimeuse-client-python/README.md) for full API docs.
48+
See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for local setup, package-specific development commands, and the recommended checks to run before opening a PR.
7049

7150
## License
7251

73-
BSL-1.1
52+
[FSL-1.1-ALv2](./LICENSE.md)

docs/README.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
# docs
22

3-
This is a React Router application generated with
4-
[Create Fumadocs](https://github.com/fuma-nama/fumadocs).
3+
Documentation app for `runtimeuse`, built with React Router and Fumadocs.
54

6-
Run development server:
5+
## Local Development
6+
7+
Install dependencies and start the dev server from this directory:
78

89
```bash
10+
npm install
911
npm run dev
10-
# or
11-
pnpm dev
12-
# or
13-
yarn dev
1412
```
13+
14+
## Available Scripts
15+
16+
```bash
17+
npm run dev # start the local docs app
18+
npm run build # create a production build
19+
npm run start # serve the built site
20+
npm run types:check # generate route/docs types and run TypeScript checks
21+
npm run lint # run Biome checks
22+
npm run format # format the docs app with Biome
23+
```
24+
25+
## Project Layout
26+
27+
- `content/docs` contains the MDX documentation content.
28+
- `app` contains the React Router application and search/UI code.
29+
- `source.config.ts` configures the Fumadocs content source.

docs/app/lib/layout.shared.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
22

3-
// fill this with your actual GitHub info, for example:
43
export const gitConfig = {
5-
user: 'fuma-nama',
6-
repo: 'fumadocs',
4+
user: 'getlark',
5+
repo: 'runtimeuse',
76
branch: 'main',
87
};
98

109
export function baseOptions(): BaseLayoutProps {
1110
return {
1211
nav: {
13-
title: 'React Router',
12+
title: 'RuntimeUse',
1413
},
1514
githubUrl: `https://github.com/${gitConfig.user}/${gitConfig.repo}`,
1615
};

docs/app/root.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import SearchDialog from '@/components/search';
1313
import NotFound from './routes/not-found';
1414

1515
export const links: Route.LinksFunction = () => [
16+
{ rel: 'icon', href: '/favicon.svg', type: 'image/svg+xml' },
1617
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
1718
{
1819
rel: 'preconnect',

docs/content/docs/index.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
22
title: Introduction
3-
description: Run AI agents in sandboxes and communicate over WebSocket.
3+
description: Run AI agents in sandboxes and communicate with them over WebSocket.
44
---
55

66
## What is RuntimeUse?
77

8-
RuntimeUse lets you run an AI agent inside any sandbox and communicate with it over WebSocket — handling artifact uploads, pre-commands, file downloads, cancellation, and structured results.
8+
RuntimeUse lets you run an AI agent inside any sandbox and communicate with it over WebSocket. It handles the runtime lifecycle for you: file downloads, pre-commands, artifact uploads, cancellation, and structured results.
99

1010
It is made up of two parts:
1111

12-
1. **NPM Runtime executable** — Run it in any sandbox with `npx runtimeuse`. It sets up your agent of choice (Claude, OpenAI, etc) and starts a WebSocket server to interact with it.
13-
2. **Client libraries** — Simple abstractions for interacting with the sandbox WebSocket server from your API server, worker nodes, etc.
12+
1. **`runtimeuse`**: the TypeScript runtime that runs inside the sandbox and exposes a WebSocket server.
13+
2. **`runtimeuse-client`**: the Python client that connects from outside the sandbox and sends invocations.
14+
15+
Today, the recommended path is to run the runtime in the sandbox and use the Python client from your application code.
1416

1517
## Built-in Agent Handlers
1618

@@ -21,6 +23,12 @@ The runtime ships with two built-in handlers:
2123

2224
Switch between them with `--agent openai` or `--agent claude`.
2325

26+
The Claude handler also requires the `claude` CLI to be installed in the sandbox, for example:
27+
28+
```bash
29+
npm install -g @anthropic-ai/claude-code
30+
```
31+
2432
## Key Features
2533

2634
- **Sandbox-agnostic** — works with any provider that can run `npx` and expose a port
@@ -30,4 +38,6 @@ Switch between them with `--agent openai` or `--agent claude`.
3038

3139
<Cards>
3240
<Card title="Quickstart" href="/docs/quickstart" />
41+
<Card title="Runtime Package" href="https://github.com/getlark/runtimeuse/tree/main/packages/runtimeuse" />
42+
<Card title="Python Client" href="https://github.com/getlark/runtimeuse/tree/main/packages/runtimeuse-client-python" />
3343
</Cards>

0 commit comments

Comments
 (0)