* feat: add is_bot_message column and support dedicated phone numbers Replace fragile content-prefix bot detection with an explicit is_bot_message database column. The old prefix check (content NOT LIKE 'Andy:%') is kept as a backstop for pre-migration messages. - Add is_bot_message column with automatic backfill migration - Add ASSISTANT_HAS_OWN_NUMBER env var to skip name prefix when the assistant has its own WhatsApp number - Move prefix logic into WhatsApp channel (no longer a router concern) - Remove prefixAssistantName from Channel interface - Load .env via dotenv so launchd-managed processes pick up config - WhatsApp bot detection: fromMe for own number, prefix match for shared Based on #160 and #173. Co-Authored-By: Stefan Gasser <stefan@stefangasser.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: extract shared .env parser and remove dotenv dependency Extract .env parsing into src/env.ts, used by both config.ts and container-runner.ts. Reads only requested keys without loading secrets into process.env, avoiding leaking API keys to child processes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Stefan Gasser <stefan@stefangasser.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import path from 'path';
|
|
|
|
import { readEnvFile } from './env.js';
|
|
|
|
// Read config values from .env (falls back to process.env).
|
|
// Secrets are NOT read here — they stay on disk and are loaded only
|
|
// where needed (container-runner.ts) to avoid leaking to child processes.
|
|
const envConfig = readEnvFile(['ASSISTANT_NAME', 'ASSISTANT_HAS_OWN_NUMBER']);
|
|
|
|
export const ASSISTANT_NAME =
|
|
process.env.ASSISTANT_NAME || envConfig.ASSISTANT_NAME || 'Andy';
|
|
export const ASSISTANT_HAS_OWN_NUMBER =
|
|
(process.env.ASSISTANT_HAS_OWN_NUMBER || envConfig.ASSISTANT_HAS_OWN_NUMBER) === 'true';
|
|
export const POLL_INTERVAL = 2000;
|
|
export const SCHEDULER_POLL_INTERVAL = 60000;
|
|
|
|
// Absolute paths needed for container mounts
|
|
const PROJECT_ROOT = process.cwd();
|
|
const HOME_DIR = process.env.HOME || '/Users/user';
|
|
|
|
// Mount security: allowlist stored OUTSIDE project root, never mounted into containers
|
|
export const MOUNT_ALLOWLIST_PATH = path.join(
|
|
HOME_DIR,
|
|
'.config',
|
|
'nanoclaw',
|
|
'mount-allowlist.json',
|
|
);
|
|
export const STORE_DIR = path.resolve(PROJECT_ROOT, 'store');
|
|
export const GROUPS_DIR = path.resolve(PROJECT_ROOT, 'groups');
|
|
export const DATA_DIR = path.resolve(PROJECT_ROOT, 'data');
|
|
export const MAIN_GROUP_FOLDER = 'main';
|
|
|
|
export const CONTAINER_IMAGE =
|
|
process.env.CONTAINER_IMAGE || 'nanoclaw-agent:latest';
|
|
export const CONTAINER_TIMEOUT = parseInt(
|
|
process.env.CONTAINER_TIMEOUT || '1800000',
|
|
10,
|
|
);
|
|
export const CONTAINER_MAX_OUTPUT_SIZE = parseInt(
|
|
process.env.CONTAINER_MAX_OUTPUT_SIZE || '10485760',
|
|
10,
|
|
); // 10MB default
|
|
export const IPC_POLL_INTERVAL = 1000;
|
|
export const IDLE_TIMEOUT = parseInt(
|
|
process.env.IDLE_TIMEOUT || '1800000',
|
|
10,
|
|
); // 30min default — how long to keep container alive after last result
|
|
export const MAX_CONCURRENT_CONTAINERS = Math.max(
|
|
1,
|
|
parseInt(process.env.MAX_CONCURRENT_CONTAINERS || '5', 10) || 5,
|
|
);
|
|
|
|
function escapeRegex(str: string): string {
|
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
}
|
|
|
|
export const TRIGGER_PATTERN = new RegExp(
|
|
`^@${escapeRegex(ASSISTANT_NAME)}\\b`,
|
|
'i',
|
|
);
|
|
|
|
// Timezone for scheduled tasks (cron expressions, etc.)
|
|
// Uses system timezone by default
|
|
export const TIMEZONE =
|
|
process.env.TZ || Intl.DateTimeFormat().resolvedOptions().timeZone;
|