Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

1.1 KB
Raw Blame
import { Hono } from 'hono';
import { loadConfig, saveConfig } from '../../utils/config.js';

const config = new Hono();

config.get('/api/config', (c) => {
  const cfg = loadConfig();
  return c.json({
    identity: cfg.identity,
    defaultProvider: cfg.providers.default,
    tokenBudget: cfg.tokens.dailyBudget,
    heartbeatInterval: cfg.heartbeat.intervalMinutes,
    telegramEnabled: cfg.channels.telegram.enabled,
    secondBrainEnabled: cfg.memory.secondBrain.enabled,
  });
});

config.put('/api/config', async (c) => {
  const body = await c.req.json();
  const cfg = loadConfig();
  if (body.identity) {
    if (body.identity.name !== undefined) cfg.identity.name = body.identity.name;
    if (body.identity.owner !== undefined) cfg.identity.owner = body.identity.owner;
  }
  if (body.defaultProvider !== undefined) cfg.providers.default = body.defaultProvider;
  if (body.tokenBudget !== undefined) cfg.tokens.dailyBudget = body.tokenBudget;
  saveConfig(cfg);
  // Providers and keys are read at boot — the save is durable, not live.
  return c.json({ success: true, restartRequired: true });
});

export default config;