ai: migrate LLM backbone from Kimi CLI to Codex CLI
Retires the Moonshot/Kimi subscription in favour of the already-paid ChatGPT plan. Both CLI wrappers now run `codex exec`; the kimi-agent container is gone. adolf-llm + hindsight-llm: - runKimi -> runCodex (`codex exec --json --skip-git-repo-check`), resume via `codex exec resume <thread_id>`. - MCP moves from a per-session .mcp.json (a workaround for Kimi having no --mcp-config-file flag) to a $CODEX_HOME/config.toml generated once at startup from shared-mcp.json. Field translation is load-bearing: bearerTokenEnvVar -> bearer_token_env_var, enabledTools -> enabled_tools. - approval_policy="never" + sandbox_mode required, or unattended turns block on an approval prompt nobody can answer. kimi-agent removed. It was the ONLY large-tier deployment behind LiteLLM, so deleting it outright would have silently degraded every large-tier request to the local 4B model via the existing fallbacks. tier-large, the auto_router complex-reasoning route and their fallbacks now point at the codex-backed adolf-llm wrapper (model_name: codex-agent). Three environment blockers fixed along the way: - OpenAI geo-blocks this host (403 unsupported_country_region_territory). Both containers now egress via the host xray proxy, with NO_PROXY keeping MCP and *.alogins.net traffic off the tunnel. - node:22-slim ships no system CA store; the Rust codex binary validates TLS against it, so every HTTPS call failed with a generic transport error while Node's own fetch worked. ca-certificates added to both images. - `codex exec resume` rejects -C/--cd (plain `codex exec` accepts it), which broke follow-up turns while first turns succeeded. Known regression: Kimi's managed-usage API has no Codex equivalent, so the /usage route returns 501 and there is no quota probe for the codex model. The two quota plugins degrade quietly to no output. Also: stop tracking cognee.env (live LLM + JWT secrets) and gitignore it. The secrets remain in earlier history and should be rotated. Verified live: plain turn, SSE streaming, session resume, MCP tool call, bearer-token MCP call, and completions through both LiteLLM routes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014Y5QPagv4iun1ghpwM96Ff
This commit is contained in:
64
ai/backup-hindsight-adolf.sh
Executable file
64
ai/backup-hindsight-adolf.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
# Backup script for hindsight (Adolf's long-term memory bank) and the
|
||||
# openai_adolf-state Docker volume (Matrix E2EE identity/sessions + config).
|
||||
# Mirrors the seafile/vaultwarden/openai-llm-dbs backup.sh pattern (same repo):
|
||||
# dump/tar via `docker exec`, gzip, retention of last 5. Backup-freshness
|
||||
# monitored via .age items.
|
||||
#
|
||||
# hindsight is an embedded Postgres (pg0) instance living at
|
||||
# /mnt/ssd/dbs/hindsight on the host, bind-mounted into the `hindsight`
|
||||
# container at /home/hindsight/.pg0. We use pg_dump against the live,
|
||||
# running instance (safe, no downtime/quiescing needed — same rationale as
|
||||
# openai-llm-dbs).
|
||||
#
|
||||
# adolf-state is a named Docker volume (openai_adolf-state) owned by the
|
||||
# container's `node` user, not readable directly from the host as this
|
||||
# script's operator. We tar it from inside the `adolf` container instead
|
||||
# (docker exec has access via the mount; no host-side permission needed).
|
||||
#
|
||||
# Run every 3 days via root crontab (same schedule as sibling backups), e.g.:
|
||||
# 0 4 */3 * * /home/alvis/agap_git/ai/backup-hindsight-adolf.sh >> /mnt/backups/hindsight-adolf/backup.log 2>&1
|
||||
#
|
||||
# Restore:
|
||||
# # hindsight (drop+recreate the DB first if restoring into a fresh instance,
|
||||
# # since the dump is a plain SQL dump, not --clean):
|
||||
# gunzip -c /mnt/backups/hindsight-adolf/<DATE>/hindsight.sql.gz | \
|
||||
# docker exec -i -e PGPASSWORD=hindsight hindsight \
|
||||
# /home/hindsight/.pg0/installation/18.1.0/bin/psql -U hindsight -h 127.0.0.1 -p 5432 hindsight
|
||||
#
|
||||
# # adolf-state (container must be stopped first so files aren't overwritten
|
||||
# # while in use; extract into the volume's mountpoint):
|
||||
# docker stop adolf
|
||||
# docker run --rm -v openai_adolf-state:/target -v /mnt/backups/hindsight-adolf/<DATE>:/backup:ro \
|
||||
# alpine sh -c "rm -rf /target/* && tar xzf /backup/adolf-state.tar.gz -C /target"
|
||||
# docker start adolf
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BACKUP_DIR="/mnt/backups/hindsight-adolf"
|
||||
|
||||
DATE=$(date '+%Y%m%d-%H%M')
|
||||
DEST="$BACKUP_DIR/$DATE"
|
||||
|
||||
mkdir -p "$DEST"
|
||||
# Backup-freshness monitoring is now done via .age items (calculated fields showing
|
||||
# age of the backup). The .ts (timestamp) trappers were unreliable (history.push not
|
||||
# landing); removed in kb#189 in favor of .age overdue triggers.
|
||||
|
||||
# --- hindsight (Postgres logical dump, live/read-only) ---
|
||||
echo "Dumping hindsight..."
|
||||
docker exec -e PGPASSWORD=hindsight hindsight \
|
||||
/home/hindsight/.pg0/installation/18.1.0/bin/pg_dump -U hindsight -h 127.0.0.1 -p 5432 hindsight \
|
||||
| gzip > "$DEST/hindsight.sql.gz"
|
||||
echo "Dumped: hindsight -> $DEST/hindsight.sql.gz"
|
||||
|
||||
# --- adolf-state (tar the volume from inside the adolf container) ---
|
||||
echo "Archiving adolf-state..."
|
||||
docker exec adolf tar czf - -C /home/node/.openclaw . > "$DEST/adolf-state.tar.gz"
|
||||
echo "Archived: adolf-state -> $DEST/adolf-state.tar.gz"
|
||||
|
||||
echo "$(date): Backup complete: $DEST"
|
||||
ls -la "$DEST/"
|
||||
|
||||
# Rotate: keep last 5 backups
|
||||
ls -1dt "$BACKUP_DIR"/[0-9]*-[0-9]* 2>/dev/null | tail -n +6 | xargs -r rm -rf
|
||||
Reference in New Issue
Block a user