Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
220d46f
feat(v3): add core interface contracts and migration for v3 redesign
viettranx Apr 6, 2026
2d13aaf
refactor(plans): mark all v3 design phases complete with file references
viettranx Apr 6, 2026
ea6346e
fix(v3): address code review findings on design contracts
viettranx Apr 6, 2026
4ec83b3
fix(v3): second-pass review fixes
viettranx Apr 6, 2026
c66b6ad
feat(v3): implement DomainEventBus with worker pool, dedup, and retry
viettranx Apr 6, 2026
585baef
feat(v3): implement ProviderAdapter for Anthropic, OpenAI, DashScope,…
viettranx Apr 6, 2026
23b24c4
feat(v3): implement WorkspaceContext Resolver for 6 scenarios
viettranx Apr 6, 2026
8feeeaf
feat(v3): implement tiktoken TokenCounter with BPE encoding + cache
viettranx Apr 6, 2026
93c6d16
feat(v3): promote 12 other_config JSONB fields to dedicated agent col…
viettranx Apr 6, 2026
9351b01
feat(v3): implement Knowledge Vault with unified search, wikilinks, a…
viettranx Apr 6, 2026
f94ace9
feat(v3): wire vault into gateway startup + add unit tests
viettranx Apr 6, 2026
225d2b1
feat(v3): implement stage-based pipeline loop with 8 pluggable stages
viettranx Apr 6, 2026
ec1ad53
feat(v3): wire pipeline callbacks to Loop methods + add 71 unit tests
viettranx Apr 6, 2026
9891082
feat(v3): wire remaining 2 callbacks (ExecuteToolCall, CheckReadOnly)
viettranx Apr 6, 2026
7cd8c14
fix(v3): eliminate data race in tool execution + capture injected mes…
viettranx Apr 6, 2026
5d5a722
feat(v3): wire ResolveWorkspace, safe parallel tools, ContextStage tests
viettranx Apr 6, 2026
c880b92
feat(v3): add episodic memory store + temporal KG columns
viettranx Apr 6, 2026
b415cb9
fix(v3): review fixes for episodic store + temporal KG
viettranx Apr 6, 2026
10a436e
feat(v3): implement consolidation pipeline with 3 event-driven workers
viettranx Apr 6, 2026
f036bdb
feat(v3): implement progressive loading with L0 auto-inject + unified…
viettranx Apr 6, 2026
1a6559d
feat(v3): add memory_expand tool for L2 episodic retrieval
viettranx Apr 6, 2026
eb967d7
feat(v3): complete Phase 5 — tool extensions + gateway wiring
viettranx Apr 6, 2026
fb7cd7e
fix(v3): Phase 3 review fixes — tenant isolation + AutoInject args
viettranx Apr 6, 2026
0f4b0b5
feat(v3): wire per-agent v3 flags from DB into dual-mode gate
viettranx Apr 6, 2026
ff7d792
feat(v3): wire AutoInjector into pipeline for L0 memory auto-inject
viettranx Apr 6, 2026
cd0e90b
feat(v3): add tool metadata map + capability-based deny rules
viettranx Apr 6, 2026
8e91de4
fix(v3): add RWMutex to PolicyEngine capability deny fields
viettranx Apr 6, 2026
090ffd9
feat(v3): implement delegate tool for inter-agent task delegation
viettranx Apr 6, 2026
a5c5d66
feat(v3): complete 3 deferred implementations
viettranx Apr 6, 2026
0c4fbba
fix(v3): address code review findings on commits 5-6
viettranx Apr 6, 2026
b28205c
fix(teams): stop auto-creating agent_links for team members
viettranx Apr 6, 2026
9ed0e4d
fix(v3): tenant isolation for all agent_links queries + PromptBuilder…
viettranx Apr 6, 2026
57e9cf1
feat(v3): wire orchestration mode + evolution metrics into agent loop
viettranx Apr 6, 2026
e94ea1d
feat(v3): implement suggestion engine with pluggable analysis rules
viettranx Apr 6, 2026
41ddc90
feat(v3): implement auto-adapt guardrails with apply/rollback
viettranx Apr 6, 2026
64f5829
feat(v3): wire evolution stores + daily/weekly cron for suggestions
viettranx Apr 6, 2026
2632194
fix(v3): address code review findings on evolution engine
viettranx Apr 6, 2026
63f5d78
test(v3): add unit tests for orchestration, suggestions, guardrails, …
viettranx Apr 7, 2026
f218a2d
test(v3): add integration tests for evolution metrics + suggestions
viettranx Apr 7, 2026
a2d782d
feat(v3): add HTTP API handlers for evolution, vault, episodic, orche…
viettranx Apr 7, 2026
a027dd4
feat(v3): add web UI for evolution tab, v3 settings, vault page, epis…
viettranx Apr 7, 2026
6ab26aa
refactor(http): add bindJSON helper and migrate all decode call sites
viettranx Apr 7, 2026
68a1c06
refactor(store): adopt sqlx for PG scan operations (Phase 1+2)
viettranx Apr 7, 2026
f00c466
refactor(store): adopt sqlx for SQLite scan operations (Phase 3)
viettranx Apr 7, 2026
f3238b6
refactor(store): migrate PG bulk scan operations to sqlx (Phase 4)
viettranx Apr 7, 2026
93eaac7
refactor(store): extract shared CamelToSnake mapper, add UUIDArray us…
viettranx Apr 7, 2026
92a211f
refactor(cli): migrate commands from config.json to HTTP API, add pro…
viettranx Apr 7, 2026
d4f8213
refactor(store): add explicit db struct tags, fix sqlx mapper for hea…
viettranx Apr 7, 2026
6675ca1
test(store): add integration tests for 13 store interfaces (70 tests)
viettranx Apr 7, 2026
6637804
fix(store): resolve NULL scan bugs in MCP server and task metadata
viettranx Apr 7, 2026
56f3dee
feat(pipeline): fix v3 pipeline context injection, tracing, KG tempor…
viettranx Apr 7, 2026
f282df8
refactor(store): migrate KG store from raw sql.Rows to sqlx StructScan
viettranx Apr 7, 2026
573bea9
refactor(store): migrate memory, skills, agents, sessions, mcp, cron,…
viettranx Apr 7, 2026
d10dd22
fix(store): fix 3 sqlx scan struct db tag issues found by audit
viettranx Apr 7, 2026
bce92b9
feat(providers): implement Wave 2 provider resilience and intelligence
viettranx Apr 7, 2026
b02e1f5
feat(providers): wire model registry into gateway provider construction
viettranx Apr 7, 2026
a7ffadb
feat(consolidation): wire DomainEventBus and consolidation pipeline
viettranx Apr 7, 2026
2dac86e
fix(store): fix episodic key_topics pq.Array, ON CONFLICT, and migrat…
viettranx Apr 7, 2026
f96d5e7
test(store): add 17 integration tests for skills, cron, episodic, ten…
viettranx Apr 7, 2026
0e5da24
fix(permissions): use cron-specific permission check for cron tool (#…
nguyennguyenit Apr 7, 2026
9d154d8
fix(chat): load message history on first conversation click (#730)
kaitranntt Apr 7, 2026
ea8c518
feat(whatsapp): port native WhatsApp channel with whatsmeow from dev
viettranx Apr 7, 2026
b3215ac
feat(ui): v3 web UI enhancement — branded loading, rich markdown, vau…
viettranx Apr 7, 2026
919a870
fix(ui): address code review — mermaid XSS, Safari compat, cache key
viettranx Apr 7, 2026
6e3bf8f
docs: update CLAUDE.md with v3 architecture + complete changelog
viettranx Apr 7, 2026
8f17d30
fix(security): harden file path validation, tenant isolation, and too…
viettranx Apr 7, 2026
64a6a40
docs(v3): update 16 docs + add 2 new docs for v3 architecture
viettranx Apr 7, 2026
4a3290b
feat(v3): wire delegate tool, fix pipeline callbacks, clean dead code
viettranx Apr 7, 2026
7e8ab2c
feat(v3): finalize stage — emit session.completed, NO_REPLY, strip di…
viettranx Apr 7, 2026
de732b5
feat(vault): full CRUD — backend endpoints, UI dialogs, content preview
viettranx Apr 7, 2026
a48502d
fix(v3): critical pipeline parity fixes — ChatRequest, reasoning, pas…
viettranx Apr 7, 2026
e483cfa
fix(store): coerce NOT NULL JSONB columns to empty object on agent up…
viettranx Apr 7, 2026
91cdb18
feat(v3): v3 info modal redesign, agent links CRUD tab, sidebar rename
viettranx Apr 7, 2026
7d58276
fix(store): include personal chats in cron delivery targets
viettranx Apr 7, 2026
60414f4
fix(v3): duplicate messages, missing thinking, span numbering
viettranx Apr 7, 2026
ab8acb7
fix(v3): wire delegation targets into BuildSystemPrompt
viettranx Apr 7, 2026
7830aa6
fix(v3): sync mediaResults from bridgeRS to pipeline state
viettranx Apr 7, 2026
08f160e
fix(v3): populate SessionCompletedPayload in session.completed events
viettranx Apr 7, 2026
c0f642a
fix(v3): remaining pipeline parity gaps — skill postscript, team task…
viettranx Apr 7, 2026
21bc822
fix(evolution): add JSON struct tags to metric aggregates
viettranx Apr 8, 2026
50d3898
fix(v3): add debug logging to episodic worker for consolidation pipeline
viettranx Apr 8, 2026
1aaca76
chore: silence noisy tenant_cache debug logs
viettranx Apr 8, 2026
6586f3a
refactor(ui): replace v3 settings section with engine version picker …
viettranx Apr 8, 2026
92fe3ae
feat(v3): pass media files through delegate tool results
viettranx Apr 8, 2026
3d834aa
merge: bring main bug fixes into dev-v3
viettranx Apr 8, 2026
61e9984
feat(v3): add foundation packages for architecture refactor (Phase 1)
viettranx Apr 8, 2026
2842135
refactor(store): unify pg/ and sqlitestore/ helpers via base/ package…
viettranx Apr 8, 2026
c438012
refactor(orch): extract BatchQueue[T] generic for announce queues (Ph…
viettranx Apr 8, 2026
a6ac5a5
fix: remove defer accumulation in announce loop, clean comment tombstone
viettranx Apr 8, 2026
9cb0b99
fix: scope defer in announce loop via closure for panic safety
viettranx Apr 8, 2026
728cb15
refactor(providers): wire shared SSEScanner into 3 providers (Phase 4b)
viettranx Apr 8, 2026
4ea6d9f
refactor(agent): force v3 pipeline, remove v2 runLoop (Phase 4A)
viettranx Apr 8, 2026
54a5d5e
refactor(gateway): decompose gateway.go from 1295 to 476 LOC (Phase 4B)
viettranx Apr 8, 2026
b1abe07
test(agent): add v3 force migration guard tests
viettranx Apr 8, 2026
f7fd620
feat(delegate): wire ChildResult + fix media passthrough (Phase 3 gap)
viettranx Apr 8, 2026
5a72788
refactor(ui): remove v2/v3 pipeline toggle, always show V3 (Phase 4E)
viettranx Apr 8, 2026
1f0bfbc
test: add Phase 5 test infrastructure for v3 architecture refactor
viettranx Apr 8, 2026
cc1af0b
chore: remove stale runLoop references + apply go fix (Phase 6)
viettranx Apr 8, 2026
125a70b
docs: update architecture docs for v3 refactor completion (Phase 6)
viettranx Apr 8, 2026
ffcfa72
feat(evolution): skill draft auto-generation + go fix cleanup
viettranx Apr 8, 2026
96c468f
perf(prompt): deterministic tool order + Anthropic cache boundary split
viettranx Apr 8, 2026
eb6546f
perf(prompt): optimize cache boundary position + add Execution Bias
viettranx Apr 8, 2026
3d477e1
feat(prompt): add PromptMode task/none + 3-layer resolution
viettranx Apr 8, 2026
b69b937
feat(prompt): provider prompt contributions (stable/dynamic/overrides)
viettranx Apr 8, 2026
69e8053
feat(prompt): pinned skills with hybrid inline+search mode
viettranx Apr 8, 2026
ce08683
fix(prompt): validate prompt_mode from DB before cast
viettranx Apr 8, 2026
88402a4
fix(prompt): wire SectionIDToolCallStyle for provider override
viettranx Apr 8, 2026
6343b42
feat(store): implement 9 SQLite store backends for v3 parity
viettranx Apr 8, 2026
3eeefe7
docs(store): add SQLite parity section to store data model docs
viettranx Apr 8, 2026
ab1246a
fix(docker): skip web-builder stage when ENABLE_EMBEDUI=false
viettranx Apr 8, 2026
5de6c7a
feat(vault): embed metadata.summary for richer vector search
viettranx Apr 8, 2026
cec2b3d
fix(vault-ui): wider detail dialog, markdown rendering, create tooltip
viettranx Apr 8, 2026
dc9c5b0
feat(ui): prompt_mode dropdown + pinned_skills multi-select
viettranx Apr 8, 2026
4a5ee2c
fix(vault-ui): enlarge dialog to max-w-4xl, constrain markdown headin…
viettranx Apr 8, 2026
2aa03ba
refactor(ui): move pinned skills to dedicated section with skill select
viettranx Apr 8, 2026
59fc24d
fix(ui): add border wrap to capabilities section for visual consistency
viettranx Apr 9, 2026
9d8ddfd
feat(ui): redesign prompt mode as compact cards, replace v3 badge
viettranx Apr 9, 2026
9cd62c3
feat(ui): add section tags and token estimates to prompt mode cards
viettranx Apr 9, 2026
9495e9c
fix(ui): correct token estimates with actual tiktoken measurements
viettranx Apr 9, 2026
2f86139
fix(ui): use tiktoken-measured token ranges for prompt mode cards
viettranx Apr 9, 2026
186a8f4
fix(ui): use production-measured token counts for prompt mode cards
viettranx Apr 9, 2026
6d26154
refactor(ui): accurate section tags per prompt mode from systemprompt.go
viettranx Apr 9, 2026
4e3bc0e
feat(ui): replace engine version toggles with V3 capabilities modal
viettranx Apr 9, 2026
d9fc460
refactor(ui): move V3 badge to agent header, remove engine version se…
viettranx Apr 9, 2026
c78373f
feat: v3 prompt engine overhaul — 7-phase restructuring
viettranx Apr 9, 2026
5eb0f42
fix(vault-ui): redesign detail dialog and link dialog UX
viettranx Apr 9, 2026
3981e0f
fix(i18n): keep prompt section badges in English across all locales
viettranx Apr 9, 2026
39de0bb
feat(ui): system prompt preview in Files tab + README restructure
viettranx Apr 9, 2026
256ccdd
feat: replace architecture images with v3 sketchnotes
viettranx Apr 9, 2026
a37c8b5
feat(readme): add remaining 4 architecture sketchnotes with sections
viettranx Apr 9, 2026
0bc1095
feat: reorder README architecture images, evolution guardrails fix, m…
viettranx Apr 9, 2026
18783f0
feat(desktop): add 12 v3 feature sections to agent detail panel
viettranx Apr 9, 2026
2251180
fix(vault): team-scope security — prevent cross-team data corruption …
viettranx Apr 9, 2026
9842956
feat(evolution): allow CAPABILITIES.md self-evolution, backfill exist…
viettranx Apr 9, 2026
55a6025
feat(export): add v3 sections to agent import/export pipeline
viettranx Apr 9, 2026
c1133dd
feat(backup): system and tenant backup/restore with S3 support
viettranx Apr 9, 2026
37effa5
feat(backup): add table registry validation + gate tenant backup for …
viettranx Apr 9, 2026
68df808
fix(backup): address code review security + correctness findings
viettranx Apr 9, 2026
90dd489
feat(web): add backup & restore admin page with 4 tabs
viettranx Apr 9, 2026
969a88e
feat(web): system prompt preview modal + CAPABILITIES.md backfill + p…
viettranx Apr 9, 2026
8313474
feat(prompt): redesign 4 system prompt modes with tiered context files
viettranx Apr 9, 2026
e52b15f
refactor(web): extract PromptModeCards shared component
viettranx Apr 9, 2026
da1ab44
fix(backup): align preflight API contract + add package guidance UX
viettranx Apr 9, 2026
2f25b0a
feat(web): system prompt preview modal + CAPABILITIES.md backfill + p…
viettranx Apr 9, 2026
bb2c853
feat(vault): async enrich worker for auto summary + semantic linking
viettranx Apr 9, 2026
6b1112d
refactor(web): phase 1 quick wins — grid breakpoints, silent catches,…
viettranx Apr 9, 2026
de4498f
refactor(web): phase 2 split god components into sub-components
viettranx Apr 9, 2026
d62ecb5
refactor(web): phase 3 form standardization — RHF+Zod migration + fie…
viettranx Apr 9, 2026
e16d9e3
refactor(web): phase 4 lazy-load 20 dialog components + memory co-loc…
viettranx Apr 9, 2026
fd67235
refactor(web): phase 5 data fetching polish — staleTime tiers + optim…
viettranx Apr 9, 2026
d8df4d0
refactor(web): phase 6 styling standardization — CVA, design tokens, …
viettranx Apr 9, 2026
4e7d54d
feat(vault): pagination, team filter, graph upgrade, and link_type param
viettranx Apr 9, 2026
38c47c3
fix(vault): graph not rendering due to containerRef timing issue
viettranx Apr 9, 2026
12112ce
fix(vault): eliminate graph flicker on zoom by using ref instead of s…
viettranx Apr 9, 2026
46c3250
refactor(backend): comprehensive audit — safety, god files, interface…
viettranx Apr 9, 2026
b47ba47
fix(vault): fetch graph links per-agent so all-agents mode shows links
viettranx Apr 9, 2026
860214d
docs: add vault enhancement changelog entry
viettranx Apr 9, 2026
a6931c2
feat(agent): add displayName to Loop and SystemPrompt for runtime con…
viettranx Apr 9, 2026
70a101b
fix(vault): truncate path from head and hash from middle in detail di…
viettranx Apr 9, 2026
685d086
merge: resolve dev into dev-v3 — 15 conflict files
viettranx Apr 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ jobs:
go-version-file: go.mod
cache-dependency-path: go.sum
- run: go build ./...
- run: go test -race ./...
- run: go build -tags sqliteonly ./...
- run: go vet ./...
- run: go test -race -coverprofile=coverage.out ./...
- name: Coverage summary
run: go tool cover -func=coverage.out | tail -1

web:
runs-on: ubuntu-latest
Expand Down
44 changes: 34 additions & 10 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ internal/
├── bus/ Event bus system
├── cache/ Caching layer
├── channels/ Channel manager: Telegram, Feishu/Lark, Zalo, Discord, WhatsApp
│ └── whatsapp/ Native WhatsApp via whatsmeow (v3)
├── config/ Config loading (JSON5) + env var overlay
├── consolidation/ Memory consolidation workers (episodic, semantic, dreaming) (v3)
├── crypto/ AES-256-GCM encryption for API keys
├── cron/ Cron scheduling (at/every/cron expr)
├── edition/ Edition system (Lite, Standard) with feature gating
├── eventbus/ Domain event bus with worker pool, dedup, retry (v3)
├── gateway/ WS + HTTP server, client, method router
│ └── methods/ RPC handlers (chat, agents, sessions, config, skills, cron, pairing)
├── hooks/ Hook system for extensibility
Expand All @@ -37,33 +41,50 @@ internal/
├── media/ Media handling utilities
├── memory/ Memory system (pgvector)
├── oauth/ OAuth authentication
├── orchestration/ Orchestration primitives: BatchQueue[T] generic, ChildResult, media conversion (v3)
├── permissions/ RBAC (admin/operator/viewer)
├── pipeline/ 8-stage agent pipeline (context→history→prompt→think→act→observe→memory→summarize)
├── providers/ LLM providers: Anthropic (native HTTP+SSE), OpenAI-compat (HTTP+SSE), DashScope (Alibaba Qwen), Claude CLI (stdio+MCP bridge), ACP (Anthropic Console Proxy), Codex (OpenAI)
├── sandbox/ Docker-based code sandbox
├── providerresolve/ Provider adapter + model registry with forward-compat resolver
├── sandbox/ Docker-based code execution sandbox
├── scheduler/ Lane-based concurrency (main/subagent/cron)
├── sessions/ Session management
├── skills/ SKILL.md loader + BM25 search
├── store/ Store interfaces + pg/ (PostgreSQL) implementations
├── store/ Store interfaces + implementations (PostgreSQL, SQLite)
│ ├── base/ Shared store abstractions: Dialect interface, helpers (NilStr, BuildMapUpdate, BuildScopeClause)
│ ├── pg/ PostgreSQL implementations (database/sql + pgx/v5)
│ └── sqlitestore/ SQLite implementations (modernc.org/sqlite)
├── tasks/ Task management
├── tools/ Tool registry, filesystem, exec, web, memory, subagent, MCP bridge
├── tokencount/ tiktoken BPE token counting
├── tools/ Tool registry, filesystem, exec, web, memory, subagent, MCP bridge, delegate
├── tracing/ LLM call tracing + optional OTel export (build-tag gated)
├── tts/ Text-to-Speech (OpenAI, ElevenLabs, Edge, MiniMax)
├── updater/ Desktop auto-update checker (Lite edition)
├── upgrade/ Database schema version tracking
├── vault/ Knowledge Vault with wikilinks, hybrid search, FS sync
├── workspace/ WorkspaceContext resolver for 6 scenarios
pkg/protocol/ Wire types (frames, methods, errors, events)
pkg/browser/ Browser automation (Rod + CDP)
migrations/ PostgreSQL migration files
ui/web/ React SPA (pnpm, Vite, Tailwind, Radix UI)
ui/desktop/ Wails v2 desktop app (React frontend + embedded gateway)
```

## Key Patterns

- **Store layer:** Interface-based (`store.SessionStore`, `store.AgentStore`, etc.) with pg/ (PostgreSQL) implementations. Uses `database/sql` + `pgx/v5/stdlib`, raw SQL, `execMapUpdate()` helper in `pg/helpers.go`
- **Store layer:** Interface-based (`store.SessionStore`, `store.AgentStore`, etc.) with shared Dialect pattern in `store/base/`. PostgreSQL (`pg/`) and SQLite (`sqlitestore/`) implementations use `database/sql` + `pgx/v5/stdlib` + sqlx, raw SQL, `BuildMapUpdate()` and `BuildScopeClause()` helpers
- **Agent types:** `open` (per-user context, 7 files) vs `predefined` (shared context + USER.md per-user)
- **Context files:** `agent_context_files` (agent-level) + `user_context_files` (per-user), routed via `ContextFileInterceptor`
- **Providers:** Anthropic (native HTTP+SSE), OpenAI-compat (HTTP+SSE), DashScope (Alibaba Qwen), Claude CLI (stdio+MCP bridge), ACP (Anthropic Console Proxy), Codex (OpenAI). All use `RetryDo()` for retries. Loads from `llm_providers` table with encrypted API keys
- **Agent loop:** `RunRequest` → think→act→observe → `RunResult`. Events: `run.started`, `run.completed`, `chunk`, `tool.call`, `tool.result`. Auto-summarization at >85% context (token-based only)
- **Context propagation:** `store.WithAgentType(ctx)`, `store.WithUserID(ctx)`, `store.WithAgentID(ctx)`, `store.WithLocale(ctx)`
- **WebSocket protocol (v3):** Frame types `req`/`res`/`event`. First request must be `connect`
- **Providers:** Anthropic (native HTTP+SSE), OpenAI-compat (HTTP+SSE), DashScope (Alibaba Qwen), Claude CLI (stdio+MCP bridge), ACP (Anthropic Console Proxy), Codex (OpenAI). All use `RetryDo()` for retries. Loads from `llm_providers` table with encrypted API keys. ProviderAdapter enables pluggable implementations with ModelRegistry forward-compat resolver. Shared SSEScanner in `providers/sse_reader.go` for streaming providers
- **Pipeline:** 8-stage loop (context→history→prompt→think→act→observe→memory→summarize) with pluggable callbacks, always-on execution path
- **DomainEventBus:** Typed events with worker pool, dedup, retry. Used by consolidation pipeline and memory workers
- **3-tier memory:** Working (conversation) → Episodic (session summaries) → Semantic (KG). Progressive loading L0/L1/L2 with auto-inject for L0
- **Knowledge Vault:** Document registry + [[wikilinks]] + hybrid search, query layer above existing stores, FS sync, unified search
- **Context propagation:** `store.WithAgentType(ctx)`, `store.WithUserID(ctx)`, `store.WithAgentID(ctx)`, `store.WithLocale(ctx)`, `store.WithTenantID(ctx)`
- **Request middleware:** Composable chain (cache, service tier, request guards), zero-alloc fast path for hot operations
- **Self-evolution:** Metrics → suggestions → auto-adapt. 3 progressive stages: metrics collection, suggestion analysis, guardrail-protected apply/rollback
- **Orchestration:** Delegate tool for inter-agent task delegation with agent_links, 3 delegation modes (auto/explicit/manual), token-aware work distribution. BatchQueue[T] generic for result aggregation
- **WebSocket protocol:** Frame types `req`/`res`/`event`. First request must be `connect`
- **Config:** JSON5 at `GOCLAW_CONFIG` env. Secrets in `.env.local` or env vars, never in config.json
- **Security:** Rate limiting, input guard (detection-only), CORS, shell deny patterns, SSRF protection, path traversal prevention, AES-256-GCM encryption. All security logs: `slog.Warn("security.*")`
- **Telegram formatting:** LLM output → `SanitizeAssistantContent()` → `markdownToTelegramHTML()` → `chunkHTML()` → `sendHTML()`. Tables rendered as ASCII in `<pre>` tags
Expand All @@ -74,7 +95,10 @@ ui/web/ React SPA (pnpm, Vite, Tailwind, Radix UI)
```bash
go build -o goclaw . && ./goclaw onboard && source .env.local && ./goclaw
./goclaw migrate up # DB migrations
go test -v ./tests/integration/ # Integration tests
# Integration tests (requires pgvector pg18 on port 5433)
docker run -d --name pgtest -p 5433:5432 -e POSTGRES_PASSWORD=test -e POSTGRES_DB=goclaw_test pgvector/pgvector:pg18
TEST_DATABASE_URL="postgres://postgres:test@localhost:5433/goclaw_test?sslmode=disable" \
go test -v -tags integration ./tests/integration/

cd ui/web && pnpm install && pnpm dev # Web dashboard (dev)

Expand Down Expand Up @@ -167,7 +191,7 @@ Go conventions to follow:
- Use `switch/case` instead of `if/else if` chains on the same variable
- Use `append(dst, src...)` instead of loop-based append
- Always handle errors; don't ignore return values
- **Migrations:** When adding a new SQL migration file in `migrations/`, bump `RequiredSchemaVersion` in `internal/upgrade/version.go` to match the new migration number
- **Migrations (dual-DB):** PostgreSQL and SQLite have **separate migration systems**. When adding schema changes: (1) PG: add SQL in `migrations/` + bump `RequiredSchemaVersion` in `internal/upgrade/version.go`. (2) SQLite: update `internal/store/sqlitestore/schema.sql` (full schema for fresh DBs) + add incremental patch in `schema.go` `migrations` map + bump `SchemaVersion` constant. **Always update both** — missing SQLite migrations cause desktop edition to crash on startup
- **i18n strings:** When adding user-facing error messages, add key to `internal/i18n/keys.go` and translations to `catalog_en.go`, `catalog_vi.go`, `catalog_zh.go`. For UI strings, add to all locale JSON files in `ui/web/src/i18n/locales/{en,vi,zh}/`
- **SQL safety:** When implementing or modifying SQL store code (`store/pg/*.go`), always verify: (1) All user inputs use parameterized queries (`$1, $2, ...`), never string concatenation — prevents SQL injection. (2) Queries are optimized — no N+1 queries, no unnecessary full table scans. (3) WHERE clauses, JOINs, and ORDER BY columns use existing indices — check migration files for available indexes
- **DB query reuse:** Before adding a new DB query for key entities (teams, agents, sessions, users), check if the same data is already fetched earlier in the current flow/pipeline. Prefer passing resolved data through context, event payloads, or function params rather than re-querying. Duplicate queries waste DB resources and add latency
Expand Down
22 changes: 16 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# syntax=docker/dockerfile:1

# ── Stage 0: Build Web UI (conditional) ──
# ENABLE_EMBEDUI controls whether the web UI is built and embedded.
# Must be declared before first FROM to use in stage selector.
ARG ENABLE_EMBEDUI=false

# ── Stage 0: Build Web UI ──
# BuildKit skips this stage entirely when ENABLE_EMBEDUI=false
# because no downstream stage in the dependency graph references it.
FROM node:22-alpine AS web-builder
RUN corepack enable && corepack prepare pnpm@10.28.2 --activate
WORKDIR /app
Expand All @@ -11,6 +17,12 @@ RUN pnpm install --frozen-lockfile
COPY ui/web/ .
RUN pnpm build

# ── Stage selector: pick web-builder output or empty dir ──
FROM web-builder AS embedui-true
FROM busybox AS embedui-false
RUN mkdir -p /app/dist
FROM embedui-${ENABLE_EMBEDUI} AS web-dist

# ── Stage 1: Build Go ──
FROM golang:1.26-bookworm AS builder

Expand All @@ -23,18 +35,16 @@ RUN go mod download
# Copy source
COPY . .

# Build args
# Build args (re-declare after FROM; top-level ARG only visible in FROM lines)
ARG ENABLE_OTEL=false
ARG ENABLE_TSNET=false
ARG ENABLE_REDIS=false
ARG ENABLE_EMBEDUI=false
ARG VERSION=

# Copy web UI dist for embedding (only used when ENABLE_EMBEDUI=true)
COPY --from=web-builder /app/dist /src/internal/webui/dist
# Copy web UI dist — from web-builder when ENABLE_EMBEDUI=true, empty dir otherwise.
COPY --from=web-dist /app/dist /src/internal/webui/dist

# Build static binary (CGO disabled for scratch/alpine compatibility)
# Version: build arg > VERSION file (auto-generated by Makefile) > "dev"
RUN set -eux; \
if [ -z "$VERSION" ] && [ -f VERSION ]; then VERSION=$(cat VERSION); fi; \
if [ -z "$VERSION" ]; then VERSION="dev"; fi; \
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ VERSION ?= $(shell git describe --tags --abbrev=0 --match "v[0-9]*" 2>/dev/null
LDFLAGS = -s -w -X github.com/nextlevelbuilder/goclaw/cmd.Version=$(VERSION)
BINARY = goclaw

.PHONY: build build-full run clean version up down logs reset test vet check-web dev migrate setup ci desktop-dev desktop-build desktop-dmg
.PHONY: build build-full build-tui run clean version up down logs reset test vet check-web dev migrate setup ci desktop-dev desktop-build desktop-dmg

# Build backend only (API-only, no embedded web UI)
build:
Expand All @@ -14,6 +14,10 @@ build-full: check-web
cp -r ui/web/dist/* internal/webui/dist/
CGO_ENABLED=0 go build -tags embedui -ldflags="$(LDFLAGS)" -o $(BINARY) .

# Build with TUI (Bubble Tea enhanced CLI)
build-tui:
CGO_ENABLED=0 go build -tags tui -ldflags="$(LDFLAGS)" -o $(BINARY) .

run: build
./$(BINARY)

Expand Down
Loading
Loading