mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
feat: add hidden CODER_AGENT_IS_SUB_AGENT
flag to coder agent
(#17783)
Closes https://github.com/coder/internal/issues/620 Adds a new, hidden, flag `CODER_AGENT_IS_SUB_AGENT` to the `coder agent` command.
This commit is contained in:
@ -89,6 +89,7 @@ type Options struct {
|
|||||||
ServiceBannerRefreshInterval time.Duration
|
ServiceBannerRefreshInterval time.Duration
|
||||||
BlockFileTransfer bool
|
BlockFileTransfer bool
|
||||||
Execer agentexec.Execer
|
Execer agentexec.Execer
|
||||||
|
SubAgent bool
|
||||||
|
|
||||||
ExperimentalDevcontainersEnabled bool
|
ExperimentalDevcontainersEnabled bool
|
||||||
ContainerAPIOptions []agentcontainers.Option // Enable ExperimentalDevcontainersEnabled for these to be effective.
|
ContainerAPIOptions []agentcontainers.Option // Enable ExperimentalDevcontainersEnabled for these to be effective.
|
||||||
@ -190,6 +191,8 @@ func New(options Options) Agent {
|
|||||||
metrics: newAgentMetrics(prometheusRegistry),
|
metrics: newAgentMetrics(prometheusRegistry),
|
||||||
execer: options.Execer,
|
execer: options.Execer,
|
||||||
|
|
||||||
|
subAgent: options.SubAgent,
|
||||||
|
|
||||||
experimentalDevcontainersEnabled: options.ExperimentalDevcontainersEnabled,
|
experimentalDevcontainersEnabled: options.ExperimentalDevcontainersEnabled,
|
||||||
containerAPIOptions: options.ContainerAPIOptions,
|
containerAPIOptions: options.ContainerAPIOptions,
|
||||||
}
|
}
|
||||||
@ -272,6 +275,8 @@ type agent struct {
|
|||||||
metrics *agentMetrics
|
metrics *agentMetrics
|
||||||
execer agentexec.Execer
|
execer agentexec.Execer
|
||||||
|
|
||||||
|
subAgent bool
|
||||||
|
|
||||||
experimentalDevcontainersEnabled bool
|
experimentalDevcontainersEnabled bool
|
||||||
containerAPIOptions []agentcontainers.Option
|
containerAPIOptions []agentcontainers.Option
|
||||||
containerAPI atomic.Pointer[agentcontainers.API] // Set by apiHandler.
|
containerAPI atomic.Pointer[agentcontainers.API] // Set by apiHandler.
|
||||||
|
13
cli/agent.go
13
cli/agent.go
@ -53,6 +53,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
|||||||
blockFileTransfer bool
|
blockFileTransfer bool
|
||||||
agentHeaderCommand string
|
agentHeaderCommand string
|
||||||
agentHeader []string
|
agentHeader []string
|
||||||
|
subAgent bool
|
||||||
|
|
||||||
experimentalDevcontainersEnabled bool
|
experimentalDevcontainersEnabled bool
|
||||||
)
|
)
|
||||||
@ -350,6 +351,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
|||||||
PrometheusRegistry: prometheusRegistry,
|
PrometheusRegistry: prometheusRegistry,
|
||||||
BlockFileTransfer: blockFileTransfer,
|
BlockFileTransfer: blockFileTransfer,
|
||||||
Execer: execer,
|
Execer: execer,
|
||||||
|
SubAgent: subAgent,
|
||||||
|
|
||||||
ExperimentalDevcontainersEnabled: experimentalDevcontainersEnabled,
|
ExperimentalDevcontainersEnabled: experimentalDevcontainersEnabled,
|
||||||
})
|
})
|
||||||
@ -481,6 +483,17 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
|
|||||||
Description: "Allow the agent to automatically detect running devcontainers.",
|
Description: "Allow the agent to automatically detect running devcontainers.",
|
||||||
Value: serpent.BoolOf(&experimentalDevcontainersEnabled),
|
Value: serpent.BoolOf(&experimentalDevcontainersEnabled),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Flag: "is-sub-agent",
|
||||||
|
Default: "false",
|
||||||
|
Env: "CODER_AGENT_IS_SUB_AGENT",
|
||||||
|
Description: "Specify whether this is a sub agent or not.",
|
||||||
|
Value: serpent.BoolOf(&subAgent),
|
||||||
|
// As `coderd` handles the creation of sub-agents, it does not make
|
||||||
|
// sense for this to be exposed. We do not want people setting an
|
||||||
|
// agent as a sub-agent if it is not.
|
||||||
|
Hidden: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
Reference in New Issue
Block a user