leo commited on
Commit
1e2d855
·
1 Parent(s): 35406ca

hello-world plugin template for Autonomous OS

Browse files
Files changed (6) hide show
  1. README.md +57 -5
  2. index.html +76 -18
  3. main.py +36 -0
  4. plugin.json +6 -0
  5. requirements.txt +1 -0
  6. style.css +0 -28
README.md CHANGED
@@ -1,10 +1,62 @@
1
  ---
2
- title: Autonomous Os Hello Robot
3
- emoji: 🐠
4
- colorFrom: yellow
5
- colorTo: indigo
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Hello Robot
3
+ emoji: 🤖
4
+ colorFrom: blue
5
+ colorTo: green
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - autonomous-os-plugin
10
  ---
11
 
12
+ # Hello World Plugin
13
+
14
+ A minimal Autonomous OS plugin that pulses LEDs and speaks a greeting.
15
+
16
+ ## Quick Start
17
+
18
+ 1. Fork this repo
19
+ 2. Edit `main.py` to do something cool
20
+ 3. Push to HuggingFace / GitHub / GitLab
21
+ 4. Install on your device: **Settings > Plugins > paste URL > Install**
22
+
23
+ ## Plugin Format
24
+
25
+ ```
26
+ your-plugin/
27
+ plugin.json # name, version, description, entry point
28
+ main.py # your Python code
29
+ requirements.txt # pip dependencies
30
+ README.md # description + demo video
31
+ ```
32
+
33
+ ## HAL API
34
+
35
+ Plugins control hardware via HAL's HTTP API (injected as `HAL_URL` env var, default `http://localhost:5001`):
36
+
37
+ ```python
38
+ import os, requests
39
+
40
+ HAL = os.environ.get("HAL_URL", "http://localhost:5001")
41
+
42
+ # LED
43
+ requests.post(f"{HAL}/led/effect", json={"effect": "rainbow"})
44
+ requests.post(f"{HAL}/led/effect", json={"effect": "pulse", "color": "blue"})
45
+ requests.post(f"{HAL}/led/off")
46
+
47
+ # Voice
48
+ requests.post(f"{HAL}/voice/speak", json={"text": "Hello!"})
49
+
50
+ # Servo (devices with motion capability)
51
+ requests.post(f"{HAL}/servo/move", json={"pan": 45, "tilt": 10})
52
+
53
+ # Camera (devices with vision capability)
54
+ resp = requests.get(f"{HAL}/camera/snapshot")
55
+ ```
56
+
57
+ ## Tips
58
+
59
+ - Keep `requirements.txt` minimal — installs run on constrained devices
60
+ - Use `HAL_URL` env var, don't hardcode `localhost:5001`
61
+ - Add a demo video/GIF to your README for discoverability
62
+ - Tag your HuggingFace Space with `autonomous-os-plugin` for discovery
index.html CHANGED
@@ -1,19 +1,77 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Hello Robot - Autonomous OS Plugin</title>
7
+ <style>
8
+ * { margin: 0; padding: 0; box-sizing: border-box; }
9
+ body {
10
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
11
+ background: #0a0a0a; color: #e5e5e5;
12
+ min-height: 100vh; display: flex; align-items: center; justify-content: center;
13
+ }
14
+ .card {
15
+ max-width: 520px; width: 90%; padding: 40px;
16
+ background: #161616; border: 1px solid #2a2a2a; border-radius: 16px;
17
+ text-align: center;
18
+ }
19
+ .emoji { font-size: 48px; margin-bottom: 16px; }
20
+ h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
21
+ .subtitle { font-size: 14px; color: #888; margin-bottom: 24px; }
22
+ .code {
23
+ background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 10px;
24
+ padding: 16px; text-align: left; margin-bottom: 24px;
25
+ font-family: 'SF Mono', Monaco, Consolas, monospace; font-size: 13px;
26
+ line-height: 1.7; overflow-x: auto;
27
+ }
28
+ .code .comment { color: #555; }
29
+ .code .fn { color: #f59e0b; }
30
+ .code .str { color: #34d399; }
31
+ .steps {
32
+ text-align: left; margin-bottom: 24px; font-size: 13px; line-height: 2;
33
+ }
34
+ .steps li { list-style: none; padding-left: 24px; position: relative; }
35
+ .steps li::before {
36
+ content: attr(data-n); position: absolute; left: 0;
37
+ color: #f59e0b; font-weight: 600;
38
+ }
39
+ .btn {
40
+ display: inline-block; padding: 10px 24px; border-radius: 8px;
41
+ background: #f59e0b; color: #000; font-weight: 600; font-size: 13px;
42
+ text-decoration: none; transition: opacity 0.15s;
43
+ }
44
+ .btn:hover { opacity: 0.85; }
45
+ .footer { margin-top: 20px; font-size: 11px; color: #555; }
46
+ .footer a { color: #888; text-decoration: none; }
47
+ </style>
48
+ </head>
49
+ <body>
50
+ <div class="card">
51
+ <div class="emoji">🤖</div>
52
+ <h1>Hello Robot</h1>
53
+ <p class="subtitle">A starter plugin for Autonomous OS &mdash; rainbow LEDs + voice greeting</p>
54
+
55
+ <div class="code">
56
+ <span class="comment"># What it does</span><br>
57
+ <span class="fn">POST</span> /led/effect &nbsp;{<span class="str">"effect": "rainbow"</span>}<br>
58
+ <span class="fn">POST</span> /voice/speak {<span class="str">"text": "Hello!"</span>}<br>
59
+ <span class="comment"># ...wait 30s, then LED off</span>
60
+ </div>
61
+
62
+ <ol class="steps">
63
+ <li data-n="1.">Fork this Space</li>
64
+ <li data-n="2.">Edit main.py to do something cool</li>
65
+ <li data-n="3.">On your device: Settings &gt; Plugins &gt; paste URL &gt; Install</li>
66
+ </ol>
67
+
68
+ <a class="btn" href="https://huggingface.co/spaces/autonomous-os/autonomous-os-hello-robot?duplicate=true">
69
+ Fork this plugin
70
+ </a>
71
+
72
+ <p class="footer">
73
+ Part of <a href="https://github.com/autonomous-ai/autonomous">Autonomous OS</a>
74
+ </p>
75
+ </div>
76
+ </body>
77
  </html>
main.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Hello World plugin for Autonomous OS.
2
+
3
+ Pulses LED rainbow, speaks a greeting, waits, then turns off.
4
+ Fork this repo and modify to build your own plugin.
5
+
6
+ HAL API docs: see hal/routes/ in the main repo.
7
+ """
8
+
9
+ import os
10
+ import time
11
+
12
+ import requests
13
+
14
+ HAL = os.environ.get("HAL_URL", "http://localhost:5001")
15
+
16
+
17
+ def main():
18
+ # Rainbow LED effect
19
+ requests.post(f"{HAL}/led/effect", json={"effect": "rainbow"}, timeout=5)
20
+
21
+ # Voice greeting
22
+ requests.post(
23
+ f"{HAL}/voice/speak",
24
+ json={"text": "Hello! I am a plugin running on Autonomous OS."},
25
+ timeout=30,
26
+ )
27
+
28
+ # Keep running for 30 seconds (demo)
29
+ time.sleep(30)
30
+
31
+ # Clean up
32
+ requests.post(f"{HAL}/led/off", timeout=5)
33
+
34
+
35
+ if __name__ == "__main__":
36
+ main()
plugin.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "name": "hello-world",
3
+ "version": "1.0.0",
4
+ "description": "LED rainbow + greeting — fork this to make your own plugin",
5
+ "entry": "main.py"
6
+ }
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ requests
style.css DELETED
@@ -1,28 +0,0 @@
1
- body {
2
- padding: 2rem;
3
- font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
4
- }
5
-
6
- h1 {
7
- font-size: 16px;
8
- margin-top: 0;
9
- }
10
-
11
- p {
12
- color: rgb(107, 114, 128);
13
- font-size: 15px;
14
- margin-bottom: 10px;
15
- margin-top: 5px;
16
- }
17
-
18
- .card {
19
- max-width: 620px;
20
- margin: 0 auto;
21
- padding: 16px;
22
- border: 1px solid lightgray;
23
- border-radius: 16px;
24
- }
25
-
26
- .card p:last-child {
27
- margin-bottom: 0;
28
- }