likhonsheikh commited on
Commit
7cb66b1
Β·
verified Β·
1 Parent(s): 24e443f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -0
README.md CHANGED
@@ -7,4 +7,76 @@ sdk: docker
7
  pinned: false
8
  ---
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
7
  pinned: false
8
  ---
9
 
10
+ README.md
11
+
12
+ # Ubuntu Agent over SSE (Hugging Face Spaces)
13
+
14
+ A minimal Ubuntu sandbox exposing **MCP-style tools** (`shell`, `python`) with **Server-Sent Events** streaming in Hugging Face Docker Spaces.
15
+
16
+ ## Endpoints
17
+
18
+ - `GET /` β€” health check
19
+ - `GET /tools` β€” list available tools (from `tools.json`)
20
+ - `GET /exec?tool=shell&command=ls%20-la` β€” run a tool and stream results via SSE
21
+ - `GET /exec?tool=python&code=print(%27hi%27)` β€” run Python and stream results via SSE
22
+ - `POST /run` β€” JSON body, streams results via SSE
23
+ Body: `{"tool":"shell","args":{"command":"ls -la"}}`
24
+
25
+ **SSE Event types:**
26
+ - `tools` β€” initial tool manifest
27
+ - `output` β€” stdout chunk
28
+ - `error` β€” stderr chunk
29
+ - `done` β€” `{ code: <exit_code> }`
30
+ - `ping` β€” keepalive
31
+
32
+ ## Local run
33
+
34
+ ```bash
35
+ npm install
36
+ npm run dev
37
+ # open http://localhost:7860
38
+
39
+ Example (curl SSE):
40
+
41
+ curl -N "http://localhost:7860/exec?tool=shell&command=uname%20-a"
42
+
43
+ POST streaming:
44
+
45
+ curl -N -H "Content-Type: application/json" \
46
+ -X POST "http://localhost:7860/run" \
47
+ -d '{"tool":"python","args":{"code":"import sys; print(sys.version)"}}'
48
+
49
+ Notes (Hugging Face Spaces)
50
+
51
+ The app must listen on 0.0.0.0:$PORT β€” handled in server.js.
52
+
53
+ No SSH/root console is provided by Spaces; all interaction is via HTTP endpoints.
54
+
55
+ Filesystem is ephemeral across restarts.
56
+
57
+
58
+ Security
59
+
60
+ Endpoints are open by default (demo). For private Spaces, rely on HF visibility. For public Spaces, add auth (tokens, IP allowlists) if needed.
61
+
62
+
63
+ ---
64
+
65
+ ## How to deploy to your Space quickly
66
+
67
+ ```bash
68
+ # In a fresh local folder
69
+ git init
70
+ git remote add origin https://huggingface.co/spaces/likhonsheikh/ubuntu
71
+
72
+ # Add the files above, then:
73
+ git add .
74
+ git commit -m "HF Ubuntu agent: SSE tools + runtime fix"
75
+ git push origin main
76
+
77
+ Once the Space finishes building, test:
78
+
79
+ # Replace URL with your Space URL if different
80
+ curl -N "https://likhonsheikh-ubuntu.hf.space/exec?tool=shell&command=ls%20-la"
81
+
82
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference