mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
fix: Add WORKER_1 and WORKER_2 env vars to remote sandbox service (#12424)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -30,6 +30,20 @@ GLOBAL_SKILLS_DIR = os.path.join(
|
||||
WORK_HOSTS_SKILL = """The user has access to the following hosts for accessing a web application,
|
||||
each of which has a corresponding port:"""
|
||||
|
||||
WORK_HOSTS_SKILL_FOOTER = """
|
||||
When starting a web server, use the corresponding ports via environment variables:
|
||||
- $WORKER_1 for the first port
|
||||
- $WORKER_2 for the second port
|
||||
|
||||
**CRITICAL: You MUST enable CORS and bind to 0.0.0.0.** Without CORS headers, the App tab cannot detect your server and will show an empty state.
|
||||
|
||||
Example (Flask):
|
||||
```python
|
||||
from flask_cors import CORS
|
||||
CORS(app)
|
||||
app.run(host='0.0.0.0', port=int(os.environ.get('WORKER_1', 12000)))
|
||||
```"""
|
||||
|
||||
|
||||
def _find_and_load_global_skill_files(skill_dir: Path) -> list[Skill]:
|
||||
"""Find and load all .md files from the global skills directory.
|
||||
@@ -73,6 +87,7 @@ def load_sandbox_skills(sandbox: SandboxInfo) -> list[Skill]:
|
||||
content_list = [WORK_HOSTS_SKILL]
|
||||
for url in urls:
|
||||
content_list.append(f'* {url.url} (port {url.port})')
|
||||
content_list.append(WORK_HOSTS_SKILL_FOOTER)
|
||||
content = '\n'.join(content_list)
|
||||
return [Skill(name='work_hosts', content=content, trigger=None)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user