MCPcopy Index your code
hub / github.com/anomalyco/opencode / localAgent

Function localAgent

packages/opencode/src/cli/cmd/run.ts:595–619  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

593 }
594
595 async function localAgent() {
596 if (!args.agent) return undefined
597 const name = args.agent
598
599 const entry = await Effect.runPromise(
600 agentSvc.get(name).pipe(Effect.provideService(InstanceRef, localInstance)),
601 )
602 if (!entry) {
603 UI.println(
604 UI.Style.TEXT_WARNING_BOLD + "!",
605 UI.Style.TEXT_NORMAL,
606 `agent "${name}" not found. Falling back to default agent`,
607 )
608 return undefined
609 }
610 if (entry.mode === "subagent") {
611 UI.println(
612 UI.Style.TEXT_WARNING_BOLD + "!",
613 UI.Style.TEXT_NORMAL,
614 `agent "${name}" is a subagent, not a primary agent. Falling back to default agent`,
615 )
616 return undefined
617 }
618 return name
619 }
620
621 async function attachAgent(sdk: OpencodeClient) {
622 if (!args.agent) return undefined

Callers 1

pickAgentFunction · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected