Skip to content

Commit 5ab13da

Browse files
committed
feat: comprehensive codebase improvements and features
Major enhancements across the entire codebase: **Security & Authentication:** - Add UI authentication system (LoginPage, useAuth hook, auth endpoints) - Implement security self-protection module - Add heartbeat service for monitoring - Add UI session middleware and service **Channel System:** - Add message normalizers (base, telegram) with comprehensive tests - Enhance channel service implementation - Improve attachment handling **Database & Migration:** - Fix unused variable warnings in seed-database script - Improve migration script error handling - Add database adapter improvements **AI Provider Updates:** - Update provider configs (alibaba, azure, github-copilot, opencode, siliconflow, togetherai, venice) - Add new provider capabilities **Core Services:** - Add file-system tool improvements - Enhance event system - Improve sandbox code validator - Add security index exports **Documentation:** - Update API routes documentation - Revise architecture docs - Update UI components documentation **Infrastructure:** - Update Docker configuration - Improve docker-compose setup - Update package.json dependencies - Add version bump scripts **Code Quality:** - Remove _fix.js temporary file - Clean up unused code - Improve error handling across services Includes 100+ new files and extensive refactoring across all packages.
1 parent c9900a6 commit 5ab13da

93 files changed

Lines changed: 3334 additions & 1291 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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ NODE_ENV=development
2121
# ===========================================
2222
# Database (PostgreSQL)
2323
# ===========================================
24-
# Option 1: Full connection URL
24+
# These defaults match docker-compose.yml so both paths work out of the box.
25+
#
26+
# Option 1: Full connection URL (overrides individual settings)
2527
# DATABASE_URL=postgresql://ownpilot:ownpilot_secret@localhost:25432/ownpilot
2628

2729
# Option 2: Individual settings
30+
# For "From Source" dev: localhost + exposed port 25432
31+
# For Docker: docker-compose.yml hardcodes host=postgres, port=5432 internally
2832
POSTGRES_HOST=localhost
2933
POSTGRES_PORT=25432
3034
POSTGRES_USER=ownpilot
31-
POSTGRES_PASSWORD=your-secure-password-here
35+
POSTGRES_PASSWORD=ownpilot_secret
3236
POSTGRES_DB=ownpilot
3337
# POSTGRES_POOL_SIZE=10
3438
# DB_VERBOSE=false

Dockerfile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,34 @@ RUN pnpm install --frozen-lockfile --prod
5656

5757
# Copy built files from builder
5858
COPY --from=builder /app/packages/core/dist ./packages/core/dist
59+
COPY --from=builder /app/packages/core/data ./packages/core/data
5960
COPY --from=builder /app/packages/gateway/dist ./packages/gateway/dist
61+
COPY --from=builder /app/packages/gateway/data ./packages/gateway/data
6062
COPY --from=builder /app/packages/channels/dist ./packages/channels/dist
6163
COPY --from=builder /app/packages/cli/dist ./packages/cli/dist
6264

6365
# Copy UI static assets (no node_modules needed — pre-built by Vite)
6466
COPY --from=builder /app/packages/ui/dist ./packages/ui/dist
6567

68+
# Create non-root user
69+
RUN addgroup -g 1001 -S ownpilot && adduser -S ownpilot -u 1001 -G ownpilot
70+
71+
# Create data directory with proper ownership
72+
RUN mkdir -p /app/data && chown -R ownpilot:ownpilot /app/data
73+
6674
# Set environment variables
6775
ENV NODE_ENV=production
6876
ENV PORT=8080
6977
ENV HOST=0.0.0.0
7078

79+
# Switch to non-root user
80+
USER ownpilot
81+
7182
# Expose port
7283
EXPOSE 8080
7384

7485
# Health check
75-
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
86+
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
7687
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
7788

7889
# OCI labels for GHCR

README.md

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,19 @@ All messages (web UI chat, Telegram, trigger-initiated chats) flow through the s
162162
```bash
163163
git clone https://github.com/ownpilot/ownpilot.git
164164
cd ownpilot
165-
cp .env.example .env
166165

167-
# Start OwnPilot + PostgreSQL
166+
# Start OwnPilot + PostgreSQL (uses defaults, no .env needed)
168167
docker compose --profile postgres up -d
169168

170169
# UI + API: http://localhost:8080
171170
```
172171

173-
Or use the pre-built image:
172+
To customize settings (auth, Telegram, etc.), copy and edit `.env` before starting:
174173

175174
```bash
176-
docker pull ghcr.io/ownpilot/ownpilot:latest
175+
cp .env.example .env
176+
# Edit .env — docker-compose.yml defaults match .env.example
177+
docker compose --profile postgres up -d
177178
```
178179

179180
### From Source
@@ -182,7 +183,7 @@ docker pull ghcr.io/ownpilot/ownpilot:latest
182183

183184
- **Node.js** >= 22.0.0
184185
- **pnpm** >= 10.0.0
185-
- **PostgreSQL** (via Docker or native)
186+
- **PostgreSQL** 16+ (via Docker Compose or native install)
186187

187188
#### Setup
188189

@@ -194,8 +195,10 @@ pnpm install
194195

195196
# Configure
196197
cp .env.example .env
197-
# Edit .env with database connection details
198-
# AI provider API keys are configured via the Config Center UI after setup
198+
# Edit .env if needed (defaults work with docker compose PostgreSQL)
199+
200+
# Start PostgreSQL (if you don't have one already)
201+
docker compose --profile postgres up -d
199202

200203
# Start development (gateway + ui)
201204
pnpm dev
@@ -204,6 +207,8 @@ pnpm dev
204207
# API: http://localhost:8080
205208
```
206209

210+
AI provider API keys are configured via the **Config Center UI** (Settings page) after setup.
211+
207212
### Configuration via CLI
208213

209214
```bash
@@ -448,23 +453,35 @@ All API keys are managed via the **Config Center UI** (Settings page) or the `ow
448453

449454
### Supported Providers
450455

451-
| Provider | Integration Type | Key Models |
452-
| ------------------ | ------------------------------ | --------------------------------------------------------------------- |
453-
| **OpenAI** | Native | GPT-4o, GPT-4o-mini, o1, o3-mini |
454-
| **Anthropic** | Native (with prompt caching) | Claude Sonnet 4.6, Claude Opus 4.6, Claude 3.7 Sonnet, Claude 3 Haiku |
455-
| **Google** | Native (with OAuth) | Gemini 2.0 Flash, Gemini 1.5 Pro |
456-
| **Zhipu AI** | Native | GLM-4 |
457-
| **Together AI** | Aggregator (OpenAI-compatible) | Llama 3.3 70B, DeepSeek R1/V3, Qwen 2.5 Coder |
458-
| **Groq** | Aggregator (ultra-fast LPU) | Llama 3.3 70B, Mixtral 8x7B, Gemma 2 9B |
459-
| **Fireworks AI** | Aggregator | Llama 3.3 70B, Qwen 2.5, FLUX image models |
460-
| **DeepInfra** | Aggregator | Serverless open-source inference |
461-
| **OpenRouter** | Aggregator | Unified API for all providers |
462-
| **Perplexity** | Aggregator | Sonar Pro, Sonar Reasoning (with citations) |
463-
| **Cerebras** | Aggregator (fastest inference) | Llama 3.3 70B, Llama 3.1 8B |
464-
| **fal.ai** | Aggregator (image/video) | FLUX Pro/Dev/Schnell, Stable Diffusion, Recraft v3 |
465-
| **Ollama** | Local (auto-discovered) | Any GGUF model |
466-
| **LM Studio** | Local (auto-discovered) | Any loaded model |
467-
| **LocalAI / vLLM** | Local | Self-hosted models |
456+
**96 providers** with auto-synced model catalogs from [models.dev](https://models.dev). Key providers:
457+
458+
| Provider | Integration Type | Key Models |
459+
| --- | --- | --- |
460+
| **OpenAI** | Native | GPT-5.3 Codex, GPT-5.2, GPT-5.1, o4-mini, o3 |
461+
| **Anthropic** | Native (prompt caching) | Claude Sonnet 4.6, Claude Opus 4.6, Claude Sonnet 4.5, Claude Haiku 4.5 |
462+
| **Google** | Native | Gemini 3.1 Pro, Gemini 3 Flash, Gemini 2.5 Flash/Pro |
463+
| **xAI** | Native | Grok 4.1 Fast, Grok 4, Grok 3 |
464+
| **DeepSeek** | Native | DeepSeek Chat, DeepSeek Reasoner |
465+
| **Mistral** | Native | Devstral 2, Mistral Medium 3.1, Mistral Large 3, Codestral |
466+
| **Zhipu AI** | Native | GLM-5, GLM-4.7, GLM-4.6 |
467+
| **Cohere** | Native | Command A, Command A Reasoning, Command R+ |
468+
| **Together AI** | Aggregator | Qwen3.5 397B, GLM-5, Kimi K2.5, DeepSeek V3.1 |
469+
| **Groq** | Aggregator (LPU) | Kimi K2, GPT OSS 120B, Llama 4 Scout, Qwen3 32B |
470+
| **Fireworks AI** | Aggregator | MiniMax-M2.5, GLM 5, Kimi K2.5, DeepSeek V3.2 |
471+
| **DeepInfra** | Aggregator | Kimi K2.5, GLM-4.7, DeepSeek-V3.2, Qwen3 Coder |
472+
| **OpenRouter** | Aggregator (161+ models) | Unified API for all providers |
473+
| **Perplexity** | Aggregator | Sonar Deep Research, Sonar Pro, Sonar Reasoning Pro |
474+
| **Cerebras** | Aggregator (fastest) | GLM-4.7, GPT OSS 120B, Qwen 3 235B |
475+
| **NVIDIA** | Aggregator (65+ models) | GLM5, Kimi K2.5, DeepSeek V3.2, Nemotron |
476+
| **Amazon Bedrock** | Cloud (96+ models) | Claude 4.6, DeepSeek-V3.2, Kimi K2.5, Nova Pro |
477+
| **Azure** | Cloud (85+ models) | GPT-5.2, Claude 4.6, DeepSeek-V3.2, Grok 4 |
478+
| **GitHub Models** | Cloud | GPT-4.1, DeepSeek-R1, Llama 4, Mistral |
479+
| **Hugging Face** | Aggregator | MiniMax-M2.5, GLM-5, Qwen3.5, DeepSeek-V3.2 |
480+
| **SiliconFlow** | Aggregator (66+ models) | GLM-5, Kimi K2.5, DeepSeek V3.2, Qwen3 VL |
481+
| **Novita AI** | Aggregator (80+ models) | Qwen3.5, GLM-5, Kimi K2.5, ERNIE-4.5 |
482+
| **Nebius** | Aggregator (45+ models) | DeepSeek-V3.2, GLM-4.7, Qwen3, FLUX |
483+
| **Ollama** | Local | qwen3.5, minimax-m2.5, glm-5, kimi-k2.5 |
484+
| **LM Studio** | Local | GPT OSS 20B, Qwen3 30B, Qwen3 Coder 30B |
468485

469486
Any OpenAI-compatible endpoint can be added as a custom provider.
470487

@@ -1015,7 +1032,7 @@ NODE_ENV=development
10151032
POSTGRES_HOST=localhost
10161033
POSTGRES_PORT=25432
10171034
POSTGRES_USER=ownpilot
1018-
POSTGRES_PASSWORD=ownpilot_secret
1035+
POSTGRES_PASSWORD=ownpilot_secret # Change in production
10191036
POSTGRES_DB=ownpilot
10201037
# POSTGRES_POOL_SIZE=10
10211038
# DB_VERBOSE=false

_fix.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

docker-compose.db.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# Default credentials: ownpilot / ownpilot_secret
66
#
77
# Then in your .env:
8-
# DB_TYPE=postgres
98
# POSTGRES_HOST=localhost
109
# POSTGRES_PORT=25432
1110
# POSTGRES_USER=ownpilot

docker-compose.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.8'
2-
31
services:
42
# PostgreSQL Database
53
postgres:
@@ -42,9 +40,9 @@ services:
4240
- PORT=8080
4341
- HOST=0.0.0.0
4442
- OWNPILOT_DATA_DIR=/app/data
45-
# Database
43+
# Database (always connects to the postgres service inside Docker network)
4644
- DATABASE_URL=${DATABASE_URL:-}
47-
- POSTGRES_HOST=${POSTGRES_HOST:-postgres}
45+
- POSTGRES_HOST=postgres
4846
- POSTGRES_PORT=5432
4947
- POSTGRES_USER=${POSTGRES_USER:-ownpilot}
5048
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-ownpilot_secret}

docs/API_ROUTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ LLM usage cost tracking and budget management. Tracks tokens, costs, latency, an
939939
**Mount:** `/api/v1/channels`
940940
**Source:** `packages/gateway/src/routes/channels.ts`
941941

942-
Communication channel management for Telegram, Discord, Slack, and other messaging platforms. Manages channel configurations, message inbox, and webhook endpoints.
942+
Communication channel management for Telegram. Manages channel configurations, message inbox, and webhook endpoints.
943943

944944
### Endpoints
945945

docs/ARCHITECTURE.md

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ OwnPilot is a self-hosted, privacy-first personal AI assistant platform. It conn
6969
+---------------------------------------------------------------------------+
7070
| |
7171
| CLIENTS |
72-
| +----------+ +----------+ +----------+ +----------+ +----------+ |
73-
| | Web UI | | CLI | | Telegram | | Discord | | Slack | |
74-
| | (React) | |(commander| | (grammy)| |(discord.js| |(@slack/ | |
75-
| | | |inquirer) | | | | | | bolt) | |
76-
| +----+-----+ +----+-----+ +----+-----+ +----+-----+ +----+-----+ |
77-
| | | | | | |
78-
| | HTTP/WS | HTTP | Events | Events | Events |
79-
| +------+------+------+------+------+------+------+-----+ |
80-
| | | | |
72+
| +----------+ +----------+ +----------+ |
73+
| | Web UI | | CLI | | Telegram | |
74+
| | (React) | |(commander| | (grammy)| |
75+
| | | |inquirer) | | | |
76+
| +----+-----+ +----+-----+ +----+-----+ |
77+
| | | | |
78+
| | HTTP/WS | HTTP | Events |
79+
| +------+------+------+------+ |
80+
| | | |
8181
+---------------|--------------------|--------------------|------------------+
8282
v v v
8383
+---------------------------------------------------------------------------+
@@ -190,7 +190,7 @@ ownpilot/
190190
| | | |-- assistant/ # Gateway-level assistant orchestrator
191191
| | | |-- audit/ # Audit trail persistence
192192
| | | |-- autonomy/ # Autonomy levels and risk assessment
193-
| | | |-- channels/ # Channel adapters (Discord, Slack, Telegram)
193+
| | | |-- channels/ # Channel adapters (Telegram)
194194
| | | |-- db/ # Database layer
195195
| | | | |-- adapters/ # PostgreSQL adapter (DatabaseAdapter interface)
196196
| | | | |-- migrations/ # SQL schema migrations (47 tables)
@@ -285,16 +285,14 @@ Detailed dependency table:
285285
| ws | ^8.19 | gateway | WebSocket server |
286286
| jose | ^6.0 | gateway | JWT authentication |
287287
| dotenv | ^16.4 | gateway | Environment variable loading |
288-
| discord.js | ^14.16 | gateway | Discord channel adapter |
289-
| @slack/bolt | ^4.1 | gateway | Slack channel adapter |
290288
| nodemailer | ^7.0 | gateway | Email sending |
291289
| imapflow | ^1.2 | gateway | Email receiving (IMAP) |
292290
| archiver | ^7.0 | gateway | File archival |
293291
| grammy | ^1.36 | channels | Telegram bot framework |
294292
| react | ^19.0 | ui | UI framework |
295293
| react-router-dom | ^7.1 | ui | Client-side routing |
296294
| tailwindcss | ^4.0 | ui | Utility-first CSS |
297-
| vite | ^6.0 | ui | Build tool and dev server |
295+
| vite | ^7.3 | ui | Build tool and dev server |
298296
| commander | ^13.1 | cli | CLI framework |
299297
| @inquirer/prompts | ^7.0 | cli | Interactive CLI prompts |
300298
| vitest | ^2.1 | all | Test framework (dev) |
@@ -1090,15 +1088,9 @@ The `ChannelManager` (`packages/gateway/src/channels/manager.ts`) provides a uni
10901088

10911089
**Supported Channel Types:**
10921090

1093-
| Channel | Library | Adapter Location |
1094-
| -------- | ----------- | --------------------------------------------------- |
1095-
| Telegram | grammy | `packages/channels/src/telegram/bot.ts` |
1096-
| Discord | discord.js | `packages/gateway/src/channels/adapters/discord.ts` |
1097-
| Slack | @slack/bolt | `packages/gateway/src/channels/adapters/slack.ts` |
1098-
| WhatsApp | (planned) | -- |
1099-
| Matrix | (planned) | -- |
1100-
| Signal | (planned) | -- |
1101-
| Webchat | (built-in) | Via WebSocket |
1091+
| Channel | Library | Adapter Location |
1092+
| -------- | ------- | --------------------------------------- |
1093+
| Telegram | grammy | `packages/channels/src/telegram/bot.ts` |
11021094

11031095
**Architecture:**
11041096

@@ -1114,11 +1106,9 @@ The `ChannelManager` (`packages/gateway/src/channels/manager.ts`) provides a uni
11141106
| send(message) |
11151107
+------------------------------+
11161108
|
1117-
+------------+------------+
1118-
| | |
1119-
TelegramAdapter DiscordAdapter SlackAdapter
1120-
| | |
1121-
grammy Bot discord.js @slack/bolt
1109+
TelegramAdapter
1110+
|
1111+
grammy Bot
11221112
```
11231113

11241114
Each adapter converts platform-specific messages into the unified `IncomingMessage` / `OutgoingMessage` types defined in `packages/gateway/src/ws/types.ts`.
@@ -1215,7 +1205,7 @@ The frontend is a single-page application built with modern React.
12151205
| -------------------- | ------- | ----------------------------------- |
12161206
| React | 19.x | UI framework |
12171207
| React Router | 7.x | Client-side routing |
1218-
| Vite | 6.x | Build tool and dev server |
1208+
| Vite | 7.x | Build tool and dev server |
12191209
| Tailwind CSS | 4.x | Utility-first CSS framework |
12201210
| @tailwindcss/vite | 4.x | Vite integration for Tailwind |
12211211
| prism-react-renderer | 2.x | Syntax highlighting for code blocks |
@@ -1560,8 +1550,6 @@ Channel adapters use factories for registration:
15601550

15611551
```typescript
15621552
channelManager.registerFactory('telegram', (config) => new TelegramAdapter(config));
1563-
channelManager.registerFactory('discord', (config) => new DiscordAdapter(config));
1564-
channelManager.registerFactory('slack', (config) => new SlackAdapter(config));
15651553

15661554
// Later:
15671555
const adapter = await channelManager.connect({ type: 'telegram', id: '...', ... });
@@ -1800,7 +1788,6 @@ pnpm --filter @ownpilot/cli start
18001788
| `HOST` | No | `0.0.0.0` | HTTP server bind address |
18011789
| `DATA_DIR` | No | `./data` | Persistent data directory |
18021790
| **Database** | | | |
1803-
| `DB_TYPE` | No | `postgres` | Database type (PostgreSQL only) |
18041791
| `DATABASE_URL` | No | -- | PostgreSQL connection string |
18051792
| `POSTGRES_HOST` | No | `postgres` | PostgreSQL host |
18061793
| `POSTGRES_PORT` | No | `5432` | PostgreSQL port |

0 commit comments

Comments
 (0)