106 lines
4.0 KiB
Python
106 lines
4.0 KiB
Python
"""
|
|
Connect: erzeugt saubere, getestete Konfig-Snippets für IDEs/Agenten auf dem
|
|
LOKALEN PC (separate Maschine im LAN). Alle zeigen auf den **Gateway** der Box
|
|
(`model: auto`, Cockpit-Port :9001/v1) + den **Shared-Memory-MCP** (MC :9001).
|
|
|
|
Wichtig: Host ist die LAN-IP der Box (NICHT eine Proxy-Domain) — das war in v1
|
|
die häufigste Fehlerquelle. Der Aufrufer übergibt den Host explizit.
|
|
"""
|
|
|
|
import json
|
|
|
|
from config import PORT
|
|
|
|
DEFAULT_HOST = "192.168.178.151"
|
|
|
|
# Modelle, die der Gateway anbietet (model:auto = Standard).
|
|
GATEWAY_MODELS = ["auto", "fast", "heavy", "coder", "vision"]
|
|
|
|
|
|
def _gw(host: str) -> str:
|
|
# Eingebauter Gateway: MC2 serviert /v1 selbst (gleicher Port wie das Cockpit).
|
|
return f"http://{host}:{PORT}/v1"
|
|
|
|
|
|
def build_snippets(host: str = DEFAULT_HOST,
|
|
mcp_script_path: str = r"F:\\Coding Stuff\\mission-control-2\\mcp\\mcp_memory.py",
|
|
mcp_python: str = "python") -> dict:
|
|
gw = _gw(host)
|
|
mc_url = f"http://{host}:{PORT}"
|
|
|
|
cline = json.dumps({
|
|
"apiProvider": "openai",
|
|
"openAiBaseUrl": gw,
|
|
"openAiApiKey": "local",
|
|
"openAiModelId": "auto",
|
|
}, indent=2)
|
|
|
|
opencode = json.dumps({
|
|
"providers": {
|
|
"litellm": {
|
|
"npm": "@ai-sdk/openai-compatible",
|
|
"name": "Bosgame Gateway",
|
|
"options": {"baseURL": gw, "apiKey": "local"},
|
|
"models": {m: {"name": m} for m in GATEWAY_MODELS},
|
|
}
|
|
}
|
|
}, indent=2)
|
|
|
|
zed = json.dumps({
|
|
"language_models": {
|
|
"openai_compatible": {
|
|
"bosgame": {
|
|
"api_url": gw,
|
|
"available_models": [
|
|
{"name": m, "display_name": m, "max_tokens": 131072,
|
|
"capabilities": {"tools": True}} for m in GATEWAY_MODELS
|
|
],
|
|
}
|
|
}
|
|
}
|
|
}, indent=2)
|
|
|
|
cont = json.dumps({
|
|
"models": [
|
|
{"title": f"Bosgame / {m}", "provider": "openai", "model": m,
|
|
"apiBase": gw, "apiKey": "local"} for m in ("auto", "coder", "heavy")
|
|
]
|
|
}, indent=2)
|
|
|
|
# Claude Code spricht Anthropic-Format; der eingebaute Gateway ist OpenAI-kompatibel.
|
|
claude_code = (
|
|
f"# Der eingebaute Gateway ist OpenAI-kompatibel ({gw}, model: auto).\n"
|
|
f"# Claude Code nutzt das Anthropic-Format — dafür braucht es einen Anthropic-Shim\n"
|
|
f"# (z.B. LiteLLM /v1/messages) als Aufsatz. Für lokale Modelle direkt: Cline / OpenCode /\n"
|
|
f"# Continue / Zed nutzen (oben), die sprechen OpenAI-kompatibel mit diesem Gateway."
|
|
)
|
|
|
|
memory_mcp = json.dumps({
|
|
"mcpServers": {
|
|
"mission-control-memory": {
|
|
"command": mcp_python,
|
|
"args": [mcp_script_path],
|
|
"env": {"MC_URL": mc_url},
|
|
}
|
|
}
|
|
}, indent=2)
|
|
|
|
return {
|
|
"host": host,
|
|
"gateway_url": gw,
|
|
"tools": {
|
|
"cline": {"label": "Roo Code / Cline (VS Code)", "lang": "json", "snippet": cline,
|
|
"note": "OpenAI-Provider → Gateway. Modell 'auto' (schnell, eskaliert bei Bedarf)."},
|
|
"opencode": {"label": "OpenCode", "lang": "jsonc", "snippet": opencode,
|
|
"note": "Datei opencode.jsonc, Key 'providers'."},
|
|
"zed": {"label": "Zed", "lang": "json", "snippet": zed,
|
|
"note": "settings.json → language_models.openai_compatible."},
|
|
"continue": {"label": "Continue", "lang": "json", "snippet": cont,
|
|
"note": "~/.continue/config.json."},
|
|
"claude_code": {"label": "Claude Code", "lang": "bash", "snippet": claude_code,
|
|
"note": "Anthropic-Format über LiteLLM /v1/messages."},
|
|
"memory_mcp": {"label": "Shared Memory (MCP)", "lang": "json", "snippet": memory_mcp,
|
|
"note": "Für jedes MCP-fähige Tool. mcp_memory.py muss lokal liegen."},
|
|
},
|
|
}
|