-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathintegrate.py
More file actions
277 lines (250 loc) · 11.6 KB
/
Copy pathintegrate.py
File metadata and controls
277 lines (250 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
"""Integration script — wires all components together.
Creates unified config, registers services, and sets up the
coordinator entry point.
Usage:
python integrate.py # generate configs
python integrate.py --verify # verify all services reachable
python integrate.py --status # show integrated system status
"""
import json
import os
import sys
from pathlib import Path
ROOT = Path(__file__).parent
CONFIG_DIR = ROOT / "config"
PROXY_PORT = int(os.environ.get("PROXY_PORT", "8100"))
MEMORY_PORT = int(os.environ.get("MEMORY_PORT", "8110"))
AGENTS_PORT = int(os.environ.get("AGENTS_PORT", "8120"))
REGISTRY_PORT = int(os.environ.get("REGISTRY_PORT", "8130"))
RAG_PORT = int(os.environ.get("RAG_PORT", "8140"))
BRAIN_PORT = int(os.environ.get("BRAIN_PORT", "8150"))
SKILL_PORT = int(os.environ.get("SKILL_PORT", "8160"))
def generate_configs():
"""Generate all integration config files."""
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
# 1. Unified proxy config (opencodex-style)
proxy_config = {
"version": "1.0",
"default_provider": "anthropic",
"default_model": "claude-sonnet-4-5",
"proxy_port": PROXY_PORT,
"providers": {
"anthropic": {
"enabled": True,
"base_url": "https://api.anthropic.com",
"key_env": "ANTHROPIC_API_KEY",
"models": ["claude-opus-4-6", "claude-sonnet-4-5",
"claude-haiku-4-5"],
"task_profiles": {
"coding": "claude-opus-4-6",
"reasoning": "claude-opus-4-6",
"quick": "claude-haiku-4-5",
"creative": "claude-sonnet-4-5",
},
},
"openai": {
"enabled": True,
"base_url": "https://api.openai.com/v1",
"key_env": "OPENAI_API_KEY",
"models": ["gpt-4o", "gpt-4o-mini", "o3-mini"],
"task_profiles": {
"coding": "gpt-4o",
"reasoning": "o3-mini",
"quick": "gpt-4o-mini",
},
},
"google": {
"enabled": True,
"base_url": "https://generativelanguage.googleapis.com/v1beta",
"key_env": "GOOGLE_API_KEY",
"models": ["gemini-2.5-pro", "gemini-2.5-flash"],
"task_profiles": {
"coding": "gemini-2.5-pro",
"quick": "gemini-2.5-flash",
},
},
"deepseek": {
"enabled": True,
"base_url": "https://api.deepseek.com/v1",
"key_env": "DEEPSEEK_API_KEY",
"models": ["deepseek-chat", "deepseek-reasoner",
"deepseek-coder"],
"task_profiles": {
"coding": "deepseek-coder",
"reasoning": "deepseek-reasoner",
"quick": "deepseek-chat",
},
},
"groq": {
"enabled": True,
"base_url": "https://api.groq.com/openai/v1",
"key_env": "GROQ_API_KEY",
"models": ["llama-3.3-70b-versatile", "qwen/qwen3-32b",
"llama-3.1-8b-instant"],
"task_profiles": {
"coding": "llama-3.3-70b-versatile",
"quick": "llama-3.1-8b-instant",
},
},
"ollama": {
"enabled": False,
"base_url": "http://localhost:11434/v1",
"key_env": None,
"models": ["qwen2.5-coder", "llama3.2", "deepseek-coder"],
},
},
"routing": {
"coding": ["anthropic/claude-opus-4-6", "openai/gpt-4o",
"deepseek/deepseek-coder", "groq/llama-3.3-70b-versatile"],
"reasoning": ["anthropic/claude-opus-4-6", "openai/o3-mini",
"google/gemini-2.5-pro", "deepseek/deepseek-reasoner"],
"quick": ["google/gemini-2.5-flash", "openai/gpt-4o-mini",
"groq/llama-3.1-8b-instant"],
"creative": ["anthropic/claude-sonnet-4-5", "openai/gpt-4o"],
},
"rate_limit": {"capacity": 60, "refill_per_min": 60},
"timeout_s": 300,
}
(CONFIG_DIR / "proxy.json").write_text(
json.dumps(proxy_config, indent=2), encoding="utf-8")
# 2. Agent brain config
brain_config = {
"enabled": True,
"tier_defaults": {
"reflex": {"max_latency_ms": 100, "llm_calls": 0},
"instinct": {"max_latency_ms": 3000, "llm_calls": 1},
"deliberation": {"max_latency_ms": 30000, "llm_calls": 10},
},
"reflex_patterns": [
{"pattern": r"\b(status|health)\b", "tier": "reflex"},
{"pattern": r"\b(list|show)\s+(models|agents|plugins)\b", "tier": "reflex"},
{"pattern": r"\b(time|date)\b", "tier": "reflex"},
{"pattern": r"\b(help|what can you do)\b", "tier": "reflex"},
],
"instinct_keywords": ["hello", "hi", "thanks", "ok", "explain", "what is"],
"deliberation_keywords": [
"implement", "build", "create", "analyze", "debug",
"optimize", "refactor", "compare", "research",
],
}
(CONFIG_DIR / "agent_brain.json").write_text(
json.dumps(brain_config, indent=2), encoding="utf-8")
# 3. Swarm config
swarm_config = {
"max_agents": 5,
"worktree_base": ".swarm/worktrees",
"merge_strategy": "dependency_ordered",
"poll_interval_s": 5,
"timeout_s": 1800,
"memory_guard": {"min_ram_gb": 4.0, "max_swap_gb": 1.0},
}
(CONFIG_DIR / "swarm.json").write_text(
json.dumps(swarm_config, indent=2), encoding="utf-8")
# 4. Service registry (all internal services)
services = {
"proxy": {"port": PROXY_PORT, "module": "proxy.proxy", "url": f"http://localhost:{PROXY_PORT}"},
"memory": {"port": MEMORY_PORT, "module": "memory.memory_api", "url": f"http://localhost:{MEMORY_PORT}"},
"agents": {"port": AGENTS_PORT, "module": "agents.specialized.agents_api", "url": f"http://localhost:{AGENTS_PORT}"},
"registry": {"port": REGISTRY_PORT, "module": "plugins.registry.registry_api", "url": f"http://localhost:{REGISTRY_PORT}"},
"rag": {"port": RAG_PORT, "module": "rag.service", "url": f"http://localhost:{RAG_PORT}"},
"brain": {"port": BRAIN_PORT, "module": "brain.brain", "url": f"http://localhost:{BRAIN_PORT}"},
"skills": {"port": SKILL_PORT, "module": "skills.skill_api", "url": f"http://localhost:{SKILL_PORT}"},
"pipeline": {"port": 8170, "module": "pipeline.api", "url": "http://localhost:8170"},
"dashboard": {"port": 8080, "module": "dashboard.backend", "url": "http://localhost:8080"},
"autonomous": {"port": 8050, "module": "autonomous.api", "url": "http://localhost:8050"},
}
(CONFIG_DIR / "services.json").write_text(
json.dumps(services, indent=2), encoding="utf-8")
# 5. Skills mapping
skills_config = {
"paths": [
str(ROOT / "skills"),
str(ROOT / ".opencode" / "skill"),
],
"auto_load": ["orchestrate", "rate-limit-retry", "self-heal",
"repo-maintenance", "research", "code-review"],
"categories": {
"coding": ["binary-patching-for-ai-providers", "debugging-hermes-tui-commands",
"gui-component-integration", "python-debugpy",
"systematic-debugging", "test-driven-development",
"writing-plans"],
"agents": ["agent-autonomy-kit", "agent-team-orchestration",
"self-improving-agent"],
"creative": ["ascii-art", "comfyui", "design-md", "manim-video",
"pixel-art"],
"devops": ["kanban-orchestrator", "kanban-worker", "webhook-subscriptions"],
"github": ["github-code-review", "github-issues", "github-pr-workflow"],
"productivity": ["notion", "linear", "obsidian"],
"mlops": ["llama-cpp", "vllm", "dspy"],
},
}
(CONFIG_DIR / "skills.json").write_text(
json.dumps(skills_config, indent=2), encoding="utf-8")
print(f"[integrate] Generated {len(list(CONFIG_DIR.glob('*.json')))} config files")
services["skills"] = {"port": SKILL_PORT, "module": "skills.skill_api",
"url": f"http://localhost:{SKILL_PORT}",
"dashboard": str(ROOT / "skills" / "dashboard.html")}
return services
def verify_services(services):
"""Check all services are reachable."""
import requests
results = {}
for name, svc in services.items():
try:
r = requests.get(f"{svc['url']}/health", timeout=3)
results[name] = {"status": r.status_code, "healthy": r.ok}
except Exception as exc:
results[name] = {"status": 0, "healthy": False, "error": "health check failed"}
return results
def print_status(services, verify=True):
"""Print integrated system status."""
print("\n" + "=" * 60)
print(" FreeAI AI Development Environment — Integration Status")
print("=" * 60)
for name, svc in services.items():
status = "RUNNING" if verify and verify_services({name: svc})[name]["healthy"] else "STOPPED"
icon = "\u2713" if status == "RUNNING" else " "
print(f" [{icon}] {name:12s} :{svc['port']} {status}")
print("-" * 60)
print(" Components:")
print(" - Unified LLM Proxy (40+ providers)")
print(" - Agent Brain (3-tier routing: Reflex/Instinct/Deliberation)")
print(" - Agent Zero Memory (persistent, cross-session)")
print(" - 7 Specialized Agents (Orchestrator, Explorer, Oracle, etc.)")
print(" - Plugin Registry (awesome-opencode compatible)")
print(" - RAG Service (BM25 + vector hybrid)")
print(" - Swarm Orchestrator (parallel agents, worktree isolation)")
print(" - Skills System (agent-toolkit, 100+ skills)")
print(" - AutoSkill Monitor (pattern detection, auto SKILL.md creation)")
print(" - Custom Pipeline API (scaffold/refactor/debug/analyze/review/document)")
print(" - Autonomous SDLC (7-phase lifecycle: Plan→Code→Test→Fix→Review→Doc→Package)")
print(" - Skills Manager Dashboard (browse, edit, manage skills)")
print("=" * 60)
def main():
import argparse
parser = argparse.ArgumentParser(description="FreeAI Integration")
parser.add_argument("--verify", action="store_true",
help="Verify all services are running")
parser.add_argument("--status", action="store_true",
help="Show system status")
parser.add_argument("--generate", action="store_true",
help="Generate config files only")
args = parser.parse_args()
services = generate_configs()
if args.generate:
print("[integrate] Config generation complete.")
return
if args.verify:
results = verify_services(services)
all_healthy = all(r["healthy"] for r in results.values())
for name, r in results.items():
icon = "\u2713" if r["healthy"] else "\u2717"
print(f" [{icon}] {name}: {'healthy' if r['healthy'] else 'unreachable'}")
sys.exit(0 if all_healthy else 1)
if args.status:
print_status(services, verify=False)
return
# Default: generate + show status
print_status(services, verify=True)
if __name__ == "__main__":
main()