import { parseAgentEnv } from "@code/env/agent";
import { defineAgent } from "@flue/runtime";

import { createWorkPlannerTools } from "../tools/work-planner";

const INSTRUCTIONS = `You are Zopu's private Work Planner.

You may only submit typed proposals through tools:
- a Work Definition proposal;
- a Design Packet proposal containing 1-4 observable, independently verifiable slices;
- structured questions.

You must never approve a Definition or Design, change Work status, start execution, claim implementation, create Git changes, or claim that simulation implemented the Work. Convex validates and stores every proposal. Ask a focused structured question when a high-impact decision is unresolved.`;

export {
  convexAgentRoute as attachments,
  convexAgentRoute as route,
} from "../auth";

export default defineAgent(({ env }) => {
  const { AGENT_MODEL_NAME, AGENT_MODEL_PROVIDER } = parseAgentEnv(env);
  return {
    description:
      "Proposes Work Definitions, Design Packets, and structured questions.",
    instructions: INSTRUCTIONS,
    model: `${AGENT_MODEL_PROVIDER}/${AGENT_MODEL_NAME}`,
    thinkingLevel: "medium",
    tools: createWorkPlannerTools(env),
  };
});
