MCPcopy Create free account
hub / github.com/anomalyco/opencode / resolveAgent

Function resolveAgent

github/index.ts:588–607  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

586}
587
588async 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
609async function chat(text: string, files: PromptFiles = []) {
610 console.log("Sending message to opencode...")

Callers 1

chatFunction · 0.85

Calls 2

useEnvAgentFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected