Files
loki/scripts/openclaw/media-understanding.json
CatoandClaude Opus 5.5 a1cc13053c feat(mcp): message Loki from any AI app; the Telegram agent reads screenshots and videos (#965)
* 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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-28 14:49:20 -07:00

19 lines
1.6 KiB
JSON

{
"image": {
"enabled": true,
"models": [{ "provider": "google" }],
"maxChars": 6000,
"timeoutSeconds": 90,
"attachments": { "mode": "all", "maxAttachments": 10 },
"prompt": "You are the eyes of an assistant that cannot see this image and must act on it. If it is a screenshot: name the app or site if recognisable, then transcribe ALL visible text verbatim (messages, labels, buttons, errors, code, numbers, URLs), keeping the reading order, and say which element is selected, highlighted or pointed at. If it is a photo: describe the subjects, the setting and any text in it. State only what is visible; do not guess what is off-screen."
},
"video": {
"enabled": true,
"models": [{ "provider": "google" }],
"maxChars": 20000,
"timeoutSeconds": 300,
"attachments": { "mode": "all", "maxAttachments": 2 },
"prompt": "You are the eyes and ears of an assistant that will discuss this video with its owner, including whether what it says holds up. Report, in this order: 1) SUMMARY: one sentence. 2) TRANSCRIPT: everything spoken, labelled by speaker, with approximate timestamps; if not in English, give the original and an English translation. 3) VISUALS: what is shown, chronologically with timestamps, including all on-screen text verbatim. 4) CLAIMS: every factual claim made (spoken or on screen), one bullet each, with who makes it and when. 5) AUTHENTICITY: any visible sign of editing, splicing, AI generation, staging or a misleading caption, or 'none observed'. Report only what is in the video; do not judge whether the claims are true."
}
}