import { parseAgentEnv } from "@code/env/agent";
import { registerProvider } from "@flue/runtime";
import { flue } from "@flue/runtime/routing";
import { Hono } from "hono";

import { projectRequestRoute } from "./project-request";

const agentEnv = parseAgentEnv(process.env);

registerProvider(agentEnv.AGENT_MODEL_PROVIDER, {
  api: agentEnv.AGENT_MODEL_API,
  apiKey: agentEnv.AGENT_MODEL_API_KEY,
  baseUrl: agentEnv.AGENT_MODEL_BASE_URL,
  models: {
    [agentEnv.AGENT_MODEL_NAME]: {
      contextWindow: agentEnv.AGENT_MODEL_CONTEXT_WINDOW,
      maxTokens: agentEnv.AGENT_MODEL_MAX_TOKENS,
    },
  },
});

const app = new Hono();
app.post("/project-requests", projectRequestRoute);
app.route("/", flue());

export default app;
