From 8c4b8a88efb039c2e6218bd08cbcbf8318d32c0a Mon Sep 17 00:00:00 2001 From: Operator & Codex Date: Sat, 2 May 2026 07:16:30 +0200 Subject: [PATCH] Remove hardcoded mevy runtime identity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace remaining executable-code mevy assumptions with config-derived values. This updates operator messaging, runtime prompts, agent-task role defaults, inspect-system fallbacks, and OpenRouter metadata headers to follow PLATFORM_SERVICE_NAME, PLATFORM_ID, TENANT_ID, and PROJECT_ROOT instead of the live example tenant. --- Build: pass | Tests: FAIL — Tests 3 failed | 2089 passed (2092) --- scripts/agent-task.ts | 4 ++-- scripts/inspect-system.sh | 9 +++++++-- src/agent-runner.ts | 4 ++-- src/telegram-commands.ts | 2 +- src/transcription.ts | 3 ++- src/vision.ts | 3 ++- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/agent-task.ts b/scripts/agent-task.ts index b5ba4b1..f558d76 100644 --- a/scripts/agent-task.ts +++ b/scripts/agent-task.ts @@ -1,4 +1,4 @@ -import { CONTROLPLANE_INTERNAL_DOMAIN } from '../src/config.js'; +import { CONTROLPLANE_INTERNAL_DOMAIN, TENANT_ID } from '../src/config.js'; const API_PORT = parseInt(process.env.CONTROLPLANE_PORT ?? '3100', 10); const API_HOST = process.env.CONTROLPLANE_BIND_HOST ?? '127.0.0.1'; @@ -9,7 +9,7 @@ const KNOWN_ROLES = new Set([ 'sysadmin', 'db-admin', 'git-admin', - 'mevy', + TENANT_ID, ]); const arg1 = process.argv[2]; diff --git a/scripts/inspect-system.sh b/scripts/inspect-system.sh index 70e5662..cc93abc 100755 --- a/scripts/inspect-system.sh +++ b/scripts/inspect-system.sh @@ -155,14 +155,19 @@ HOSTNAME_VALUE="$(hostname 2>/dev/null || echo unknown)" FREEBSD_VERSION="$(tr -d '\r' <"$OUTPUT_DIR/freebsd-version.txt" | head -n 1 || true)" UNAME_VALUE="$(tr -d '\r' <"$OUTPUT_DIR/uname.txt" | head -n 1 || true)" +PLATFORM_ID_VALUE="${PLATFORM_ID:-$(read_env_value PLATFORM_ID 2>/dev/null || true)}" +if [ -z "$PLATFORM_ID_VALUE" ]; then + PLATFORM_ID_VALUE="clawdie" +fi + PLATFORM_SERVICE_NAME="${PLATFORM_SERVICE_NAME:-$(read_env_value PLATFORM_SERVICE_NAME 2>/dev/null || true)}" if [ -z "$PLATFORM_SERVICE_NAME" ]; then - PLATFORM_SERVICE_NAME="mevy" + PLATFORM_SERVICE_NAME="$PLATFORM_ID_VALUE" fi PLATFORM_RUNTIME_USER="${PLATFORM_RUNTIME_USER:-$(read_env_value PLATFORM_RUNTIME_USER 2>/dev/null || true)}" if [ -z "$PLATFORM_RUNTIME_USER" ]; then - PLATFORM_RUNTIME_USER="mevy" + PLATFORM_RUNTIME_USER="$PLATFORM_SERVICE_NAME" fi ZFS_PREFIX_VALUE="${ZFS_PREFIX:-$(read_env_value ZFS_PREFIX 2>/dev/null || true)}" diff --git a/src/agent-runner.ts b/src/agent-runner.ts index 30a1a9d..fe7023d 100644 --- a/src/agent-runner.ts +++ b/src/agent-runner.ts @@ -419,9 +419,9 @@ export async function runJailAgent( `State this accurately if asked — do not guess or substitute another model name.\n` + (modelGuide ? `Rule: ${modelGuide}\n` : '') + `Rule: Do not end your reply with a promise of future inspection or follow-up unless you are actually providing that follow-up in the same message. If there is no real async job, answer directly now.\n` + - `Rule: The Mevy service runs as a FreeBSD rc.d service and executes \`node dist/index.js\` (not \`node src/index.ts\`). ` + + `Rule: The platform service runs as a FreeBSD rc.d service and executes \`node dist/index.js\` (not \`node src/index.ts\`). ` + `Do not tell the operator to run \`just dev\` or start the service manually unless explicitly asked; instead, instruct to check \`sudo service ${PLATFORM_SERVICE_NAME} status\` and use \`sudo service ${PLATFORM_SERVICE_NAME} restart\` when needed.\n` + - `Rule: Text-to-speech uses the \`edge-tts\` CLI provided by the repo wrapper at \`/home/mevy/mevy-ai/bin/edge-tts\`, which runs from a persistent uv venv at \`/home/mevy/mevy-ai/.venv-edge-tts\`. ` + + `Rule: Text-to-speech uses the \`edge-tts\` CLI provided by the repo wrapper at \`${path.join(PROJECT_ROOT, 'bin', 'edge-tts')}\`, which runs from a persistent uv venv at \`${path.join(PROJECT_ROOT, '.venv-edge-tts')}\`. ` + `Do NOT suggest installing \`edge-tts\` via pip/pkg unless explicitly asked to change the installation method.`; const lowBudgetInfo = input.lowBudget ? 'Rule: Budget is low for this chat. Keep responses concise (<= 200 words), avoid long lists, and ask for clarification rather than speculating.' diff --git a/src/telegram-commands.ts b/src/telegram-commands.ts index b5f92e9..aec5987 100644 --- a/src/telegram-commands.ts +++ b/src/telegram-commands.ts @@ -287,7 +287,7 @@ async function requireAdmin(ctxArg: any): Promise { const id = ctxArg.from?.id; await replyAuthFailure( ctxArg, - `Admin IDs not configured. Run /whoami and set TELEGRAM_ADMIN_IDS=${id ?? ''} in .env, then restart mevy.`, + `Admin IDs not configured. Run /whoami and set TELEGRAM_ADMIN_IDS=${id ?? ''} in .env, then restart ${PLATFORM_SERVICE_NAME}.`, ); return false; } diff --git a/src/transcription.ts b/src/transcription.ts index 2c1aa8d..33d6880 100644 --- a/src/transcription.ts +++ b/src/transcription.ts @@ -1,6 +1,7 @@ import { logger } from './logger.js'; import OpenAI from 'openai'; import fs from 'fs'; +import { TENANT_ID } from './config.js'; let openaiClient: OpenAI | null = null; let transcriptionReady = false; @@ -122,7 +123,7 @@ export function initTranscription( baseURL: 'https://openrouter.ai/api/v1', defaultHeaders: { 'HTTP-Referer': 'https://codeberg.org/Clawdie/Clawdie-AI', - 'X-Title': 'mevy-ai', + 'X-Title': `${TENANT_ID}-ai`, }, }); transcriptionReady = true; diff --git a/src/vision.ts b/src/vision.ts index 423fd30..6c4f31e 100644 --- a/src/vision.ts +++ b/src/vision.ts @@ -3,6 +3,7 @@ import path from 'path'; import { readEnvFile } from './env.js'; import { + TENANT_ID, TMP_DIR, VISION_MAX_CHARS_PER_IMAGE, VISION_MAX_IMAGES, @@ -89,7 +90,7 @@ async function describeImageOpenRouter(imagePath: string): Promise { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json', 'HTTP-Referer': 'https://codeberg.org/Clawdie/Clawdie-AI', - 'X-Title': 'mevy-ai', + 'X-Title': `${TENANT_ID}-ai`, }, body: JSON.stringify(body), });