Skip to content

Sync hands-free v0.5 into main (stacked #20 landed on its base branch) - #21

Merged
mrhegemon merged 11 commits into
mainfrom
feat/glasses-ecosystem
Jul 16, 2026
Merged

mrhegemon merged 11 commits into
mainfrom
feat/glasses-ecosystem

Conversation

@mrhegemon

Copy link
Copy Markdown
Member

#20 (hands-free v0.5: STT proxy, ambient memory, intent routing, safe approvals, Dockerfile) was stacked on feat/glasses-ecosystem and merged into that base after #18 had already landed the base into main — so its content never reached main. This PR completes the sync. No new code beyond what was reviewed in #20.

🤖 Generated with Claude Code

mrhegemon and others added 11 commits July 15, 2026 21:33
…le STT server

The glasses app POSTs multipart audio to ${baseUrl}/v1/audio/transcriptions,
but agent-hub had no such route — every standardized preset 404ed the
hands-free flow. The hub now fronts chat AND speech-to-text, so the glasses
need exactly one URL.

- config: STT_URL (any Whisper-compatible server: faster-whisper-server,
  speaches, LocalAI, OpenAI) + STT_API_KEY, both default empty
- stt.ts: buffers the raw body (clips <= ~2 MB) and forwards it verbatim,
  preserving the multipart boundary Content-Type; injects the upstream key
  server-side; pipes upstream status + JSON back verbatim; 501
  stt_not_configured when STT_URL is unset, 502 on upstream refusal
- router: one route line behind the same authorized() gate (HUB_TOKEN /
  Portal JWT)
- tests: byte-for-byte passthrough, key injection, status passthrough,
  501/502 paths, 401 without credentials (23 -> 28)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
….use_memory

Memory becomes a layer, not a mode: any chat request flagged
`metadata.use_memory === true` now gets CI-Server ("Companion Memory")
recall prepended as a system message and its finished turn written back,
whatever backend it targets.

- NEW src/middleware/memory.ts: withMemoryAugment(adapter, opts) wraps any
  Adapter (same kind, approve/dispose delegated) — best-effort recall
  (never blocks the chat), re-yields inner events while accumulating text,
  fire-and-forget turn write-back {session_id, user, assistant,
  source: 'ci-glasses'} only on error-free turns with text; plus the
  wantsMemoryAugment router guard (strict boolean flag, CI-Server
  configured, memory adapter exempt).
- router.ts: thread HubConfig into handleChatCompletions and wrap the
  selected adapter when the guard passes.
- config.ts: ciServerTurnPath (CI_SERVER_TURN_PATH, default /memory/turn).
- Tests: 9 new (guard predicate, prepend without caller mutation, recall
  500 fallback, write-back body, custom paths, no write-back on error,
  router end-to-end + memory-kind exemption) — 23 → 32, all green.
- README: metadata.use_memory flow + CI_SERVER_TURN_PATH env row.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Requests with agent_kind 'auto' (or AGENT_KIND=auto as default) are now
routed from the utterance itself by a deterministic rule-based classifier
(routing/intent.ts): memory-recall phrasings go to 'memory' untouched,
explicit addresses ("ask hermes …", "claude, …") go to that agent with
the address prefix stripped in a copy of the request, everything else
falls to 'local-llm'. Unregistered targets fall back defaultKind →
local-llm → first registered. The routing decision is surfaced on the
HUD as one agent_status thinking event ("→ <kind>") in the streaming
branch only. Rule table is data-driven; an Ollama-backed classifier can
slot in behind the same classifyIntent signature later.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…istant preset

- Invert permission-prompt gestures: double-tap now APPROVES (deliberate),
  single tap DENIES (safe — the agent can re-ask); prompt-card footer and
  retry messaging updated to match ('2×tap: Approve · tap: Deny')
- BackendConfig.useMemory (default false) + 'Memory-augmented chat' toggle
  in the CI-Hub section; sent as metadata.use_memory on every chat request
- One-URL presets: the Ollama preset now routes via the agent-hub (:8787)
  so a single baseUrl fronts chat AND voice (STT); the hub injects its own
  downstream Ollama key so the user's apiKey is preserved
- New 'auto' BackendKind + first-position 'Assistant' hub preset
  (model ci-companion) and kind-picker card — agent-hub routes by intent
  (memory · Hermes · OpenClaw · chat); 'auto' is hub-routed in ApiAdapter
- Tests: prompt-card footer, assistant/ollama-via-hub presets, useMemory
  defaults + persistence, 'auto' forced to chat-completions (102 → 110)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Multi-stage node:22-alpine Dockerfile: tsc compiles src/ to dist/ in a
build stage; the runtime stage ships production deps only (jose) and runs
node dist/server.js — no tsx in the image. Defaults HUB_PORT=8787 and
HUB_BIND=0.0.0.0 (containers must bind beyond loopback; auth still gates
every request) with a BusyBox-wget /healthz HEALTHCHECK.

README gains a 'Run as a CI-Hub app / Docker' section documenting the
marketplace app (ci-glasses-bridge) and the Hub-injected env the hub
already aliases — CI_LLM_BASE_URL/CI_LLM_API_KEY for Ollama chat and
CI_SERVER_URL/CI_SERVER_TOKEN for Companion Memory — so a Hub install
needs zero manual env; Hermes/OpenClaw/static-token env stays optional.

Verified: docker build + run smoke (healthz 200, HEALTHCHECK healthy).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts:
#	agent-hub/README.md
#	agent-hub/src/config.ts
#	agent-hub/src/router.ts
Hands-free v0.5 — voice STT proxy, ambient memory, intent routing, safe approvals
Found in live testing against a real hub+Ollama stack: in plain-browser mode
the SDK can resolve a bridge whose container calls then fail ("both
textContainerUpgrade and rebuildPageContainer failed"). Those calls sat
unwrapped inside sendToAI's stream loop (agent_status showStatus, prompt card,
flushGlasses) so a HUD failure aborted the stream and replaced the streamed
answer with the renderer error.

Add safeHud() and route the flow-critical renderer calls through it (stream
loop, error path, transcribe status); flushGlasses additionally latches off
after the first failure for the rest of the turn. The phone webview is the
source of truth; the glasses display is best-effort.

Verified live: the previously-failing browser flow now streams the full
answer with a single console warning; simulator (real bridge) unaffected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mrhegemon

Copy link
Copy Markdown
Member Author

Added one commit beyond #20: fix(glasses): HUD render failures must never kill the conversation — found during live testing against a real hub + Ollama stack (browser-mode bridge resolves but container calls fail, which aborted the stream and replaced the answer with a renderer error). Verified fixed live; suite still 110 green.

@mrhegemon
mrhegemon merged commit bdb8462 into main Jul 16, 2026
3 checks passed
@mrhegemon
mrhegemon deleted the feat/glasses-ecosystem branch July 16, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant