Files
loki/scripts
CatoandClaude Fable 5.1 ce92d74b70 fix(openclaw): find the openclaw CLI for a user whose login shell lacks it (#983)
* feat(openclaw): the Telegram agent reads screenshots, photos and videos

The Telegram agent is OpenClaw on bitbaum, and OpenClaw already describes
inbound media before the chat model reads the turn — but on defaults that
cut every description at 500 characters and read one attachment per
message. A screenshot lost most of its text; an album was read as its
first picture; video had a one-line "Describe the video." prompt.

- scripts/openclaw/media-understanding.json: versioned tools.media.image
  and tools.media.video blocks (Gemini; screenshots transcribed verbatim,
  albums read whole; videos returned as transcript + visuals + claims +
  authenticity signs so the agent can argue about whether a clip holds up).
  tools.media.audio is deliberately untouched — voice notes already work.
- scripts/openclaw/install-media-understanding.sh: the only way it reaches
  the box. Refuses without a Gemini key, writes through OpenClaw's own
  schema-validating `config set`, restarts the gateway, then proves an
  image (and, where ffmpeg exists, a video) is actually described.
- scripts/test/openclaw-media-config.ts: pins the limits and the audio
  hands-off rule.

Validated against openclaw@2026.4.23's schema locally. Not yet applied to
the box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD

* refactor(actions): share the decision and the enqueue report; let a turn be read-only

Groundwork for the MCP server, so it calls the same code the chat seams do
instead of a copy of it:

- lib/actions/decide-action.ts: approve/reject one draft, lifted out of
  POST /api/actions/[id]/decision (which now calls it; wire shape unchanged).
- lib/actions/enqueue-report.ts: what an enqueue outcome may truthfully be
  called (auto-approved / awaiting-approval / deduped), lifted out of
  POST /api/actions/propose (wire shape unchanged).
- config/orangecat.ts: the OrangeCat origin and OAuth issuer in a DB-free
  module; Auth.js and the identity bridge read the issuer from here instead
  of each re-deriving it.
- askLoki / runLokiTurn take `readOnly`: the tool loop drops its propose
  tools and the OpenClaw gateway fallback is skipped, so a caller granted
  conversation but not action cannot get Loki to act by asking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD

* feat(mcp): a remote MCP server so AI apps can message Loki and have it act

POST /api/mcp speaks MCP Streamable HTTP (stateless JSON-RPC 2.0; protocol
2025-11-25 / 2025-06-18 / 2025-03-26). claude.ai and ChatGPT connectors,
Claude Code and Cursor can ask Loki, list the approval queue and projects,
dispatch work, book appointments and decide queued actions.

Auth: a ck_* agent token (both scopes), or an OrangeCat RS256 access token
verified with node:crypto against the issuer's JWKS — iss, aud (must be the
Loki resource URL, never a client id), exp. `sub` maps to the Loki user via
orangecatActorId; an unlinked actor gets the sign-in step, not a 500. A
missing or bad token is a 401 whose WWW-Authenticate points at the RFC 9728
metadata served at /.well-known/oauth-protected-resource(/api/mcp).

Scopes loki.chat / loki.act and the tool map are SSOT in src/config/mcp.ts.
Act tools go through injectPrompt, enqueueAction and decideAction — the
functions the Telegram skill's routes call — so the approval queue gates
them exactly as it does there. Both paths are excluded from the session
middleware (proxy.ts, with the reason), registered in api-route-auth and
the demo sandbox. Docs: docs/development/mcp.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD

* fix(openclaw): match the installer's smoke output with a here-string, not a pipe

printf | grep -q can report a miss on a match under pipefail (grep exits,
the writer takes SIGPIPE). no-grep-q-in-a-pipe caught it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD

* feat(openclaw): a workflow that installs media understanding on the box

install-media-understanding.sh needs SSH to bitbaum and a Gemini key, which
a sandboxed agent session has neither of. This workflow_dispatch job has
both: it reuses deploy.yml's HETZNER_SSH_KEY / HETZNER_IP, takes the key
from the GEMINI_API_KEY repo secret or, failing that, from OrangeCat's env
already on the box, writes it into the openclaw user's ~/.openclaw/.env only
when none is there, and runs the installer, which proves a describe.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD

* fix(openclaw): find the openclaw CLI for a user whose login shell lacks it

The first run of the media workflow reached the box, found the Google key
already there, and died on `openclaw: command not found`: the CLI is under
nvm, which only an interactive .bashrc puts on PATH. Each remote step now
sources .bashrc, then falls back to the nvm / npm-global / local bin
directories, and refuses loudly if none has the binary.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tsc8Yu7TQR9a6Y5xNYkeD

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-29 08:31:35 -07:00
..
2026-08-31 09:23:30 +00:00
2026-08-31 09:23:30 +00:00
2026-08-31 09:23:30 +00:00
2026-08-31 09:23:30 +00:00
2026-08-31 09:23:30 +00:00