Skip to content

Commit 85011e0

Browse files
authored
Merge pull request #24 from madkoding/feat/local-runtime-ws-status
feat(core): consolidar runtime local y estado en tiempo real
2 parents 93c23c4 + 913e66c commit 85011e0

109 files changed

Lines changed: 18765 additions & 2076 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Fractal-Mind Configuration
22

3-
# Database Configuration (SurrealDB)
4-
SURREAL_URL=ws://localhost:8000
3+
# Database Configuration (SurrealDB HTTP endpoint)
4+
SURREAL_URL=http://localhost:8000
55
SURREAL_USER=root
66
SURREAL_PASS=root
77
SURREAL_NS=fractalmind

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,30 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- name: Setup Rust
1515
uses: dtolnay/rust-toolchain@stable
16+
- name: Cache cargo
17+
uses: Swatinem/rust-cache@v2
1618
- name: Run tests
1719
run: cargo test --lib
1820

21+
test-bin:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Setup Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
- name: Cache cargo
28+
uses: Swatinem/rust-cache@v2
29+
- name: Run binary tests
30+
run: cargo test --bins
31+
1932
build:
2033
runs-on: ubuntu-latest
2134
steps:
2235
- uses: actions/checkout@v4
2336
- name: Setup Rust
2437
uses: dtolnay/rust-toolchain@stable
38+
- name: Cache cargo
39+
uses: Swatinem/rust-cache@v2
2540
- name: Build
2641
run: cargo build --release
2742

@@ -31,6 +46,8 @@ jobs:
3146
- uses: actions/checkout@v4
3247
- name: Setup Rust
3348
uses: dtolnay/rust-toolchain@stable
49+
- name: Cache cargo
50+
uses: Swatinem/rust-cache@v2
3451
- name: Clippy
3552
run: cargo clippy -- -D warnings
3653
- name: Format

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Cargo.lock
3232
CREDENTIALS.md
3333
API_KEYS.md
3434
secrets/
35+
config/secrets.json
3536

3637
# Logs
3738
*.log
@@ -46,3 +47,6 @@ Thumbs.db
4647

4748
# Data
4849
data/
50+
*.db
51+
*.db WAL
52+
*.db SHM

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async-trait = "0.1"
1414
async-stream = "0.3"
1515

1616
# Web Framework
17-
axum = { version = "0.7", features = ["macros", "multipart"] }
17+
axum = { version = "0.7", features = ["macros", "multipart", "ws"] }
1818
tower = { version = "0.5", features = ["full"] }
1919
tower-http = { version = "0.5", features = ["trace", "cors", "timeout"] }
2020
http = "1.1"
@@ -71,7 +71,7 @@ tesseract = { version = "0.14", optional = true }
7171
pdf-extract = { version = "0.10", optional = true }
7272

7373
# Clustering algorithms para RAPTOR
74-
linfa = { version = "0.7", optional = true }
74+
linfa = { version = "0.8", optional = true }
7575
linfa-clustering = { version = "0.8", optional = true }
7676

7777
# GGUF model parsing
@@ -83,11 +83,12 @@ sha2 = "0.10"
8383

8484
# Bytes for streaming uploads
8585
bytes = "1.5"
86-
half = "2.7.1"
86+
half = "2.0"
8787

8888
[dev-dependencies]
8989
mockall = "0.13"
9090
criterion = "0.5"
91+
tempfile = "3"
9192

9293
[features]
9394
default = []

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ RUN apt-get update && apt-get install -y \
3737
curl \
3838
&& rm -rf /var/lib/apt/lists/*
3939

40-
# Copy .env and binary from builder
40+
# Copy .env.example and binary from builder
4141
COPY --from=builder /app/target/release/fractalmind /app/fractalmind
42-
COPY .env .env
42+
COPY .env.example .env
4343

4444
# Expose port
4545
EXPOSE 9000
4646

4747
# Health check
4848
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
49-
CMD curl -f http://127.0.0.1:3000/health || exit 1
49+
CMD curl -f http://127.0.0.1:9000/health || exit 1
5050

5151
# Run the application
5252
CMD ["/app/fractalmind"]

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ cd fractalmind
8080
```
8181

8282
**Docker Services:**
83-
- **SurrealDB** (port 8000): Database with persistent SSD storage in `./data/surrealdb/`
84-
- **SearXNG** (port 8080): Local web search for REM phase
85-
- **FractalMind API** (port 9000): Main API server (default: 9000, configurable via SERVER_PORT)
83+
- **SurrealDB** (port 8000): Database with persistent file storage in `./data/surrealdb/fractalmind.db`
84+
- **SearXNG** (port 18080): Local web search for REM phase (`8080` inside Docker network)
85+
- **FractalMind API** (port 12000): Main API server (`9000` inside Docker network)
8686

8787
**Free LLM Models (Ollama Cloud):**
8888
- `nemotron-3-nano` - 30B parameters, excellent for chat/summarization
@@ -97,7 +97,7 @@ cd fractalmind
9797
**SearXNG Integration:**
9898
- automatically included in docker-compose (profile: searxng)
9999
- provides web search for REM phase
100-
- runs on http://localhost:8080
100+
- runs on http://localhost:18080 (host) and http://searxng:8080 (inside Docker)
101101
- if unavailable, REM phase web search disabled (still works with local knowledge)
102102

103103
2. **Build and run**:
@@ -124,7 +124,7 @@ cargo test
124124
cargo test -- --ignored
125125

126126
# Linting
127-
cargo clippy
127+
cargo clippy -- -D warnings
128128

129129
# Formatting
130130
cargo fmt
@@ -172,7 +172,7 @@ Key variables in `.env`:
172172

173173
```bash
174174
# Database
175-
SURREAL_URL=ws://localhost:8000
175+
SURREAL_URL=http://localhost:8000
176176
SURREAL_NS=fractalmind
177177
SURREAL_DB=knowledge
178178

@@ -260,12 +260,12 @@ OLLAMA_API_KEY= # Empty for local
260260

261261
```bash
262262
# Ingest content - FastEmbed handles embeddings automatically
263-
curl -X POST http://localhost:9000/v1/ingest \
263+
curl -X POST http://localhost:12000/v1/ingest \
264264
-H "Content-Type: application/json" \
265265
-d '{"content": "Your text here", "namespace": "global"}'
266266

267267
# Query - embeddings retrieved from DB (no model needed)
268-
curl -X POST http://localhost:9000/v1/ask \
268+
curl -X POST http://localhost:12000/v1/ask \
269269
-d '{"query": "What is this about?", "namespace": "global"}'
270270
```
271271

@@ -289,4 +289,4 @@ curl -X POST http://localhost:9000/v1/ask \
289289
MIT
290290

291291
<!-- AUTO-UPDATE-DATE -->
292-
**Última actualización:** 2026-02-26 15:51:01 -03
292+
**Última actualización:** 2026-04-10

config/secrets.json.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ollama_api_key": ""
3+
}

dev.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,21 @@ start_docker() {
3535
echo -e "${GREEN}✓ Docker containers already running${NC}"
3636
else
3737
# Start searxng by default (profile enabled)
38-
docker-compose up -d surrealdb searxng
38+
docker-compose up -d ollama surrealdb searxng
39+
40+
# Wait for Ollama and pull required local models
41+
sleep 5
42+
echo -e "${YELLOW}Ensuring Ollama local models...${NC}"
43+
docker exec fractalmind-ollama ollama pull qwen3-embedding:0.6b 2>/dev/null || true
44+
docker exec fractalmind-ollama ollama pull llama3.2:1b 2>/dev/null || true
3945

4046
if [ $? -eq 0 ]; then
4147
echo -e "${GREEN}✓ Docker containers started successfully${NC}"
4248
echo ""
4349
echo -e "${GREEN}✅ Services:${NC}"
50+
echo " - ollama: http://localhost:11434"
4451
echo " - surrealdb: http://localhost:8000"
45-
echo " - searxng: http://localhost:8080 (web search)"
52+
echo " - searxng: http://localhost:18080 (web search)"
4653
echo ""
4754
echo -e "${YELLOW}Note:${NC} SearXNG is enabled by default for REM phase web search."
4855
echo " Set WEB_SEARCH_ENABLED=false to disable (REM phase will be off)."
@@ -56,7 +63,7 @@ start_docker() {
5663
# Function to start backend
5764
start_backend() {
5865
echo -e "${YELLOW}Starting backend server...${NC}"
59-
RUST_LOG=debug cargo run --features "$FEATURES" &
66+
RUST_LOG=debug WEB_SEARCH_PROVIDER=searxng WEB_SEARCH_BASE_URL=http://localhost:18080 cargo run --features "$FEATURES" &
6067
BACKEND_PID=$!
6168
echo -e "${GREEN}✓ Backend started (PID: $BACKEND_PID)${NC}"
6269
}
@@ -95,9 +102,9 @@ case "${1:-run}" in
95102
echo ""
96103
echo "Services:"
97104
echo " Database: http://localhost:8000"
98-
echo " SearXNG: http://localhost:8080 (web search)"
99-
echo " Backend: http://localhost:3000"
100-
echo " Frontend: http://localhost:5173 (or configured port)"
105+
echo " SearXNG: http://localhost:18080 (web search)"
106+
echo " Backend: http://localhost:9000"
107+
echo " Frontend: http://localhost:9001"
101108
echo ""
102109
echo "REM Phase:"
103110
echo " ✓ SearXNG is enabled - REM web search active"

docker-compose.yml

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
version: '3.8'
2-
31
services:
2+
ollama:
3+
image: ollama/ollama:latest
4+
container_name: fractalmind-ollama
5+
restart: unless-stopped
6+
ports:
7+
- "11434:11434"
8+
volumes:
9+
- ./data/ollama:/root/.ollama
10+
healthcheck:
11+
test: ["CMD", "curl", "-f", "http://localhost:11434/api/tags"]
12+
interval: 30s
13+
timeout: 10s
14+
retries: 5
15+
start_period: 60s
16+
networks:
17+
- fractalmind-network
18+
419
surrealdb:
520
image: surrealdb/surrealdb:v1.5.6
621
container_name: fractalmind-db
7-
restart: unless-stopped
8-
user: "1000:1000"
9-
# No exposed ports - only accessible via docker network
22+
restart: "no"
23+
ports:
24+
- "8000:8000"
1025
command:
1126
- start
1227
- --log=info
1328
- --user=root
1429
- --pass=root
1530
- --bind
1631
- 0.0.0.0:8000
17-
- memory
32+
- file:///data/fractalmind.db
1833
volumes:
1934
- ./data/surrealdb:/data
2035
environment:
@@ -32,41 +47,49 @@ services:
3247
image: searxng/searxng:latest
3348
container_name: fractalmind-searxng
3449
restart: unless-stopped
35-
# No exposed ports - only accessible via docker network
50+
ports:
51+
- "18080:8080"
3652
volumes:
3753
- ./data/searxng:/etc/searxng
38-
- ./searxng:/searxng
3954
environment:
40-
- SEARXNG_BASE_URL=http://localhost:8080/
55+
- SEARXNG_BASE_URL=http://searxng:8080/
4156
- UWSGI_WORKERS=2
4257
- UWSGI_THREADS=2
58+
healthcheck:
59+
test: ["CMD", "curl", "-f", "http://localhost:8080/healthz"]
60+
interval: 10s
61+
timeout: 5s
62+
retries: 5
63+
start_period: 10s
4364
networks:
4465
- fractalmind-network
4566

46-
# Servicio backend Rust
4767
fractalmind-api:
4868
build:
4969
context: .
5070
dockerfile: Dockerfile
5171
container_name: fractalmind-api
52-
restart: unless-stopped
53-
# Only fractalmind API exposed to host
72+
restart: "no"
5473
ports:
5574
- "12000:9000"
5675
extra_hosts:
5776
- "tachikoma:host-gateway"
5877
depends_on:
5978
surrealdb:
6079
condition: service_healthy
80+
ollama:
81+
condition: service_healthy
6182
environment:
6283
- RUST_LOG=debug,fractalmind=trace
63-
- SURREAL_URL=ws://surrealdb:8000
84+
- SERVER_PORT=9000
85+
- SURREAL_URL=http://surrealdb:8000
6486
- SURREAL_USER=root
6587
- SURREAL_PASS=root
6688
- SURREAL_NS=fractalmind
6789
- SURREAL_DB=knowledge
6890
- WEB_SEARCH_PROVIDER=searxng
6991
- WEB_SEARCH_BASE_URL=http://searxng:8080
92+
- OLLAMA_BASE_URL=http://ollama:11434
7093
volumes:
7194
- ./target:/app/target
7295
networks:
@@ -75,7 +98,3 @@ services:
7598
networks:
7699
fractalmind-network:
77100
driver: bridge
78-
79-
volumes:
80-
surrealdb-data:
81-
searxng-data:

docs/OpenClaw_INTEGRATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ services:
7171
volumes:
7272
- fractalmind-data:/app/data
7373
environment:
74-
- SURREAL_URL=ws://surrealdb:8000
74+
- SURREAL_URL=http://surrealdb:8000
7575
depends_on:
7676
- surrealdb
7777

0 commit comments

Comments
 (0)