@octocodeai/freellama-mcp-server 0.9.0 → 0.12.0

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.
Files changed (54) hide show
  1. package/CONFIGURATION.md +82 -3
  2. package/DEVELOPING.md +40 -9
  3. package/README.md +317 -172
  4. package/dist/agent-cli.js +16963 -0
  5. package/dist/index.js +5424 -4320
  6. package/dist/research/bash-agent.js +308 -120
  7. package/dist/research/coder-agent.js +476 -139
  8. package/dist/research/github-agent.js +298 -107
  9. package/dist/research/octocode-agent.js +297 -106
  10. package/docs/AGENT_CLI.md +234 -0
  11. package/docs/API.md +160 -0
  12. package/docs/ARCHITECTURE.md +158 -50
  13. package/docs/ASSESSMENT.md +131 -0
  14. package/docs/BENCHMARK.md +381 -0
  15. package/docs/BUILD_AND_NOTES.md +12 -3
  16. package/docs/CLI.md +62 -17
  17. package/docs/CPU_GPU_ROUTING.md +22 -9
  18. package/docs/DEFERRED_JOBS.md +17 -4
  19. package/docs/FEATURES.md +97 -43
  20. package/docs/LLAMACPP.md +133 -0
  21. package/docs/LOCAL_MODELS.md +26 -20
  22. package/docs/MODEL_FORMS_AND_RESULTS.md +14 -6
  23. package/docs/MODEL_INTROSPECTION.md +9 -2
  24. package/docs/MODEL_SELECTION.md +39 -10
  25. package/docs/MONITORING.md +110 -12
  26. package/docs/OLLAMA_REVIEW.md +226 -0
  27. package/docs/PRODUCTION.md +68 -25
  28. package/docs/PROMPTS.md +119 -0
  29. package/docs/README.md +22 -6
  30. package/docs/RELIABILITY.md +207 -0
  31. package/docs/RUST_RESOURCE_AUDIT.md +65 -0
  32. package/docs/SCOPES_AND_WARMING.md +12 -5
  33. package/docs/TESTING.md +112 -6
  34. package/docs/TUNING.md +12 -8
  35. package/docs/assets/benchmark-results-2026-11-14.html +4 -0
  36. package/docs/assets/tool-calling-2026-11-14-bonsai-9b/TABLE.md +14 -0
  37. package/docs/assets/tool-calling-2026-11-14-lfm3-vl/TABLE.md +14 -0
  38. package/docs/assets/tool-calling-table.md +14 -0
  39. package/docs/cookbooks/README.md +9 -2
  40. package/docs/cookbooks/batch-text.md +4 -2
  41. package/docs/cookbooks/classify.md +19 -3
  42. package/docs/cookbooks/coding.md +13 -4
  43. package/docs/cookbooks/find-code.md +8 -3
  44. package/docs/cookbooks/jobs.md +8 -8
  45. package/docs/cookbooks/memory-and-caching.md +2 -2
  46. package/docs/cookbooks/ocr.md +3 -3
  47. package/docs/cookbooks/research-agent.md +32 -2
  48. package/docs/cookbooks/speech-to-text.md +1 -1
  49. package/docs/cookbooks/sweep.md +4 -1
  50. package/docs/octocode/GITHUB.md +4 -4
  51. package/docs/octocode/LOCAL.md +5 -4
  52. package/native/index.d.ts +1 -1
  53. package/package.json +6 -6
  54. package/docs/COMPARISON.md +0 -40
@@ -0,0 +1,234 @@
1
+ # Agent commands: `freellama run`, `chat`, `gateway`
2
+
3
+ `freellama run` works like `ollama run`, with FreeLlama on every request:
4
+ - a machine-calibrated Rust route when suitable evidence is available, otherwise a portable catalog pick
5
+ - the job's documented prompts and options
6
+ - the memory gate
7
+ - `check:` lines that say what to verify
8
+
9
+ `freellama gateway` serves the same workflows as models (`freellama/fix-bug`) to Ollama, OpenAI and
10
+ Anthropic clients. [Every API](API.md) shows every surface.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install -g @octocodeai/freellama # one command: freellama
16
+ ```
17
+
18
+ The npm launcher requires Node.js 22+ and installs a matching prebuilt platform package; no Rust
19
+ compiler is needed. Source builds use Yarn and the pinned Rust toolchain instead; see
20
+ [build from source](BUILD_AND_NOTES.md#build-from-source). Ollama and installed models are needed
21
+ for Ollama-backed inference.
22
+
23
+ | Command | Runs in | Needs |
24
+ |---|---|---|
25
+ | `freellama serve`, `doctor`, `init`, `catalog`, `task`, `jobs`, `bench-all`… | The prebuilt Rust binary | Node.js 22+ for the npm launcher; no Rust compiler |
26
+ | `freellama run`, `chat`, `gateway`, `workflows`, `job`, `tool`, `tools` | Node, from `@octocodeai/freellama-mcp-server` (installed as a dependency) | Node.js 22+ |
27
+ | `freellama status` | Human view on a terminal; JSON when piped or with `--json` | — |
28
+
29
+ The agent commands ship in npm 0.11.0 and later. From a checkout, run `yarn install && yarn build`,
30
+ then `node packages/cli/bin/freellama.js …`. A `cargo install freellama-cli` binary has the operator
31
+ commands only.
32
+
33
+ ## Which command
34
+
35
+ ```mermaid
36
+ flowchart TD
37
+ Q{"What do you want?"}
38
+ Q -->|"One answer, now"| R["freellama run"]
39
+ Q -->|"A conversation"| C["freellama chat NAME"]
40
+ Q -->|"An IDE, SDK or another agent<br/>to use the workflows"| G["freellama gateway"]
41
+ Q -->|"See the machine"| S["freellama status"]
42
+ Q -->|"A result from --defer"| J["freellama job ID --wait"]
43
+ Q -->|"Any MCP tool from a shell"| T["freellama tool NAME JSON"]
44
+ R --> W{"Know the model?"}
45
+ W -->|"no: name the work"| W1["-w WORKFLOW or -j JOB<br/>picks the model that fits"]
46
+ W -->|"yes"| W2["freellama run TAG"]
47
+ ```
48
+
49
+ ## First five minutes
50
+
51
+ | Step | Command | You get |
52
+ |---|---|---|
53
+ | 1 | `freellama catalog` | Tested picks per job: installed, fits now |
54
+ | 2 | `freellama workflows` | Each workflow and what it expects |
55
+ | 3 | `git diff \| freellama run -w summarize-diff` | The summary on stdout |
56
+ | 4 | Read stderr | `check:` lines: what to verify before you rely on the answer |
57
+ | 5 | `freellama gateway`, then `OLLAMA_HOST=127.0.0.1:11437 ollama run freellama/explain-code` | The same workflow in the `ollama` chat |
58
+
59
+ ## `freellama run`
60
+
61
+ ```bash
62
+ git diff | freellama run -w summarize-diff
63
+ freellama run -w fix-bug -f path/to/parser.ts "The parser drops the last token"
64
+ freellama run -j find-code -f 'path/to/src/**/*.ts' --top 3 "where are CLI flags parsed"
65
+ freellama run --ask "Is a refund requested?" < ticket.txt
66
+ freellama run --ask "Which team?" --choice billing="Payments" --choice technical="Software" < ticket.txt
67
+ freellama run "Why is the sky blue?" # the chat pick that fits now
68
+ freellama run bonsai-2:9b "Why?" --think=false # a tag you choose
69
+ echo "Invoice 2291, Acme, 1,240.50 EUR" | freellama run -w extract-json --schema "invoice_id, vendor, total float, currency"
70
+ freellama run -w review-code --each -f 'src/*.ts' # one answer per file
71
+ ```
72
+
73
+ ### How a run resolves
74
+
75
+ ```mermaid
76
+ flowchart TD
77
+ A["freellama run …"] --> B{"-w, -j, -t or -m given?"}
78
+ B -->|"-w / -j"| P["Calibrated route or portable catalog pick<br/>+ workflow prompts and options"]
79
+ B -->|"-m TAG"| T["That tag"]
80
+ B -->|"no"| F{"First word an installed tag?"}
81
+ F -->|"yes"| T
82
+ F -->|"no, and nothing after it"| BP["It is the prompt"]
83
+ F -->|"no, and a prompt follows"| E(["Usage error, exit 2:<br/>did you mean …? (never pulls)"])
84
+ BP --> CP["Chat pick that fits now"]
85
+ T --> K{"Embedding model?"}
86
+ K -->|"yes"| V(["Prints the vector"])
87
+ K -->|"no"| X
88
+ P --> X{"Output goes to"}
89
+ CP --> X
90
+ X -->|"a terminal (or --stream)"| S["Tokens stream as Ollama generates them<br/>loaded window kept, cold load admitted"]
91
+ X -->|"a pipe (or --no-stream)"| M["One managed answer with its receipt"]
92
+ S --> O["stdout: the answer<br/>stderr: check: lines, stats with --verbose"]
93
+ M --> O
94
+ ```
95
+
96
+ | Rule | Behavior |
97
+ |---|---|
98
+ | stdin | Piped or redirected input is read: the `state` of a decision, one item per line for an embedding job, else after the prompt. An agent harness's open socket never hangs the call; a socket is read only if data arrives within 250 ms |
99
+ | Image path in the prompt | Attached as an image, as in `ollama run` |
100
+ | `--ask` with no model | Runs on the `classify` job's tested pick; answers are named after the question (`refund-requested: true (p 0.89)`) |
101
+ | Always managed | Decisions, embeddings, tools, batches (`--each`), `--defer`, `--preview`, `--save-as`, and explicit routing, placement or scheduling controls (`--objective`, `--prefer`, `--min-confidence`, `--priority`, `--timeout`, `--max-wait`, `--session`) |
102
+ | serve | Started once in the background if nothing answers (log `~/.octocode/freellama/serve.log`, PID on stderr); `FREELLAMA_MCP_AUTOSTART_SERVE=0` turns it off |
103
+
104
+ Job selection first asks the Rust router for a model with matching machine-local throughput
105
+ evidence. Capable workflows also require task-quality evidence; OCR requires it too, and image
106
+ search requires vision support. If calibration is missing, insufficient, refused or unavailable,
107
+ selection uses the installed portable catalog picks and their live capability/memory preflight.
108
+ The job's note identifies the choice. A throughput screen does not establish the job's accuracy:
109
+ read `check:` lines and verify the answer. Generate calibration explicitly with
110
+ `freellama bench-all` as described in [machine calibration](MODEL_SELECTION.md#turn-measurements-into-routing-evidence).
111
+ Catalog ordering remains a starting point for unmeasured machines, rather than a machine-specific
112
+ performance ranking.
113
+
114
+ ### Flags
115
+
116
+ | Group | Flags |
117
+ |---|---|
118
+ | Same as `ollama run` | `--format json\|SCHEMA`, `--think[=true\|false\|LEVEL]`, `--hidethinking`, `--keepalive`, `--verbose`, `--ask` / `--choice` / `--level`, `--dimensions N`, `--nowordwrap`, `--insecure` |
119
+ | Choose the work | `-w/--workflow`, `-j/--job`, `-m/--model`, `--fallback TAG` (repeatable: tried in order only after a refusal before running), `-t/--task`, `--objective`, `--prefer cpu\|gpu`, `--min-confidence` |
120
+ | Inputs | `-f/--file PATH\|GLOB` (repeatable), `--image`, `-s/--system TEXT\|@FILE` (also preserved with `--suffix`), `--tools JSON\|@FILE`, `--suffix TEXT\|@FILE` (fill in the middle) |
121
+ | Model controls | `-o/--option k=v`, `--ctx N`, `--top N` (embedding matches) |
122
+ | Output | `--schema 'name, age int, tags list'\|JSON\|@FILE`, `-x/--extract` (first code block), `--json` (full receipt), `-q/--quiet`, `--stream` / `--no-stream` |
123
+ | Scheduling | `--each`, `--defer`, `--idempotency-key KEY` (with `--defer`, on a serve with durable jobs), `--preview`, `--save-as NAME`, `--session`, `--priority`, `--timeout`, `--max-wait`, `--endpoint URL` |
124
+
125
+ `freellama run --help` lists every flag. `--think=LEVEL` must be a level the model lists
126
+ (`ollama show MODEL`). `--suffix` needs a model with Ollama's `insert` capability. `-x` extracts
127
+ text; it is not a patch.
128
+
129
+ Explicit managed controls remain effective with `--stream`; these requests return one managed
130
+ answer. Fill-in-the-middle `--suffix` uses streamed completion instead and rejects managed-only
131
+ controls, deferred/batch modes, `--json`, `--extract` and `--no-stream`; a preview still discards
132
+ payload fields and executes nothing. A stream that ends without `done:true` exits 1 even if partial
133
+ text has already reached stdout. Treat that partial text as incomplete.
134
+ Buffered terminal and rewritten gateway responses share `FREELLAMA_MAX_REQUEST_BYTES` (64 MiB
135
+ by default). It counts received bytes before decoding, including incomplete NDJSON/SSE records and
136
+ error bodies. Overflow cancels the upstream read and fails without replay; a gateway stream that
137
+ already started closes with an error. This per-response bound also covers buffered JSON replies;
138
+ raw real-tag passthrough stays a pull-driven byte stream.
139
+
140
+ ### Exit codes
141
+
142
+ | Code | Meaning | What to do |
143
+ |---|---|---|
144
+ | 0 | Answered | Read the `check:` lines |
145
+ | 75 | Busy, short of memory or Ollama down | Retry; stderr gives `retry after Ns` when known |
146
+ | 1 | Refused, failed, or an empty answer | Read stderr; an empty thinking answer says to use `--think=false` |
147
+ | 2 | Usage error | Fix the command |
148
+ | 130 | Interrupted (Ctrl-C cancels the running job) | — |
149
+
150
+ ### Embeddings and code search
151
+
152
+ | Feature | How |
153
+ |---|---|
154
+ | Rank files by a question | `freellama run -j find-code -f GLOB --top N "question"` |
155
+ | Persistent index | Each chunk's vector is kept in `$FREELLAMA_HOME/embedding-index/`, so a repeated search embeds only new or changed chunks (89 chunks: 7.3 s first, 0.28 s next). `FREELLAMA_EMBED_INDEX=0` turns it off |
156
+ | Shorter vectors | `--dimensions N` on models trained for it (nomic v1.5, embeddinggemma) |
157
+
158
+ ## `freellama chat`, `status`, `job`, `tool`
159
+
160
+ | Command | What it does |
161
+ |---|---|
162
+ | `freellama chat NAME` | The real `ollama` chat on a workflow (`review-code`), `freellama/auto` or a tag, through a gateway that lives as long as the chat; each answer ends with its `check:` lines |
163
+ | `freellama status [--endpoint URL]` | On a terminal: memory, queues, usage, each loaded model (size, GPU or CPU, window, time until it unloads) and active jobs |
164
+ | `freellama job ID [--wait\|--cancel] [--endpoint URL]` | A deferred task: `--wait` blocks until it ends and prints only the answer |
165
+ | `freellama tool NAME [JSON\|@FILE\|-]` | Any FreeLlama MCP tool, with its own schema; `freellama tools` lists them, `freellama tool NAME --help` shows one. `tool sweep` with `start` or `resume` stays until the sweep ends |
166
+
167
+ Approvals still apply: `freellama tool ollama_pull` needs the exact tag and its approved size, and
168
+ `ollama_delete` the exact installed tag ([agent invariants](../AGENTS.md#agent-facing-invariants)).
169
+ `freellama tool delegate_research` reads only workspaces under `FREELLAMA_MCP_ALLOWED_ROOTS`.
170
+
171
+ ## The gateway: workflows as models
172
+
173
+ ```bash
174
+ freellama gateway # 127.0.0.1:11437
175
+ OLLAMA_HOST=127.0.0.1:11437 ollama run freellama/explain-code
176
+ curl http://127.0.0.1:11437/v1/chat/completions -d '{"model":"freellama/review-code",
177
+ "messages":[{"role":"user","content":"def avg(xs): return sum(xs)/len(xs)"}]}'
178
+ curl http://127.0.0.1:11437/v1/messages -H 'anthropic-version: 2023-06-01' -d '{"model":"freellama/explain-code",
179
+ "max_tokens":400,"thinking":{"type":"disabled"},"messages":[{"role":"user","content":"What does git rebase --onto do?"}]}'
180
+ ```
181
+
182
+ | Model name | Runs |
183
+ |---|---|
184
+ | `freellama/<workflow>` | That workflow: `fix-bug`, `review-code`, `explain-code`, `summarize-log`, `extract-json`, `describe-screen`, … |
185
+ | `freellama/<job>` | A chat-shaped job: `coding`, `summarize`, `ocr`, `image-recognition` (`summarize` uses the coding picks: `freellama catalog --job coding`) |
186
+ | `freellama/auto` | The chat pick that fits now |
187
+ | Any other tag | Passed through to Ollama via `serve`, with admission and telemetry |
188
+
189
+ ### How a request is handled
190
+
191
+ ```mermaid
192
+ flowchart TD
193
+ R["Request to :11437"] --> O{"Origin and Host loopback?"}
194
+ O -->|"no"| X(["403"])
195
+ O -->|"yes"| V{"model is freellama/…?"}
196
+ V -->|"no"| PT["Passed through to serve, then Ollama"]
197
+ V -->|"yes"| K{"Streamed, or Anthropic / Responses?"}
198
+ K -->|"yes"| RW["Resolve: pick that fits, workflow prompt,<br/>options, think, loaded window, shift setting"]
199
+ RW --> AD{"Runner loaded with that profile?"}
200
+ AD -->|"yes"| FW["Forward to Ollama's own endpoint<br/>tokens and tool calls stream natively"]
201
+ AD -->|"no"| WM["Load through managed admission<br/>or memory assessment"]
202
+ WM -->|"no room"| N(["503 with the reason"])
203
+ WM -->|"admitted"| FW
204
+ K -->|"no: non-streamed Ollama or OpenAI chat"| MT["Managed run_task<br/>full receipt and checks, one chunk"]
205
+ ```
206
+
207
+ | Endpoint | Clients | Virtual model |
208
+ |---|---|---|
209
+ | `POST /api/chat`, `/api/generate` | `ollama` CLI, Continue, Roo, Aider, Goose, Zed, Open WebUI, LangChain `ChatOllama` | Streamed by Ollama; `stream:false` is managed |
210
+ | `POST /v1/chat/completions` | opencode, Cline, LangChain `ChatOpenAI`, Open WebUI, OpenAI SDKs | `stream:true` streamed by Ollama; otherwise managed |
211
+ | `POST /v1/responses` | Codex (`wire_api = "responses"`), opencode | Streamed or not, by Ollama |
212
+ | `POST /v1/messages` | Claude Code (`ANTHROPIC_BASE_URL`), Goose, Zed | Streamed or not, by Ollama |
213
+ | `GET /api/tags`, `/v1/models`, `POST /api/show` | Model lists | Virtual models first, then installed tags |
214
+
215
+ | Rule | Behavior |
216
+ |---|---|
217
+ | What the caller sends wins | A system message, think or reasoning setting, sampling and format stay; job mode fills only what is missing |
218
+ | Thinking off | `reasoning_effort: "none"` (OpenAI), `thinking: {type: "disabled"}` (Anthropic), `think: false` (Ollama, Responses) |
219
+ | Small `max_tokens` | A thinking model may spend it all: `finish_reason: "length"`, empty content |
220
+ | Model name | Every response for a virtual model, streamed or not, names the requested virtual model (`freellama/review-code`) in the protocol's `model` field; the real tag is `freellama.model`. Real tags pass through unchanged |
221
+ | Receipts | A `freellama` object (`model`, `checks`, `job`) that standard clients ignore. Ollama streams: on the `done` line, plus `num_ctx` and `context_source`; with `checks` in the content too for a person in a chat. OpenAI Chat streams: a top-level field on the last chunk before `data: [DONE]`. Responses streams: on the `response.completed` (or `response.incomplete`) event, beside `response`. Anthropic streams: on the `message_stop` event. Non-streamed responses: a top-level field (managed Ollama and OpenAI chats carry `job_profile` and `cached_prompt_tokens` instead of `job`). Checks cover the whole answer and its tool calls; on the OpenAI and Anthropic layers they never enter the content |
222
+ | Security | Loopback only; non-loopback Origin or Host refused; no files read and no URLs fetched over HTTP (images must be base64) |
223
+ | Errors | 503 when waiting can fix it (capacity, memory, Ollama, no pick that fits), else 500 |
224
+
225
+ Set `FREELLAMA_AUTH_TOKEN_FILE` for a token-protected `serve`. Terminal streams, gateway discovery,
226
+ residency/config reads and forwarded generation use this same credential as managed calls. A
227
+ configured serve credential takes precedence over an incoming SDK placeholder bearer; without it,
228
+ gateway forwarding retains the caller's headers. Forwarding stays on the configured serve origin,
229
+ and authenticated fetches refuse redirects. Forwarded native requests refresh the server's
230
+ context-shift policy within five seconds, including `ollama_default` after a runtime reload.
231
+
232
+ The shipped workflows target bounded local-model tasks; their dated evaluation results do not
233
+ qualify arbitrary models, hardware or long agent loops. Verify each answer using its checks.
234
+ See [reliability evidence](RELIABILITY.md) for the measured workloads and limits.
package/docs/API.md ADDED
@@ -0,0 +1,160 @@
1
+ # Every FreeLlama API
2
+
3
+ FreeLlama exposes one Rust management core through several interfaces. Ollama has the complete
4
+ managed API; an explicit local llama.cpp adapter supports bounded text tasks. Other configured
5
+ OpenAI-compatible engines use passthrough. Pick the interface for your client, then check the
6
+ [engine support limits](LLAMACPP.md#supported-contract-and-limits). This inventory was reviewed
7
+ against the checkout on 2026-11-14.
8
+
9
+ ## Which one to use
10
+
11
+ | You are | Use | Start with |
12
+ |---|---|---|
13
+ | An agent with MCP (Claude Code, Codex, Cursor…) | [MCP tools](#mcp-tools) | `models {view:"catalog", job}`, then `run_task {workflow}` |
14
+ | An agent or script with only a shell | [Agent commands](#agent-commands) | `git diff \| freellama run -w summarize-diff` |
15
+ | An Ollama, OpenAI or Anthropic client (Continue, opencode, Open WebUI, LangChain, an SDK) | [Gateway](#gateway-endpoints) | base URL `http://127.0.0.1:11437`, model `freellama/review-code` |
16
+ | An operator | [`freellama` CLI](#freellama-commands) | `freellama init`, `freellama serve`, `freellama status` |
17
+ | A program that wants receipts and routing | [Control API](#control-api) | `POST /_freellama/v1/tasks` |
18
+ | An existing Ollama client that only needs admission and telemetry | [Passthrough](#ollama-compatible-passthrough) | `OLLAMA_HOST=127.0.0.1:11435` |
19
+
20
+ ```mermaid
21
+ flowchart LR
22
+ MCP["MCP client"] --> H["MCP tool handlers<br/>(job mode, prompts, files, checks)"]
23
+ SH["freellama run / tool"] --> H
24
+ GW["freellama gateway :11437"] -->|"non-streaming chat"| H
25
+ GW -->|"streamed or Anthropic / Responses:<br/>rewritten with the pick and prompts"| PX
26
+ H --> API["serve control API<br/>/_freellama/v1/*"]
27
+ CLI["freellama CLI"] --> API
28
+ API --> O["Ollama :11434"]
29
+ API -->|"explicit bounded text task"| LC["Local llama.cpp"]
30
+ RAW["Ollama-compatible client"] --> PX["serve passthrough<br/>/api/*, /v1/*"]
31
+ PX --> O
32
+ PX -->|"configured /v1 model"| EXT["OpenAI-compatible upstream"]
33
+ ```
34
+
35
+ Ports: Ollama `11434`, `freellama serve` `11435`, the CPU backend that `serve --spawn-cpu-backend`
36
+ starts `11436`, and `freellama gateway` `11437`.
37
+
38
+ ## Agent commands
39
+
40
+ `freellama run`, `chat`, `gateway`, `workflows`, `job`, `tool` and `tools` (and `status` on a terminal) are part of `@octocodeai/freellama`: its launcher runs them in Node from `@octocodeai/freellama-mcp-server`, a dependency ([install](AGENT_CLI.md#install)). See the [reference](AGENT_CLI.md) for flags and output rules.
41
+
42
+ | Command | Does |
43
+ |---|---|
44
+ | `freellama run [MODEL] [PROMPT…]` | One task, streamed on a terminal. Takes `ollama run` flags plus `-w/--workflow`, `-j/--job`, `-f/--file`, `--each`, `--schema`, `-x`, `--json` and more |
45
+ | `freellama chat [NAME]` | The real `ollama` REPL on a virtual model or a tag |
46
+ | `freellama gateway [--port] [--endpoint]` | Serves the [gateway endpoints](#gateway-endpoints) |
47
+ | `freellama workflows` | Workflows and jobs, with what each expects |
48
+ | `freellama status` | On a terminal: memory, queues, loaded models, active jobs (piped or `--json`: the JSON receipt) |
49
+ | `freellama job [ID] [--wait\|--cancel] [--endpoint URL]` | Lists deferred tasks, or gets, waits for or cancels one |
50
+ | `freellama tool NAME [JSON\|@FILE\|-]` | Calls any [MCP tool](#mcp-tools) with its own schema. `freellama tools` lists them; `--help` shows a schema |
51
+
52
+ ## Gateway endpoints
53
+
54
+ The gateway serves these virtual models:
55
+
56
+ - `freellama/<workflow>`: fix-bug, review-code, explain-code, summarize-log, extract-json,
57
+ describe-screen and the rest.
58
+ - `freellama/<job>`: coding, summarize, ocr, image-recognition.
59
+ - `freellama/auto`: routing picks the model.
60
+
61
+ Any other model name passes through to `serve`. The [reference](AGENT_CLI.md#the-gateway-workflows-as-models)
62
+ explains the mapping.
63
+
64
+ | Endpoint | Protocol | A virtual model… |
65
+ |---|---|---|
66
+ | `GET /api/tags`, `GET /v1/models` | Ollama, OpenAI | is listed first, before the installed tags |
67
+ | `POST /api/show` | Ollama | is described, with capabilities |
68
+ | `POST /api/chat`, `/api/generate` | Ollama | is streamed by Ollama (the default); with `stream:false` it runs as a managed task |
69
+ | `POST /v1/chat/completions` | OpenAI Chat | with `stream:true` is streamed by Ollama; otherwise it runs as a managed task |
70
+ | `POST /v1/responses` | OpenAI Responses (Codex) | is streamed or answered by Ollama |
71
+ | `POST /v1/messages` | Anthropic Messages (Claude Code) | is streamed or answered by Ollama |
72
+ | `GET`/`HEAD /` | Ollama heartbeat | |
73
+ | anything else | | is proxied to `serve` |
74
+
75
+ ## MCP tools
76
+
77
+ There are 13 tools, registered from [`tools/registrations.ts`](https://github.com/bgauryy/FreeLlama/blob/main/packages/mcp/src/tools/registrations.ts).
78
+ `freellama tool NAME` reaches every one of them.
79
+
80
+ | Tool | Use it to |
81
+ |---|---|
82
+ | `doctor` | Check Ollama and FreeLlama health, live queues and limits (`view:"status"`), and token usage |
83
+ | `session` | Keep related `run_task` calls on one model: create, kill, delete |
84
+ | `models` | See catalog picks per job, installed and loaded models, one model's details, or search ollama.com and Hugging Face (`view:"library"`) |
85
+ | `scope` | Keep chat history on the server, with revisions: create, get, fork, delete |
86
+ | `run_task` | Run bounded work on a local model: `job` or `workflow` (built-in or [your own](PROMPTS.md#your-own-workflows)), `files`, decisions, embeddings with `nearest` (indexed, and `dimensions`), vision, tools, up to 64 batch items, `defer` (with `idempotencyKey` on a durable serve), `fallbackModels`, `preview`. Answers with text: the answer, `check:` lines and `response_file:` ([receipts](../packages/mcp/CONFIGURATION.md#where-an-answer-goes)) |
87
+ | `task_jobs` | List, get, cancel or remove deferred work (text answers, like `run_task`) |
88
+ | `ollama_pull` | Download one exact tag the user approved, at its reported size (`approvedSizeBytes`) |
89
+ | `ollama_manage` | Load or free a model |
90
+ | `ollama_delete` | Delete one exact tag the user names; it cannot be undone |
91
+ | `delegate_research` | Answer a read-only question about a workspace or GitHub with a local agent (bash, octocode or github adapters; `coder` is opt-in) |
92
+ | `audio` | Transcribe or translate a WAV, or speak text |
93
+ | `sweep` | Judge a code tree, logs or a docs site chunk by chunk in the background, reporting only flagged or changed chunks |
94
+ | `read_response` | Read a section or page of a saved `response_file` |
95
+
96
+ The server also has 22 **prompts**: the 15 workflows (read-text, read-table, read-fields,
97
+ answer-image, describe-screen, change-code, fix-bug, implement, write-tests, review-code,
98
+ explain-code, summarize-log, summarize-text, summarize-diff, extract-json), plus classify,
99
+ find-code, duplicates, research, github-research, sweep and `freellama`. **Resources** are
100
+ `freellama://docs/<path>` for every bundled doc, with the index at `freellama://docs/index`.
101
+
102
+ ## `freellama` commands
103
+
104
+ These are the operator commands of the Rust binary. The [CLI reference](CLI.md) covers flags and
105
+ behavior.
106
+
107
+ | Group | Commands |
108
+ |---|---|
109
+ | First run and health | `init`, `doctor`, `ready`, `machine`, `status`, `usage`, `config [--reload]` |
110
+ | Run the service | `serve`, `proxy`, `auth-token` |
111
+ | Models | `models`, `catalog`, `warm`, `unload` |
112
+ | Work | `route`, `task`, `jobs`, `session`, `scope create\|get\|fork\|delete` |
113
+ | Measure and tune | `bench-all`, `policy from-eval` |
114
+
115
+ `init`, `doctor`, `catalog`, `auth-token`, `proxy`, `bench-all` and `policy` work without `serve`;
116
+ the rest are clients of it.
117
+
118
+ ## Control API
119
+
120
+ The control API lives at `/_freellama/v1/*` on `serve`
121
+ ([router](https://github.com/bgauryy/FreeLlama/blob/main/packages/rust-core/src/platform/mod.rs)).
122
+ Every route needs the bearer token when one is configured, except `GET /_freellama/ui`.
123
+
124
+ | Area | Routes |
125
+ |---|---|
126
+ | State | `GET health`, `GET ready`, `GET machine`, `GET models` |
127
+ | Decide and run | `POST routes` (no inference), `POST tasks`, `POST task-batches` |
128
+ | Affinity and history | `POST sessions`, `DELETE sessions/{id}`, `POST sessions/{id}/kill`; `POST scopes`, `GET scopes/{id}`, `DELETE scopes/{id}`, `POST scopes/{id}/fork` |
129
+ | Residency | `POST warm`, `POST unload` |
130
+ | Deferred jobs | `GET jobs`, `GET jobs/{id}` (`?wait_ms=N` long-polls up to 5 s: it answers when the job changes), `DELETE jobs/{id}`, `POST jobs/{id}/cancel` |
131
+ | Monitoring | `GET metrics`, `GET status`, `GET usage`, `GET config`, `POST config/reload`, and the `GET /_freellama/ui` page |
132
+
133
+ The catalog and general readiness endpoint remain Ollama-oriented. Explicit llama.cpp
134
+ `routes` and `tasks` calls work without a reachable Ollama server, but its adapter refuses tools,
135
+ images, embeddings, streaming and lifecycle operations. See [Managed llama.cpp](LLAMACPP.md).
136
+
137
+ Request shapes are in [Architecture](ARCHITECTURE.md#request-shapes); monitoring fields are in
138
+ [Monitoring](MONITORING.md). `POST tasks` with `"stream": true` answers with server-sent events
139
+ (`route`, `admission`, `delta`, then `done` with the usual receipt) on supported Ollama tasks:
140
+
141
+ ```sh
142
+ curl -N http://127.0.0.1:11435/_freellama/v1/tasks -H 'content-type: application/json' \
143
+ -d '{"task":"completion","model":"TAG","prompt":"Two sentences about llamas.","stream":true}'
144
+ ```
145
+
146
+ ## Ollama-compatible passthrough
147
+
148
+ By default, paths outside `/_freellama/*` on `serve` are forwarded to the primary Ollama with
149
+ byte-preserving streaming, raw admission, host-pressure holds and usage telemetry
150
+ ([sidecar](ARCHITECTURE.md#ollama-sidecar)). It covers Ollama's native `/api/*`, its
151
+ OpenAI-compatible `/v1/*`, and the Anthropic-compatible `/v1/messages`. A few paths get special
152
+ handling:
153
+
154
+ - `/v1/*` requests go by model to the engines listed in `upstreams.toml`, and `GET /v1/models` is
155
+ merged across them.
156
+ - `POST /v1/systemone` has its `assets` translated to `images`.
157
+ - Pulls, pushes, copies, deletes and blob uploads skip the execution lock.
158
+ - A request with `keep_alive:0` is treated as an unload.
159
+
160
+ `freellama proxy` runs only this layer.