fix(server): send the session token on the sidecar's calls to its own proxy (UF-044)
Since the server stopped trusting loopback callers, the built-in model proxy needs the session token like every other route, but the sidecar's own calls to it sent none. The Models key check read the proxy's 401 as a rejected key, so a working Anthropic key showed "Key found but not responding". Scheduled AI tasks and loops, the dream diary narrative and the profile calls failed the same way; the profile calls also built the port from address().toString(), and the scheduled tasks used the configured port, which the desktop app's port fallback can leave pointing at another Waggle server. self-request.ts now builds the address from the bound port and adds the session token; all these calls and command.ts use it, and the token is never sent to Ollama. An end-to-end test runs the key check through the real middleware and proxy with localhost trust off; it fails without the fix. UF-045 records the persona generator, which posts to a route that does not exist; it is left open.
This commit is contained in:
@@ -72,6 +72,8 @@ Baseline: commit `b20b138` of `git.os-dev.tech/oleg.m/waggle-os`.
|
||||
| UF-041 | The CLI server does not exit on Ctrl+C or SIGTERM | Fixed | Sidecar, CLI |
|
||||
| UF-042 | Sidebar hints repeat the visible labels and are partly hidden behind the main area | Fixed | Web UI |
|
||||
| UF-043 | The chat composer draws two focus outlines | Fixed | Web UI |
|
||||
| UF-044 | A working API key shows as not responding, and other internal model calls fail | Fixed | Sidecar, models, auth |
|
||||
| UF-045 | Generating a persona from a description calls a route that does not exist | Open | Sidecar, agents |
|
||||
|
||||
## Entries
|
||||
|
||||
@@ -435,3 +437,21 @@ Entries UF-010 to UF-019 come from the UI audit `anti-slop/audit-001-2026-10-14.
|
||||
- Cause: the textarea has its own `focus-visible:ring-2` while its box already shows focus with `focus-within:border-[var(--focus-ring)]` and a glow.
|
||||
- What we did: removed the ring from the textarea. The box's border stays the single focus indicator; it measures 8.14:1 against the composer in the dark theme and 4.92:1 in the light theme. The composer test now checks for one indicator.
|
||||
- Recommendation: apply the same change in the main project.
|
||||
|
||||
### UF-044. A working API key shows as not responding, and other internal model calls fail
|
||||
- Status: Fixed
|
||||
- Found: 2026-10-26
|
||||
- Where: at commit `b20b138`, `packages/server/src/local/routes/settings.ts:309-360` (`POST /api/settings/probe-model`, the request at :344 sends no session token); the same unauthenticated requests to the built-in proxy in `packages/server/src/local/index.ts:1901`, 2117, 2297 and 2428 (scheduled AI tasks and loops), `routes/dreams.ts:31` (dream diary narrative) and `routes/profile.ts:289`, 346 and 423 (style analysis and related profile calls); the bearer check in `security-middleware.ts`, which trusts loopback callers only with `WAGGLE_TRUST_LOCALHOST=1`
|
||||
- Symptom: Settings → Models shows "Key found but not responding" for an Anthropic key that works, so the key looks as if it keeps dropping off. On a real machine the check answered `rejected`, while the same request sent with the session token got a normal model reply. Scheduled AI tasks and loops, the dream diary narrative and the profile calls fail with HTTP 401 the same way. The profile calls also built the proxy address from `address().toString()`, which is `[object Object]`, and the scheduled tasks used the configured port, which in the desktop app (port fallback) can belong to another Waggle server.
|
||||
- Cause: since the server stopped trusting loopback callers (D1), the built-in proxy needs the session token like every other route, but these internal calls do not send it. The key check reads the proxy's own 401 as a rejected key. `vitest.setup.ts` turns localhost trust on for every test, so the suites never saw it; `routes/command.ts` had the same bug fixed locally.
|
||||
- What we did: `packages/server/src/local/self-request.ts` builds the address from the port the server is bound to and adds the session token. The key check, the scheduled tasks, the dream diary, the profile calls and `command.ts` use it; the token is never sent to Ollama. A route test checks the header, and an end-to-end test with localhost trust off checks that a working key verifies through the real middleware and proxy; it fails without the fix.
|
||||
- Recommendation: apply the same change in the main project, and run the auth-sensitive suites with localhost trust off.
|
||||
|
||||
### UF-045. Generating a persona from a description calls a route that does not exist
|
||||
- Status: Open
|
||||
- Found: 2026-10-26
|
||||
- Where: at commit `b20b138`, `packages/server/src/local/routes/personas.ts:160` (`POST /api/personas/generate`, used by the agent templates view)
|
||||
- Symptom: generating an agent persona from a text description cannot get an answer from the model.
|
||||
- Cause: the route posts to `/api/anthropic/v1/messages`, which no route serves. The request also has no session token, and its port comes from `address().toString()`, which is `[object Object]`.
|
||||
- What we did: nothing yet. The fix means moving the call to the built-in proxy (`/v1/chat/completions` through `self-request.ts`) and reading its OpenAI-format reply.
|
||||
- Recommendation: move the call to the built-in proxy in the main project as well.
|
||||
|
||||
Reference in New Issue
Block a user