mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 19:27:38 +01:00
* 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>
65 lines
2.5 KiB
YAML
65 lines
2.5 KiB
YAML
name: Fleet env
|
|
|
|
# /opt/fleet/env: the fleet's shared keys (AI vendors, web search, the shared
|
|
# mail account), held ONCE on the box and read by every app before its own
|
|
# .env (scripts/hetzner/fleet-env.sh, launch.sh.tmpl). "seed" fills keys the
|
|
# file lacks with the value the apps already share and never overwrites one;
|
|
# "show" lists each key as set or not with an 8-character fingerprint. No
|
|
# value is ever printed. Rotating a key is one edit to /opt/fleet/env.
|
|
# "usage-log" points every app at one AI usage log (AI_USAGE_DIR in the fleet
|
|
# file) and restarts them. "where" lists every env file on the box that sets the key named in `key`;
|
|
# "retire" switches that key off in all of them (the line becomes a dated
|
|
# comment) and restarts the apps, one at a time, so none keeps the old value.
|
|
#
|
|
# Manual on purpose: it writes to the box.
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
action:
|
|
description: "show, seed, usage-log, where or retire"
|
|
required: true
|
|
default: show
|
|
type: choice
|
|
options: [show, seed, usage-log, where, retire]
|
|
key:
|
|
description: "where / retire: the env name, e.g. GEMINI_API_KEY"
|
|
required: false
|
|
default: ""
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: deploy-prod
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
fleet-env:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
env:
|
|
HETZNER_IP: ${{ vars.HETZNER_IP }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: SSH setup
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
printf '%s\n' "${{ secrets.HETZNER_SSH_KEY }}" > ~/.ssh/id_deploy
|
|
chmod 600 ~/.ssh/id_deploy
|
|
ssh-keyscan -H "$HETZNER_IP" >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
- name: ${{ inputs.action }}
|
|
env:
|
|
ACTION: ${{ inputs.action }}
|
|
KEY: ${{ inputs.key }}
|
|
run: |
|
|
set -euo pipefail
|
|
case "$KEY" in *[!A-Z0-9_]*) echo "key must be an env name" >&2; exit 2 ;; esac
|
|
BOX="ubuntu@$HETZNER_IP"
|
|
SSH="ssh -o BatchMode=yes -i $HOME/.ssh/id_deploy"
|
|
$SSH "$BOX" 'sudo mkdir -p /opt/fleet/bin /opt/fleet/ai-usage && sudo chown ubuntu:ubuntu /opt/fleet /opt/fleet/bin /opt/fleet/ai-usage'
|
|
scp -q -o BatchMode=yes -i ~/.ssh/id_deploy scripts/hetzner/fleet-env.sh scripts/hetzner/fleet-keys.conf "$BOX:/opt/fleet/bin/"
|
|
$SSH "$BOX" "test -f /opt/fleet/env || { touch /opt/fleet/env && chmod 600 /opt/fleet/env; }; bash /opt/fleet/bin/fleet-env.sh $ACTION $KEY"
|