Skip to content

Commit fff782d

Browse files
committed
Add file editing and improved logging to OpenAI agents example
Introduces file creation, update, and deletion capabilities via a new WorkspaceEditor and applyPatchTool integration. Adds a logger utility for structured debug/info/error output throughout the backend. Refactors the UI to support persistent chat history, multi-column output, and improved message rendering. Updates dependencies to include Sandpack React for future file editing features. Improves documentation and exposes port 8080 in Dockerfile for local development.
1 parent fe2e775 commit fff782d

File tree

8 files changed

+1381
-86
lines changed

8 files changed

+1381
-86
lines changed

examples/openai-agents/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
# On a mac, you might need to actively pick up the
88
# arm64 build of the image.
99
FROM --platform=linux/arm64 cloudflare/sandbox-test:0.5.0
10+
11+
# Required during local development to access exposed ports
12+
EXPOSE 8080

examples/openai-agents/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
# OpenAI Agents with Cloudflare Sandbox
22

3-
Example using OpenAI Agents to execute shell commands in a Cloudflare Sandbox.
3+
A conversational AI assistant that executes shell commands and edits files in a Cloudflare Sandbox.
44

55
## Setup
66

7+
Create a `.env` file with your OpenAI API key:
8+
9+
```
10+
OPENAI_API_KEY=your-api-key-here
11+
```
12+
13+
Then start the development server:
14+
715
```bash
8-
npm install
9-
npm run types
1016
npm start
1117
```
1218

1319
## Usage
1420

15-
Enter natural language commands in the UI. The agent will execute shell commands in the sandbox and return the results.
21+
Enter natural language commands in the chat interface. The assistant can:
22+
23+
- Execute shell commands
24+
- Create, edit, and delete files
25+
26+
All conversations are saved in your browser's localStorage.
1627

1728
## Deploy
1829

examples/openai-agents/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"license": "ISC",
1414
"type": "module",
1515
"dependencies": {
16+
"@codesandbox/sandpack-react": "^2.20.0",
1617
"@openai/agents": "^0.3.2",
1718
"react": "^19.2.0",
1819
"react-dom": "^19.2.0"

0 commit comments

Comments
 (0)