@zenithfoundry/slm-gate 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +669 -0
- package/LICENSE +21 -0
- package/README.md +317 -0
- package/configs/antigravity/.env.16gb.example +674 -0
- package/configs/antigravity/.env.24gb.example +674 -0
- package/configs/antigravity/.env.32gb.example +674 -0
- package/configs/antigravity/README.md +109 -0
- package/configs/claude-code/.env.16gb.example +674 -0
- package/configs/claude-code/.env.24gb.example +674 -0
- package/configs/claude-code/.env.32gb.example +674 -0
- package/configs/claude-code/README.md +52 -0
- package/configs/claude-desktop/.env.16gb.example +674 -0
- package/configs/claude-desktop/.env.24gb.example +674 -0
- package/configs/claude-desktop/.env.32gb.example +674 -0
- package/configs/claude-desktop/README.md +37 -0
- package/configs/cline-continue-opencode/.env.16gb.example +674 -0
- package/configs/cline-continue-opencode/.env.24gb.example +674 -0
- package/configs/cline-continue-opencode/.env.32gb.example +674 -0
- package/configs/cline-continue-opencode/README.md +34 -0
- package/configs/cursor/.env.16gb.example +674 -0
- package/configs/cursor/.env.24gb.example +674 -0
- package/configs/cursor/.env.32gb.example +674 -0
- package/configs/cursor/README.md +26 -0
- package/configs/generic-http/.env.16gb.example +674 -0
- package/configs/generic-http/.env.24gb.example +674 -0
- package/configs/generic-http/.env.32gb.example +674 -0
- package/configs/generic-http/README.md +20 -0
- package/configs/generic-stdio/.env.16gb.example +674 -0
- package/configs/generic-stdio/.env.24gb.example +674 -0
- package/configs/generic-stdio/.env.32gb.example +674 -0
- package/configs/generic-stdio/README.md +24 -0
- package/configs/preserve/README.md +26 -0
- package/configs/preserve/tls.json +61 -0
- package/dist/adapters/tech-lead-stack.js +38 -0
- package/dist/cache/index.js +173 -0
- package/dist/cli.js +256 -0
- package/dist/config.js +255 -0
- package/dist/dashboard/data.js +149 -0
- package/dist/dashboard/export.js +42 -0
- package/dist/dashboard/serve.js +63 -0
- package/dist/doctor.js +338 -0
- package/dist/hardware.js +126 -0
- package/dist/home-dir.js +39 -0
- package/dist/ledger/flush-lifecycle.js +50 -0
- package/dist/ledger/index.js +946 -0
- package/dist/ledger/report.js +69 -0
- package/dist/ledger/setup-dashboard.js +456 -0
- package/dist/ledger/smoke.js +37 -0
- package/dist/ledger/sync-config.js +177 -0
- package/dist/ledger/sync.js +307 -0
- package/dist/ledger/verify.js +185 -0
- package/dist/ledger/wipe-langfuse.js +130 -0
- package/dist/llm-gate/distill.js +239 -0
- package/dist/llm-gate/formats/anthropic.js +185 -0
- package/dist/llm-gate/formats/chat-completions.js +103 -0
- package/dist/llm-gate/formats/contract.js +29 -0
- package/dist/llm-gate/formats/gemini.js +84 -0
- package/dist/llm-gate/formats/internal.js +1 -0
- package/dist/llm-gate/formats/openai.js +77 -0
- package/dist/llm-gate/formats/responses.js +146 -0
- package/dist/llm-gate/forward.js +150 -0
- package/dist/llm-gate/index.js +40 -0
- package/dist/llm-gate/local-first.js +217 -0
- package/dist/llm-gate/pipeline.js +267 -0
- package/dist/llm-gate/server.js +289 -0
- package/dist/mcp-gate/ground.js +64 -0
- package/dist/mcp-gate/index.js +57 -0
- package/dist/mcp-gate/pipeline.js +252 -0
- package/dist/mcp-gate/server.js +302 -0
- package/dist/mcp-gate/tool-names.js +57 -0
- package/dist/models/check.js +26 -0
- package/dist/models/footprint.js +137 -0
- package/dist/models/helpers.js +91 -0
- package/dist/models/index.js +5 -0
- package/dist/models/reasoning.js +91 -0
- package/dist/models/roles.js +9 -0
- package/dist/models/slm.js +243 -0
- package/dist/models/types.js +1 -0
- package/dist/pricing/index.js +115 -0
- package/dist/pricing/plans.js +54 -0
- package/dist/pricing/providers.js +172 -0
- package/dist/resolver/index.js +277 -0
- package/dist/resolver/types.js +1 -0
- package/dist/setup/claim.js +41 -0
- package/dist/setup/gate-command.js +41 -0
- package/dist/setup/init.js +92 -0
- package/dist/setup/local-models.js +123 -0
- package/dist/setup/model-gate.js +220 -0
- package/dist/setup/notify.js +45 -0
- package/dist/setup/ollama-install.js +53 -0
- package/dist/setup/parent-watch.js +84 -0
- package/dist/setup/required-models.js +20 -0
- package/dist/setup/startup.js +132 -0
- package/dist/setup/tool-settings.js +101 -0
- package/dist/utils/backoff.js +47 -0
- package/dist/utils/compression.js +145 -0
- package/dist/utils/constants.js +22 -0
- package/dist/utils/duration.js +43 -0
- package/dist/utils/elision.js +556 -0
- package/dist/utils/embedding.js +32 -0
- package/dist/utils/entry-point.js +23 -0
- package/dist/utils/local-only.js +82 -0
- package/dist/utils/preserve-patterns.js +115 -0
- package/dist/utils/safety.js +30 -0
- package/dist/verifier/index.js +67 -0
- package/package.json +121 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Antigravity MCP Configuration
|
|
2
|
+
|
|
3
|
+
Antigravity requires you to configure MCP servers in its global configuration file. Note that a REMOTE server (like HTTP) uses `serverUrl`, not `url`. Below is the configuration for `slm-gate` using `stdio`.
|
|
4
|
+
|
|
5
|
+
**File Location:** `~/.gemini/config/mcp_config.json`
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"mcpServers": {
|
|
10
|
+
"slm-gate": {
|
|
11
|
+
"command": "node",
|
|
12
|
+
"args": [
|
|
13
|
+
"<ABS_PATH>/dist/mcp-gate/index.js"
|
|
14
|
+
],
|
|
15
|
+
"env": {
|
|
16
|
+
"TLS_ADAPTER": "on",
|
|
17
|
+
"DOWNSTREAM_MCP": "{\"command\":\"node\",\"args\":[\"<ABS_PATH_TO_TLS>/dist/mcp-server.mjs\"]}",
|
|
18
|
+
"SLM_BRAIN_MODEL": "qwen2.5:7b",
|
|
19
|
+
"SLM_GATE_MODEL": "qwen2.5-coder:3b",
|
|
20
|
+
"OLLAMA_MAX_LOADED_MODELS": "2",
|
|
21
|
+
"NUM_CTX": "4096"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
> **IMPORTANT:** Antigravity reads its configuration directly from the `"env"` JSON block in `mcp_config.json` shown above. The template files (`.env.16gb.example`, `.env.24gb.example`, `.env.32gb.example`) in this directory are reference templates. Setting variables in a template file does not affect Antigravity unless you add them to the `slm-gate` -> `env` block in `mcp_config.json`.
|
|
29
|
+
>
|
|
30
|
+
> The `env` block configures this MCP server only. The model gate (Layer 2), which this MCP server starts for your other coding tools, is shared by all of them and reads its settings only from `slm-gate`'s own `.env`. The MCP server checks that the models named in both places are downloaded.
|
|
31
|
+
|
|
32
|
+
## Model gate (Layer 2)
|
|
33
|
+
|
|
34
|
+
- **Antigravity IDE / Antigravity 2:** not possible. There is no setting for the model's address. Use the MCP server above (Layer 1).
|
|
35
|
+
- **Antigravity CLI (`agy`), with a Gemini API key only:** set `{ "modelProvider": "gemini" }` in `~/.gemini/antigravity-cli/settings.json`, then
|
|
36
|
+
```bash
|
|
37
|
+
export GOOGLE_GEMINI_BASE_URL=http://localhost:8787
|
|
38
|
+
export GEMINI_API_KEY=<your key>
|
|
39
|
+
```
|
|
40
|
+
A Google-account login ignores the address setting, and Google's terms say using that login through other tools may get the account suspended.
|
|
41
|
+
- Changed `LLM_GATE_PORT`? `slm-gate doctor` prints these lines with the new port.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### 🍏 Best Practices for macOS/Homebrew Users
|
|
46
|
+
|
|
47
|
+
When deploying Ollama on macOS via Homebrew (`brew install ollama`), developers face a severe configuration trap.
|
|
48
|
+
|
|
49
|
+
> [!WARNING]
|
|
50
|
+
> **The Configuration Trap:** Running `brew services restart ollama` aggressively overwrites the `~/Library/LaunchAgents/homebrew.mxcl.ollama.plist` file. This silently deletes any custom `EnvironmentVariables` you have manually added, resulting in aggressive model swapping and context truncation. Furthermore, Homebrew's native `.env` injection (via `~/.config/homebrew/services/`) is frequently ignored by the macOS LaunchDaemon for the Ollama formula.
|
|
51
|
+
|
|
52
|
+
**The Solution:**
|
|
53
|
+
To persistently apply critical environment variables for high-performance SLM routing without them being overwritten by Homebrew:
|
|
54
|
+
1. Stop the brew service: `brew services stop ollama`
|
|
55
|
+
2. Manually add your `EnvironmentVariables` dictionary to `~/Library/LaunchAgents/homebrew.mxcl.ollama.plist`.
|
|
56
|
+
3. Natively load the daemon: `launchctl load ~/Library/LaunchAgents/homebrew.mxcl.ollama.plist`
|
|
57
|
+
|
|
58
|
+
**Required Variables for this Repo:**
|
|
59
|
+
- `OLLAMA_CONTEXT_LENGTH="8192"` (Ensures Ollama's global context matches the app's `NUM_CTX`)
|
|
60
|
+
- `OLLAMA_KEEP_ALIVE="12h"` (Prevents unloaded models, ensuring warm latency)
|
|
61
|
+
- `OLLAMA_MAX_LOADED_MODELS="2"` (or `1`, depending on VRAM capacity to prevent model swapping)
|
|
62
|
+
|
|
63
|
+
*For further reading, refer to the [official Ollama FAQ on memory and concurrency](https://github.com/ollama/ollama/blob/main/docs/faq.md).*
|
|
64
|
+
|
|
65
|
+
### ⚠️ RAM Sizing & Troubleshooting Disclaimer: If Your RAM Config Is Not Working
|
|
66
|
+
|
|
67
|
+
If your models are getting evicted, Ollama is thrashing/swapping back and forth between disk and memory, or your Mac is experiencing high memory pressure, the following **MUST** be considered:
|
|
68
|
+
|
|
69
|
+
#### The Memory Formula
|
|
70
|
+
```text
|
|
71
|
+
Memory = Model Weights + (NUM_CTX × KV-Cache) × Models Loaded
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Dropping the brain model to a 7B is exactly the right lever, and yes it'll cut RAM. But don't just hand-edit `NUM_CTX` to a smaller number and call it done — memory is model weights + (`NUM_CTX` × KV-cache) × models loaded.**
|
|
75
|
+
|
|
76
|
+
While this example shows dropping from a 9B (or 14B) to a 7B model, this principle is a general rule that applies to all RAM capacities:
|
|
77
|
+
|
|
78
|
+
1. **Check your pulled tags:**
|
|
79
|
+
```bash
|
|
80
|
+
ollama list # see which qwen tags are pulled
|
|
81
|
+
```
|
|
82
|
+
2. **Pick a smaller brain:**
|
|
83
|
+
e.g. `qwen2.5:7b` (pull it if needed: `ollama pull qwen2.5:7b`).
|
|
84
|
+
Keep the small gate model (`qwen2.5-coder:3b`) as-is; it's already tiny (~2GB).
|
|
85
|
+
3. **Set it in your Antigravity `slm-gate` env (NOT a template file):**
|
|
86
|
+
Add these directly to `mcpServers.slm-gate.env` in `~/.gemini/config/mcp_config.json`:
|
|
87
|
+
```json
|
|
88
|
+
"SLM_BRAIN_MODEL": "qwen2.5:7b",
|
|
89
|
+
"SLM_GATE_MODEL": "qwen2.5-coder:3b",
|
|
90
|
+
"OLLAMA_MAX_LOADED_MODELS": "2",
|
|
91
|
+
"NUM_CTX": "4096"
|
|
92
|
+
```
|
|
93
|
+
4. **Shrink `NUM_CTX`:**
|
|
94
|
+
Lowering `NUM_CTX` from `8192` → `4096` is where a lot of the RAM savings actually comes from (the KV cache shrinks with it), and it's the single biggest knob after model size.
|
|
95
|
+
5. **Fallback to Single-Model Mode if still heavy:**
|
|
96
|
+
If memory is still heavy, set `"OLLAMA_MAX_LOADED_MODELS": "1"`. This forces one model in memory at a time (slower switching between gate and brain, but drastically reduces RAM usage).
|
|
97
|
+
6. **Confirm exact variable names:**
|
|
98
|
+
Verify against `.env.24gb.example` that the gate reads:
|
|
99
|
+
- `SLM_BRAIN_MODEL`
|
|
100
|
+
- `SLM_GATE_MODEL`
|
|
101
|
+
- `NUM_CTX`
|
|
102
|
+
- `OLLAMA_MAX_LOADED_MODELS`
|
|
103
|
+
7. **Use doctor to sanity-check:**
|
|
104
|
+
Run `slm-gate doctor` to sanity-check the fit for your RAM:
|
|
105
|
+
```bash
|
|
106
|
+
pnpm run dev doctor # or: node dist/cli.js doctor
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
After updating `mcp_config.json`, restart/refresh MCP servers in Antigravity and verify with `slm-gate doctor`.
|