()
| 586 | } |
| 587 | |
| 588 | async function resolveAgent(): Promise<string | undefined> { |
| 589 | const envAgent = useEnvAgent() |
| 590 | if (!envAgent) return undefined |
| 591 | |
| 592 | // Validate the agent exists and is a primary agent |
| 593 | const agents = await client.agent.list<true>() |
| 594 | const agent = agents.data?.find((a) => a.name === envAgent) |
| 595 | |
| 596 | if (!agent) { |
| 597 | console.warn(`agent "${envAgent}" not found. Falling back to default agent`) |
| 598 | return undefined |
| 599 | } |
| 600 | |
| 601 | if (agent.mode === "subagent") { |
| 602 | console.warn(`agent "${envAgent}" is a subagent, not a primary agent. Falling back to default agent`) |
| 603 | return undefined |
| 604 | } |
| 605 | |
| 606 | return envAgent |
| 607 | } |
| 608 | |
| 609 | async function chat(text: string, files: PromptFiles = []) { |
| 610 | console.log("Sending message to opencode...") |
no test coverage detected