1 Commits
Author SHA1 Message Date
CatoandClaude Fable 5.2 137ff5d1fb fix(ai): Loki reads and writes the box's AI usage log; fleet-env usage-log points every app at it (#1709)
* ops(fleet-env): usage-log points every app at one AI usage log through the fleet file

launch.sh.tmpl sets AI_USAGE_DIR, but a launch script is only rewritten by
a site sync, so after #1704 no running app had it and Settings > AI said
the server is not writing the log. Every launch script already sources
/opt/fleet/env with export on. usage-log makes the directory, writes the
one line there once, and restarts the apps one at a time.

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

* fix(ai): Loki reads and writes the box's usage log without the launch variable

Loki's launch script predates /opt/fleet/env, so after the box was pointed
at one usage log Loki still had no AI_USAGE_DIR: the card said the server
was not writing a log. lib/ai/usage-dir takes the box's directory when the
variable is unset and it exists; instrumentation adopts it at boot (and
names the app LOKI). Loki walks its own chain, so the package cannot see
its calls: recordUsage reports each answered call to the log.

scripts/test/usage-dir.ts.

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

* docs(env): AI_APP_ID in .env.example

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

* ops(fleet-env): where and retire look beyond the app layout

The platform's Google key was retired from /opt/fleet/env and the app env
files on 2026-11-13, but nothing had looked at the builder's env
(/opt/loki/runner/.env), the named runners' (/etc/loki/runners/*.env) or the
Telegram gateway's (~openclaw/.openclaw/.env), where a copy of the same key
could still be read by a process that spends. where and retire now also
sweep /opt, /etc/loki, /home and /root for env files (not examples, not
node_modules, not releases), reading root-owned ones through sudo.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 13:41:20 +01:00