@octocodeai/freellama-mcp-server 0.5.0 → 0.6.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.
@@ -12,9 +12,12 @@ not provide tenant isolation or billing.
12
12
 
13
13
  - Install one Ollama CLI and server version. Run `freellama doctor` and resolve any mismatch.
14
14
  - Install Node.js 20 or later for MCP and npm distribution use.
15
- - Use the release artifacts for your operating system, or build with Rust 1.85 or later.
15
+ - Use the release artifacts for your operating system, or build with Rust 1.88 or later.
16
16
  - Preinstall and benchmark exact model tags. Discovery never authorizes a pull.
17
17
  - Keep the primary and optional CPU Ollama processes on distinct loopback sockets.
18
+ - In a slim or distroless container, install the CA bundle (`ca-certificates`) or set
19
+ `SSL_CERT_FILE` if any upstream uses `https://`. Without one, FreeLlama starts with an empty trust
20
+ store and warns: plain-HTTP upstreams work, HTTPS upstreams fail their certificate check.
18
21
 
19
22
  After a tag has been published, install that exact checksummed release on macOS or Linux:
20
23
 
@@ -31,18 +34,14 @@ published tag:
31
34
  powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -Version VERSION
32
35
  ```
33
36
 
34
- The [release workflow](../.github/workflows/release.yml) builds CLI and native artifacts for eight
35
- targets, assembles packages, verifies package contents, and publishes on version tags. The
36
- [CI workflow](../.github/workflows/ci.yml) runs Rust checks on macOS, Linux, and Windows, plus
37
- JavaScript/native checks on macOS and Linux. These workflows do not prove driver compatibility or
38
- complete the hardware promotion checklist below. Release artifact builds depend on the reusable CI checks.
39
- The publish step also verifies that a version tag matches the workspace version.
37
+ The repository has no CI or release workflows; they were removed (see git history). Release from a
38
+ clean checkout: `yarn release:version <version>`, `yarn release:build` (builds each target's
39
+ executable and addon into `release-artifacts/<target>/`), `node scripts/assemble-release.mjs
40
+ release-artifacts release`, then `yarn release:verify:publish`. The publish verifier checks that
41
+ `FREELLAMA_RELEASE_TAG`, when set, matches the workspace version.
40
42
  Live E2E and hardware qualification remain separate operator checks; verify those receipts before tagging.
41
43
 
42
- For manual assembly, build and test every claimed target in a clean
43
- environment, place each executable and matching addon under `release-artifacts/<target>/`, run
44
- `yarn release:assemble release-artifacts release` and `yarn release:verify:publish`, then attach
45
- `release/SHA256SUMS` and binaries to the release. Publish the eight `@octocodeai/freellama-native-*` packages
44
+ Attach `release/SHA256SUMS` and binaries to the release. Publish the eight `@octocodeai/freellama-native-*` packages
46
45
  first, followed by the exact-version `@octocodeai/freellama` and `@octocodeai/freellama-mcp-server` packages. Configure
47
46
  registry credentials in the release environment; never store them in the repository.
48
47
 
@@ -82,7 +81,7 @@ FreeLlama and Ollama have separate queues. FreeLlama caps retained managed waite
82
81
  `--max-queued-tasks`/`--cpu-max-queued-tasks`, then waits for at most
83
82
  `--max-queue-wait-seconds`. An admitted request can then enter Ollama's internal queue,
84
83
  which is bounded by `OLLAMA_MAX_QUEUE`. Raw compatibility traffic bypasses weighted managed
85
- admission and enters the primary Ollama queue through a separate one-stream default cap in `serve`.
84
+ admission and, for generation, enters the primary Ollama queue through a separate one-stream default cap in `serve`.
86
85
  Set all limits from observed latency and overload behavior; changing one does not configure the
87
86
  others.
88
87
 
@@ -91,7 +90,7 @@ The following flow shows where each production setting applies:
91
90
  ```mermaid
92
91
  flowchart LR
93
92
  C["Client"] --> FQ["FreeLlama admission<br/>weighted budget + wait deadline"]
94
- FQ -->|"refused"| E503["503 server busy"]
93
+ FQ -->|"refused"| E503["429 or 503 server busy"]
95
94
  FQ -->|"admitted"| OQ["Ollama queue<br/>OLLAMA_MAX_QUEUE"]
96
95
  RAW["Raw /api/* or /v1/*"] --> RC["Raw stream cap<br/>default 1 in serve"]
97
96
  RC -->|"refused"| E503
@@ -102,14 +101,24 @@ flowchart LR
102
101
 
103
102
  These values are conservative starting points, not universal constants. NVIDIA, AMD, Apple, and
104
103
  CPU-only hosts must pass hardware validation before promotion. See
105
- [Ollama and FreeLlama optimization](dev/OLLAMA_SYSTEM_OPTIMIZATION.md) for the ownership boundary and
106
104
  [Run models on CPU and GPU](CPU_GPU_ROUTING.md) for device-specific controls.
107
105
 
106
+ Ollama already picks the accelerator, fits the model to device memory, splits layers between CPU
107
+ and GPU, and schedules requests; FreeLlama decides which tasks reach it. These changes do not help:
108
+
109
+ - Forcing one model's layers between CPU and GPU: partial CPU offload usually lowers decode speed.
110
+ Run a separate CPU-only Ollama process for a second model instead.
111
+ - Running Ollama in Docker on macOS: Docker Desktop gives it no GPU acceleration there.
112
+ - Raising context globally: K/V memory grows with context; size `num_ctx` per request.
113
+ - Pinning several large models in one process without the memory arithmetic: weights, runtime
114
+ buffers and every active context must fit together.
115
+ - `q4_0` K/V cache as a default: it trades more quality than `q8_0` for the memory it saves.
116
+
108
117
  Put the values in the service manager that owns each Ollama process: launchd on macOS, systemd or
109
118
  the container definition on Linux, and the Windows service wrapper. Shell exports and
110
119
  `launchctl setenv` are useful diagnostics but are login-session state, not a reboot-persistent
111
- production configuration. After a real service restart, rerun `doctor` and `skills/freellama/scripts/check.sh` and
112
- require the same visible values before admitting work.
120
+ production configuration. After a real service restart, rerun `freellama doctor` and `freellama status`
121
+ and require the same visible values before admitting work.
113
122
 
114
123
  ## Create the security and state files
115
124
 
@@ -170,7 +179,8 @@ only model identifiers, scale, and sample count; they contain no prompts.
170
179
  Keep adapter context settings distinct from Ollama server context. `FREELLAMA_AGENT_NUM_CTX`
171
180
  budgets the adapter conversation; older tool observations are compacted inside that budget while
172
181
  the system prompt and original question remain pinned by default. `OLLAMA_CONTEXT_LENGTH` controls
173
- direct Ollama requests, and managed FreeLlama tasks send their own `num_ctx`.
182
+ direct Ollama requests; managed FreeLlama tasks size their own context and send `num_ctx` unless
183
+ Ollama's known default covers it.
174
184
 
175
185
  ## Verify lifecycle and placement
176
186
 
@@ -187,22 +197,19 @@ Require these health contracts before admitting traffic:
187
197
  - `placement_observation: ollama_api_ps_after_execution`
188
198
  - `placement_evidence_gate: configured_or_observed`
189
199
 
190
- Run `skills/freellama/scripts/check.sh` with `FREELLAMA_AUTH_TOKEN_FILE` set. It verifies the
191
- active versions, visible Ollama settings, persisted-feedback contract, authentication contract,
192
- backend topology, and binary freshness. Also inspect the service definition for any setting that
193
- the Ollama process does not expose to FreeLlama.
200
+ With `FREELLAMA_AUTH_TOKEN_FILE` set, run `freellama doctor` (Ollama and CLI versions, visible Ollama
201
+ settings, machine) and read `/_freellama/v1/health` (FreeLlama version, `security`, `feedback.persistence`,
202
+ `backends`) and `freellama status` (backend topology, loaded models, admission). Also inspect the
203
+ service definition for any setting that the Ollama process does not expose to FreeLlama.
194
204
 
195
205
  ## Validate every hardware class
196
206
 
197
207
  Run compile and deterministic test checks from clean checkouts on Windows, Linux, and macOS. Live
198
208
  accelerator acceptance is separate because build machines do not necessarily represent production
199
209
  GPU drivers or memory topology. Prepare Apple Metal, NVIDIA Linux, AMD Linux, and NVIDIA Windows
200
- hosts, then run `benchmark/hardware/run_validation.py` directly on each host.
210
+ hosts, then run a hardware acceptance check directly on each host.
201
211
 
202
- Each environment supplies its exact GPU and CPU model tags and a running FreeLlama endpoint. The
203
- portable runner in `benchmark/hardware/run_validation.py` executes GPU coding and CPU embedding
204
- concurrently, verifies physical processor receipts, checks admission receipts, and writes a JSON
205
- artifact. Add `--vision-model` and `--vision-image` for that host's OCR/vision gate.
212
+ The portable hardware runners were removed from the repository; they remain in git history.
206
213
 
207
214
  Do not mark a hardware row validated until its archived receipt says `verdict: accept`. Missing
208
215
  hardware is an explicit release gap, not a result that documentation can waive.
package/docs/README.md CHANGED
@@ -2,39 +2,31 @@
2
2
 
3
3
  FreeLlama helps agents offload bounded work to local models through Ollama. The calling agent owns
4
4
  the task and verifies the answer; FreeLlama manages model selection and resources around execution.
5
- Start with the [repository quick start](../README.md#quick-start) to run one managed task.
5
+ Start with the [repository MCP setup](https://github.com/bgauryy/FreeLlama/blob/main/README.md#mcp-server) to run one managed task.
6
6
 
7
7
  ## Choose a guide
8
8
 
9
9
  | Goal | Guide |
10
10
  |---|---|
11
- | Connect an agent and choose a tool | [MCP server](../packages/mcp/README.md) |
12
- | Follow the agent's operating workflow | [FreeLlama skill](../skills/freellama/README.md) |
11
+ | Connect an agent and choose a tool | [MCP server](https://github.com/bgauryy/FreeLlama/blob/main/packages/mcp/README.md) |
12
+ | Follow the agent's operating workflow | [FreeLlama skill](https://github.com/bgauryy/FreeLlama/blob/main/skills/freellama/SKILL.md) |
13
13
  | Look up commands and task controls | [CLI reference](CLI.md) |
14
14
  | Understand task and resource ownership | [Architecture](ARCHITECTURE.md) |
15
- | Choose a model from measured evidence | [Model selection](MODEL_SELECTION.md) |
16
- | Interpret capabilities and public model metadata | [Model metadata](MODEL_METADATA.md) |
15
+ | Choose a model and interpret its metadata | [Model selection](MODEL_SELECTION.md), [model metadata](MODEL_SELECTION.md#model-metadata) |
17
16
  | Configure CPU helpers alongside GPU work | [CPU/GPU routing](CPU_GPU_ROUTING.md) |
18
17
  | Inspect queues, memory, usage, and live settings | [Monitoring](MONITORING.md) |
19
18
  | Retain history, affinity, or residency | [Scopes and warming](SCOPES_AND_WARMING.md) |
20
- | Understand raw Ollama compatibility | [Sidecar boundary](OLLAMA_SIDECAR.md) |
21
- | Evaluate context offload and its cost | [Token economics](ECONOMICS.md) |
19
+ | Understand raw Ollama compatibility | [Ollama sidecar](ARCHITECTURE.md#ollama-sidecar) |
20
+ | Evaluate context offload and its cost | [Token economics](https://github.com/bgauryy/FreeLlama/blob/main/packages/mcp/README.md#token-economics) |
22
21
  | Deploy the management layer | [Production runbook](PRODUCTION.md) |
23
- | Run development and release checks | [Testing](TESTING.md), [release procedure](../RELEASE.md) |
24
- | Embed the routing core | [Rust core](../packages/rust-core/README.md) |
25
- | Use the read-only dashboard | [Runtime view](../packages/view/README.md) |
22
+ | Run development and release checks | [Testing](TESTING.md), [release packages](TESTING.md#verify-release-packages) |
23
+ | Embed the routing core | [Rust core](https://github.com/bgauryy/FreeLlama/blob/main/packages/rust-core/README.md) |
24
+ | Use the read-only status page | `/_freellama/ui` on a running `serve` (see [Monitoring](MONITORING.md)) |
26
25
 
27
26
  ## Evidence and design
28
27
 
29
28
  | Goal | Source |
30
29
  |---|---|
31
- | Describe the product and its limits | [Product positioning](PRODUCT_POSITIONING.md) |
32
- | Review dated findings and project comparisons | [Findings report](dev/FINDINGS_AND_POSITIONING.md) |
33
- | Measure inference, device activity, and thermal behavior | [Local performance testing](dev/LOCAL_PERFORMANCE_TESTING.md) |
34
- | Separate management controls from inference tuning | [Ollama optimization boundary](dev/OLLAMA_SYSTEM_OPTIMIZATION.md) |
35
- | Understand backend selection decisions | [Resource-routing ADR](dev/ADR_RESOURCE_AWARE_BACKEND_ROUTING.md) |
36
- | Choose a model, adapter, or hardware benchmark | [Benchmark index](../benchmark/README.md) |
37
- | Inspect research adapter contracts and caveats | [Adapter reference](../benchmark/local/docs/07-adapter-contracts.md) |
38
30
 
39
31
  Historical measurements describe one model, machine, and workload. Inspect current state and
40
32
  repeat the relevant checks before using them to select models or set resource limits.
@@ -41,15 +41,15 @@ Create accepts the following optional fields:
41
41
  | HTTP field | MCP field | Meaning |
42
42
  |---|---|---|
43
43
  | `messages` | `messages` | Initial Ollama messages, preserving fields, content, and order. |
44
- | `route_defaults` | `routeDefaults` | Task-routing defaults for later scoped execution. |
45
- | `limits` | `limits` | Per-scope bounds within the server's configured limits. |
44
+ | `route_defaults` | — | Task-routing defaults for later scoped execution (HTTP/CLI only). |
45
+ | `limits` | — | Per-scope bounds within the server's configured limits (HTTP/CLI only). |
46
46
 
47
47
  Messages require a supported role and can omit content, including for assistant tool calls.
48
48
  When present, content must be a string.
49
49
 
50
50
  Routing defaults accept `task`, `objective`, `model`, `required_capabilities`, `context_tokens`,
51
- `execution_preference`, `min_placement_evidence`, and `min_confidence`. MCP uses the corresponding
52
- camelCase field names. Defaults do not grant admission or qualify a model. Explicit task fields
51
+ `execution_preference`, `min_placement_evidence`, and `min_confidence`. MCP callers set routing per
52
+ `run_task` call instead. Defaults do not grant admission or qualify a model. Explicit task fields
53
53
  take precedence, and execution checks current eligibility and resources.
54
54
 
55
55
  The metadata receipt contains `scope_id`, `revision`, `route_defaults`, `limits`, `message_count`,
@@ -59,7 +59,7 @@ Token estimates derive from the full serialized message bytes and count both med
59
59
  This storage-budget estimate can refuse media-heavy history before inference; it does not measure
60
60
  image token cost or determine the model context required to execute the history.
61
61
 
62
- Fork requires `revision` and accepts optional replacement routing defaults and limit overrides. It creates a
62
+ Fork requires `revision`; HTTP/CLI forks also accept replacement routing defaults and limit overrides. It creates a
63
63
  separate history snapshot with revision `0`; later writes to either scope do not change the other.
64
64
  Fork independent branches before parallel execution instead of submitting concurrent writes to one
65
65
  scope.
@@ -138,15 +138,14 @@ precedence. Inspect effective values and their sources with
138
138
  | `total_max_bytes` | `FREELLAMA_SCOPE_TOTAL_MAX_BYTES` | `16777216` | Aggregate retained history-byte budget. |
139
139
  | `ttl_seconds` | `FREELLAMA_SCOPE_TTL_SECONDS` | `3600` | Idle expiry since create, fork, or successful append; reads do not renew it. |
140
140
 
141
- Per-scope `limits` accepts `max_messages`, `max_bytes`, `max_estimated_tokens`, and `ttl_seconds`;
142
- MCP uses `maxMessages`, `maxBytes`, `maxEstimatedTokens`, and `ttlSeconds`. A request can lower these
143
- bounds within server policy. Finite safety bounds remain operator-owned. Lowering runtime caps
141
+ Per-scope HTTP/CLI `limits` accepts `max_messages`, `max_bytes`, `max_estimated_tokens`, and
142
+ `ttl_seconds` and can only lower these bounds within server policy. Finite safety bounds remain operator-owned. Lowering runtime caps
144
143
  does not summarize or trim stored transcripts; subsequent writes must satisfy the active caps.
145
144
  Expired entries are removed during store operations.
146
145
 
147
146
  ## Warm API
148
147
 
149
- `POST /warm`, MCP `warm_model`, and CLI `warm` load an exact installed model with a matching
148
+ `POST /warm`, MCP `run_task {warm:true}`, and CLI `warm` load an exact installed model with a matching
150
149
  non-embedding task profile. They do not accept prompts or messages, pull a model, or store conversation
151
150
  history. The default task profile is `completion`.
152
151
 
package/docs/TESTING.md CHANGED
@@ -19,24 +19,27 @@ flowchart LR
19
19
  ## Install and build
20
20
 
21
21
  ```bash
22
+ corepack enable # Yarn version comes from package.json "packageManager"
22
23
  yarn install
23
24
  yarn build
24
25
  ```
25
26
 
26
- The root build compiles the host Rust release binary, NAPI addon, and single-file MCP JavaScript
27
- bundle. The native `.node` addon remains external to the JavaScript bundle because it is selected
27
+ The root build compiles the host Rust release binary, NAPI addon, and MCP JavaScript bundles
28
+ (server and research adapters). The native `.node` addon remains external to the JavaScript bundle because it is selected
28
29
  by platform triple at runtime. Published packages resolve it from an OS/CPU/libc-specific optional
29
30
  dependency rather than compiling Rust during installation.
30
31
 
31
32
  ## Run the test tiers
32
33
 
34
+ The root `yarn build`, `yarn lint`, and `yarn test` run across every package: the Rust crates
35
+ (`rust-core`, `cli`) through Cargo and the JavaScript workspaces (`mcp`, `cli`, `native/*`) through
36
+ Yarn. Use the `:js` or `:rust` variants to run one side only.
37
+
33
38
  | Tier | Command | External requirements |
34
39
  |---|---|---|
35
- | JavaScript unit | `yarn test` | None |
36
- | JavaScript watch | `yarn test:watch` | None |
40
+ | All package unit tests (JS + Rust) | `yarn test` | Rust toolchain |
41
+ | JavaScript unit | `yarn test:js` | None |
37
42
  | Rust contracts | `yarn test:rust` | Rust toolchain |
38
- | Local-agent contracts | `yarn test:agents` | Python 3 standard library |
39
- | Hardware runner contracts | `python3 -m unittest discover -s benchmark/hardware -p 'test_*.py'` | Python 3 standard library; no inference |
40
43
  | TypeScript | `yarn typecheck` | None after install |
41
44
  | MCP integration | `yarn test:integration` | Ollama at `FREELLAMA_OLLAMA_ENDPOINT` (default `127.0.0.1:11434`) |
42
45
  | MCP end to end | `yarn test:e2e` | Ollama, `freellama serve`, and required models |
@@ -66,7 +69,7 @@ failures. MCP integration's `model-knowledge.test.ts` exercises the built server
66
69
  local HTTP fixtures for both Ollama API data and public HTML. It checks optional enrichment,
67
70
  assigned-backend inventory, tag pagination, validation, and preservation of benchmark/policy evidence.
68
71
  The fixture tests perform no inference, pulls, or deletions. See the
69
- [metadata reference](MODEL_METADATA.md) for the public states these tests protect.
72
+ [metadata reference](MODEL_SELECTION.md#model-metadata) for the public states these tests protect.
70
73
 
71
74
  ## Run static Rust checks
72
75
 
@@ -133,11 +136,11 @@ Usage-ledger unit contracts cover ordered writes, bounded queue overflow, failed
133
136
  validation, replay, and flush behavior. `monitoring_contract` also checks that a blocked ledger path
134
137
  does not hold task completion. Persistence remains best effort, not a zero-loss promise.
135
138
 
136
- MCP `serve.test.ts` checks startup permission failure, retry, and child-lifecycle isolation. The
139
+ MCP `serve.test.ts` checks startup permission failure, retry, child-lifecycle isolation, and the
140
+ background start at launch. The
137
141
  protocol integration contracts verify that spawn failure leaves the MCP connection usable and that
138
142
  fixture-backed library requests fail on unexpected product errors. External catalog availability
139
- is separate from these deterministic checks. Runtime-view `app-windows.test.ts` checks legitimate
140
- Windows static paths alongside traversal refusal.
143
+ is separate from these deterministic checks.
141
144
 
142
145
  Launcher fixtures use `process.execPath` to avoid an extra PATH-resolved shell wrapper. After the
143
146
  MCP fixture's real executable-permission refusal, a test-only transport launches that exact fixture
@@ -156,8 +159,8 @@ a resident routing preview to agree with execution under a low-memory-only hold.
156
159
  Run the isolated control timing experiments separately from the full suite:
157
160
 
158
161
  ```bash
159
- cargo test --test control_timing_contract -- --include-ignored --nocapture
160
- cargo test --test task_jobs_contract measure_deferred_control_latency -- --ignored --nocapture
162
+ cargo test --test integration control_timing_contract -- --include-ignored --nocapture
163
+ cargo test --test integration task_jobs_contract::measure_deferred_control_latency -- --ignored --nocapture
161
164
  ```
162
165
 
163
166
  These fixed-budget experiments use simulated backends to measure status, discovery, queue
@@ -188,32 +191,19 @@ After rebuilding the release, a fresh concurrent smoke check completed both mana
188
191
  Qwen, one embedding from Nomic, positive Qwen VRAM, zero Nomic VRAM, and primary Ollama 0.33.2
189
192
  through raw passthrough.
190
193
 
191
- For promotion, use the portable [hardware acceptance runner](../benchmark/hardware/README.md) and
192
- archive its JSON receipt with the release evidence. Compilation alone does not validate a driver,
193
- physical placement, shared-memory contention, or OCR quality.
194
-
195
- The runner measures separate sequential and parallel runs of identical workloads across at least
196
- three pairs, and checks every result before reporting successful-task throughput. It requires a
197
- configurable median gain (default 5%). Resident GPU bytes establish placement; they do not measure
198
- device busy percentage, bandwidth or energy efficiency. Sustained throughput and tail latency
199
- require a representative workload and separate device/thermal observations.
194
+ The portable hardware acceptance, workload, comparison, and load runners were removed from the
195
+ repository; they remain in git history. Compilation alone does not validate a driver, physical
196
+ placement, shared-memory contention, or OCR quality.
200
197
 
201
198
  The historical CPU/GPU observations above predate the corrected paired-run acceptance gate.
202
- They remain records of those runs, and do not qualify a release under the current gate.
203
-
204
- For a GPU workload with independent expected answers, use
205
- `benchmark/hardware/run_workload.py --workload MANIFEST.json --output RECEIPT.json`. It accepts
206
- distinct generation or vision cases, runs at least three alternating pairs, retains every
207
- result, and rejects incomplete or incorrect workloads. Its client deadline also bounds a hung
208
- measurement worker. See the [hardware guide](../benchmark/hardware/README.md) for the manifest
209
- contract.
199
+ They remain records of those runs and do not qualify a release.
210
200
 
211
201
  ## Verify release packages
212
202
 
213
203
  ```bash
214
204
  # Collect each target's `freellama` executable and `freellama.<target>.node`
215
205
  # under release-artifacts/<target>/, then stage all eight platform packages.
216
- yarn release:assemble release-artifacts release
206
+ node scripts/assemble-release.mjs release-artifacts release
217
207
  yarn release:verify:publish
218
208
  ```
219
209
 
@@ -225,11 +215,8 @@ prove registry publication or another hardware class.
225
215
 
226
216
  ## Test one layer while iterating
227
217
 
228
- The October 2, 2026 fixture investigation retained failed launches, raw dynamic-loader samples,
229
- and passing reruns. After the executable-fixture correction described above, the normal
230
- `yarn test` command passed 152 tests in 1.83 seconds of suite time. Test and production deadlines
231
- remain unchanged. Preserve failed and passing receipts together; this result does not qualify
232
- production startup timing.
218
+ When investigating a fixture failure, preserve failed and passing receipts together; a passing
219
+ rerun does not qualify production startup timing.
233
220
 
234
221
  ```bash
235
222
  yarn build:native