GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: `run --attach` agent validation (#11812) · chuckchen/opencode@109ea17

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode/src/cli/cmd
    • run.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/cli/cmd/run.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/run.ts
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,45 @@ export const RunCommand = cmd({
555555
// Validate agent if specified
556556
const agent = await (async () => {
557557
if (!args.agent) return undefined
558+
559+
// When attaching, validate against the running server instead of local Instance state.
560+
if (args.attach) {
561+
const modes = await sdk.app
562+
.agents(undefined, { throwOnError: true })
563+
.then((x) => x.data ?? [])
564+
.catch(() => undefined)
565+
566+
if (!modes) {
567+
UI.println(
568+
UI.Style.TEXT_WARNING_BOLD + "!",
569+
UI.Style.TEXT_NORMAL,
570+
`failed to list agents from ${args.attach}. Falling back to default agent`,
571+
)
572+
return undefined
573+
}
574+
575+
const agent = modes.find((a) => a.name === args.agent)
576+
if (!agent) {
577+
UI.println(
578+
UI.Style.TEXT_WARNING_BOLD + "!",
579+
UI.Style.TEXT_NORMAL,
580+
`agent "${args.agent}" not found. Falling back to default agent`,
581+
)
582+
return undefined
583+
}
584+
585+
if (agent.mode === "subagent") {
586+
UI.println(
587+
UI.Style.TEXT_WARNING_BOLD + "!",
588+
UI.Style.TEXT_NORMAL,
589+
`agent "${args.agent}" is a subagent, not a primary agent. Falling back to default agent`,
590+
)
591+
return undefined
592+
}
593+
594+
return args.agent
595+
}
596+
558597
const entry = await Agent.get(args.agent)
559598
if (!entry) {
560599
UI.println(

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.