-
Notifications
You must be signed in to change notification settings - Fork 26
ollama and memory search fixes #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8539cf3
Enable Ollama upstream in keyring-proxy
jgarzik 0a02a3a
fix: generate explicit memorySearch config in openclaw.json
jgarzik 031a801
add claude.md
jgarzik f40c9da
refactor: extract embedding model constants to reduce duplication
jgarzik 7329511
refactor: add MemorySearchConfig discriminated union return type
jgarzik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Philosophy | ||
|
|
||
| BotMaker packages OpenClaw into a turnkey bot platform. We are responsible | ||
| for producing **useful, usable, and working configurations** for all users. | ||
| "OpenClaw-side issue" is not an excuse — if the generated config is broken, | ||
| that's our bug. Every bot created through the wizard must work out of the box. | ||
|
|
||
| Users download this project from GitHub/GHCR. They may run: | ||
| - 100% cloud APIs (Anthropic, OpenAI, Google, etc.) with zero Ollama | ||
| - 100% local Ollama with zero cloud APIs | ||
| - A mix of both | ||
|
|
||
| The UI wizard, template generation, and proxy configuration must produce | ||
| valid, working configs for **every** combination. | ||
|
|
||
| ## Build & Dev Commands | ||
|
|
||
| ### Backend (root) | ||
| ```bash | ||
| npm run build # Compile TypeScript | ||
| npm run dev # Hot-reload dev server (tsx watch) | ||
| npm run start # Run compiled server | ||
| npm run test # Vitest unit tests | ||
| npm run lint # ESLint | ||
| npx vitest run src/bots/store.test.ts # Single test file | ||
| ``` | ||
|
|
||
| ### Dashboard (`dashboard/`) | ||
| ```bash | ||
| npm run dev # Vite dev server (localhost:5173) | ||
| npm run build # TypeScript check + Vite build | ||
| npm run test # Vitest + React Testing Library | ||
| ``` | ||
|
|
||
| ### Proxy (`proxy/`) | ||
| ```bash | ||
| npm run dev # Hot-reload (tsx watch) | ||
| npm run build # TypeScript compile | ||
| npm run test # Vitest | ||
| ``` | ||
|
|
||
| ### Full build | ||
| ```bash | ||
| npm run build:all # Backend + dashboard | ||
| ``` | ||
|
|
||
| ### Docker | ||
| ```bash | ||
| docker compose up -d # Start botmaker + keyring-proxy | ||
| docker compose --profile build build botenv # Build bot environment image | ||
| ``` | ||
|
|
||
| Test framework is **Vitest** (not Jest) across all three modules. Tests use `*.test.ts` pattern. | ||
|
|
||
| ## Architecture | ||
|
|
||
| Three independent TypeScript services sharing one repo: | ||
|
|
||
| ``` | ||
| src/ → Backend: Fastify API (port 7100), bot lifecycle, Docker orchestration | ||
| proxy/src/ → Keyring-proxy: credential vault (admin:9100, data:9101), request forwarding | ||
| dashboard/src/ → React + Vite frontend: wizard, dashboard, secrets management | ||
| ``` | ||
|
|
||
| All three have their own `package.json`, `tsconfig.json`, and `vitest.config.ts`. | ||
|
|
||
| ### Request Flow | ||
| ``` | ||
| User → Dashboard UI → Backend API (POST /api/bots) | ||
| ↓ | ||
| Creates: openclaw.json (templates.ts) | ||
| Creates: Docker container (DockerService.ts) | ||
| Registers: bot with keyring-proxy (proxy/client.ts) | ||
| ↓ | ||
| Bot container → keyring-proxy:9101/v1/{provider}/... → upstream API | ||
| (injects real API key at network edge) | ||
| ``` | ||
|
|
||
| ### Zero-Trust Credential Model | ||
| Bots never hold real API keys. They get a proxy token that keyring-proxy | ||
| validates, then the proxy injects the real API key when forwarding upstream. | ||
| Provider names get a `-proxy` suffix (e.g., `openai-proxy`) to avoid | ||
| collisions with OpenClaw's built-in provider defaults. | ||
|
|
||
| ### Key Files | ||
| - `src/server.ts` — All API routes (bot CRUD, auth, stats, admin) | ||
| - `src/bots/templates.ts` — Generates openclaw.json from wizard input | ||
| - `src/bots/store.ts` — Bot DB CRUD (better-sqlite3, no ORM) | ||
| - `src/services/DockerService.ts` — Container lifecycle | ||
| - `proxy/src/types.ts` — All 15+ LLM vendor configs + `initOllamaVendor()` | ||
| - `proxy/src/services/upstream.ts` — Transparent request forwarding (any path) | ||
| - `proxy/src/routes/proxy.ts` — Auth validation, key selection, forwarding | ||
| - `dashboard/src/wizard/` — Multi-step bot creation wizard | ||
| - `dashboard/src/config/providers/` — Provider definitions (22 providers) | ||
|
|
||
| ### Database | ||
| Direct SQL via better-sqlite3 (no ORM). Two separate SQLite databases: | ||
| - Backend: `${DATA_DIR}/botmaker.db` — `bots` table | ||
| - Proxy: `${DB_PATH}/proxy.db` — `provider_keys`, `bots`, `usage_logs` (AES-256 encrypted keys) | ||
|
|
||
| ### Provider API Type Mapping | ||
| `templates.ts:getApiTypeForProvider()` maps provider IDs to OpenClaw API types: | ||
| - `anthropic` → `anthropic-messages` | ||
| - `google` → `google-gemini` | ||
| - `openai` → `openai-responses` | ||
| - Everything else (ollama, groq, deepseek, mistral, etc.) → `openai-completions` | ||
|
|
||
| ### Ollama Integration | ||
| - Optional: enabled by `OLLAMA_UPSTREAM` env var on keyring-proxy | ||
| - Uses `noAuth: true` + `forceNonStreaming: true` (OpenClaw can't parse streaming tool-call deltas) | ||
| - Bots address it identically to cloud: `http://keyring-proxy:9101/v1/ollama` | ||
| - Context window set via `OLLAMA_CONTEXT_LENGTH` env var on Ollama container | ||
|
|
||
| ## Known Issue: memorySearch | ||
|
|
||
| OpenClaw's memorySearch auto-discovery looks for providers named exactly | ||
| `"openai"` or `"gemini"`. Our `-proxy` suffix means auto-discovery always | ||
| fails. The template generator must explicitly produce a `memorySearch` | ||
| section in openclaw.json pointing at the correct keyring-proxy embedding | ||
| endpoint, or explicitly disable it for providers without embedding support. | ||
|
|
||
| ~13/22 providers support OpenAI-compatible `/embeddings`; the rest | ||
| (anthropic, groq, cerebras, perplexity, moonshot) need `enabled: false`. | ||
|
|
||
| ## CI | ||
|
|
||
| GitHub Actions (`.github/workflows/ci.yml`): Node 20+22 matrix, lints and | ||
| tests all three modules, builds Docker image, pushes to GHCR on main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.