import path from "node:path";

import { parseAgentEnv } from "@code/env/agent";
import { defineAgent } from "@flue/runtime";
import type { AgentRouteHandler } from "@flue/runtime";
// import { agentos } from "../sandboxes/agentos";
import { local } from "@flue/runtime/node";

import paseo from "../skills/paseo/SKILL.md" with { type: "skill" };
import { paseoCli } from "../tools/paseo";

const repositoryRoot = path.resolve(process.cwd(), "../..");

export const route: AgentRouteHandler = (_context, next) => next();

export default defineAgent(({ env }) => {
  const { AGENT_MODEL_NAME, AGENT_MODEL_PROVIDER } = parseAgentEnv(env);

  return {
    cwd: repositoryRoot,
    description: "A simple conversational agent with persistent history.",
    instructions:
      "You are Zopu, a concise and helpful assistant. Answer the user's request directly. Ask a clarifying question only when the request cannot be completed without one.",
    model: `${AGENT_MODEL_PROVIDER}/${AGENT_MODEL_NAME}`,
    // sandbox: agentos(),
    sandbox: local({ cwd: repositoryRoot }),

    skills: [paseo],
    tools: [paseoCli],
  };
});
