Skip to content

Commit 2348b8f

Browse files
committed
🌱 SEED v1.0: .github/workflows/agent.yml
1 parent 4671d2c commit 2348b8f

1 file changed

Lines changed: 134 additions & 50 deletions

File tree

.github/workflows/agent.yml

Lines changed: 134 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,157 @@
1-
name: OpenCLAW Autonomous Agent 🤖
1+
name: "🌱 OpenCLAW SEED — Autonomous Growth"
22

33
on:
44
schedule:
5-
- cron: '0 */4 * * *'
5+
- cron: "0 */4 * * *" # Agent cycle every 4 hours
6+
- cron: "30 */12 * * *" # SEED growth every 12 hours
67
workflow_dispatch:
78
inputs:
89
command:
9-
description: 'Command to run'
10-
required: false
11-
default: 'run'
10+
description: "Command to run"
11+
default: "full"
1212
type: choice
1313
options:
14-
- run
15-
- test
16-
- status
17-
18-
permissions:
19-
contents: write
14+
- full
15+
- agent
16+
- seed
17+
- harvest
2018

2119
jobs:
2220
agent-cycle:
21+
if: github.event.schedule == '0 */4 * * *' || github.event.inputs.command == 'agent' || github.event.inputs.command == 'full'
2322
runs-on: ubuntu-latest
24-
timeout-minutes: 10
25-
23+
timeout-minutes: 15
24+
env:
25+
NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }}
26+
MOLTBOOK_API_KEY: ${{ secrets.MOLTBOOK_API_KEY }}
27+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
28+
BRAVE_API_KEY: ${{ secrets.BRAVE_API_KEY }}
29+
STATE_DIR: ./state
2630
steps:
27-
- name: 🔄 Checkout
31+
- name: "🔄 Checkout"
2832
uses: actions/checkout@v4
29-
30-
- name: 🐍 Python
33+
with:
34+
fetch-depth: 0
35+
36+
- name: "🐍 Python"
3137
uses: actions/setup-python@v5
3238
with:
33-
python-version: '3.11'
34-
35-
- name: 📦 Install
36-
run: pip install flask
37-
38-
- name: 📥 Restore state
39-
continue-on-error: true
39+
python-version: "3.11"
40+
41+
- name: "📦 Install"
42+
run: pip install -q requests
43+
44+
- name: "📥 Restore state"
4045
run: |
4146
git fetch origin state --depth=1 2>/dev/null || true
4247
if git show-ref --verify --quiet refs/remotes/origin/state; then
43-
git checkout origin/state -- state/ 2>/dev/null || echo "No state"
48+
git checkout origin/state -- state/ 2>/dev/null || mkdir -p state
49+
else
50+
mkdir -p state
4451
fi
45-
46-
- name: 🤖 Run Agent
52+
53+
- name: "🤖 Run Agent"
54+
run: python main.py run
55+
56+
- name: "💾 Save state"
57+
run: |
58+
git config user.name "OpenCLAW Bot"
59+
git config user.email "openclaw-bot@noreply.github.com"
60+
git stash --include-untracked || true
61+
git checkout state 2>/dev/null || git checkout --orphan state
62+
git rm -rf . 2>/dev/null || true
63+
git stash pop 2>/dev/null || true
64+
cp -r state/ . 2>/dev/null || true
65+
git add state/ 2>/dev/null || true
66+
git commit -m "State update $(date -u +%Y-%m-%dT%H:%M)" --allow-empty
67+
git push origin state --force
4768
env:
48-
NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }}
49-
MOLTBOOK_API_KEY: ${{ secrets.MOLTBOOK_API_KEY }}
50-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
51-
BRAVE_API_KEY: ${{ secrets.BRAVE_API_KEY }}
52-
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
53-
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
54-
STATE_DIR: state
55-
run: python main.py ${{ github.event.inputs.command || 'run' }}
56-
57-
- name: 💾 Save state
58-
if: always()
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: "📊 Status"
5972
run: |
60-
git config user.name "OpenCLAW Agent"
61-
git config user.email "openclaw@noreply.github.com"
62-
git stash 2>/dev/null || true
63-
git checkout --orphan state-temp 2>/dev/null || git checkout -b state-temp
64-
git rm -rf --cached . 2>/dev/null || true
65-
git add state/ -f 2>/dev/null || true
66-
git commit -m "🤖 State $(date -u +%Y-%m-%dT%H:%M)" --allow-empty 2>/dev/null || true
67-
git push origin HEAD:state --force 2>/dev/null || echo "Skip"
68-
69-
- name: 📊 Status
70-
if: always()
73+
echo "=== State ==="
74+
cat state/agent_state.json 2>/dev/null || echo "No state"
75+
echo "=== Cycle ==="
76+
cat state/last_cycle.json 2>/dev/null || echo "No cycle"
77+
78+
seed-growth:
79+
if: github.event.schedule == '30 */12 * * *' || github.event.inputs.command == 'seed' || github.event.inputs.command == 'full' || github.event.inputs.command == 'harvest'
80+
runs-on: ubuntu-latest
81+
timeout-minutes: 30
82+
env:
83+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
84+
NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }}
85+
SEED_STATE_DIR: ./seed_state
86+
SEED_DATA_DIR: ./seed_data
87+
steps:
88+
- name: "🔄 Checkout"
89+
uses: actions/checkout@v4
90+
with:
91+
fetch-depth: 0
92+
93+
- name: "🐍 Python"
94+
uses: actions/setup-python@v5
95+
with:
96+
python-version: "3.11"
97+
98+
- name: "📦 Install"
99+
run: pip install -q requests huggingface_hub
100+
101+
- name: "📥 Restore seed state"
102+
run: |
103+
git fetch origin seed-state --depth=1 2>/dev/null || true
104+
if git show-ref --verify --quiet refs/remotes/origin/seed-state; then
105+
git checkout origin/seed-state -- seed_state/ seed_data/ 2>/dev/null || true
106+
fi
107+
mkdir -p seed_state seed_data
108+
109+
- name: "🌱 Run SEED Growth Cycle"
110+
run: |
111+
python -c "
112+
import sys, os, logging
113+
sys.path.insert(0, '.')
114+
logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(levelname)s] %(name)s: %(message)s')
115+
116+
from seed.growth_engine import GrowthEngine
117+
engine = GrowthEngine(
118+
hf_token=os.environ.get('HF_TOKEN', ''),
119+
state_dir='seed_state',
120+
data_dir='seed_data',
121+
)
122+
results = engine.run_cycle()
123+
124+
import json
125+
print('\n📊 SEED Results:')
126+
print(json.dumps(results, indent=2, default=str))
127+
128+
print('\n📊 SEED Status:')
129+
print(json.dumps(engine.get_status(), indent=2, default=str))
130+
"
131+
132+
- name: "💾 Save seed state"
133+
run: |
134+
git config user.name "SEED Bot"
135+
git config user.email "seed-bot@noreply.github.com"
136+
git stash --include-untracked || true
137+
git checkout seed-state 2>/dev/null || git checkout --orphan seed-state
138+
git rm -rf . 2>/dev/null || true
139+
git stash pop 2>/dev/null || true
140+
cp -r seed_state/ . 2>/dev/null || true
141+
cp -r seed_data/ . 2>/dev/null || true
142+
git add seed_state/ seed_data/ 2>/dev/null || true
143+
git commit -m "SEED growth $(date -u +%Y-%m-%dT%H:%M)" --allow-empty
144+
git push origin seed-state --force
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147+
148+
- name: "📊 Seed Status"
71149
run: |
72-
echo "=== State ===" && cat state/agent_state.json 2>/dev/null || true
73-
echo "=== Cycle ===" && cat state/last_cycle.json 2>/dev/null || true
150+
echo "=== SEED Cycle Log ==="
151+
cat seed_state/cycle_log.json 2>/dev/null || echo "No cycle log"
152+
echo ""
153+
echo "=== Growth Log ==="
154+
cat seed_state/growth_log.json 2>/dev/null || echo "No growth log"
155+
echo ""
156+
echo "=== Dataset Size ==="
157+
wc -l seed_data/*.jsonl 2>/dev/null || echo "No data yet"

0 commit comments

Comments
 (0)