feat(coderd/agentapi): implement sub agent api (#17823)

Closes https://github.com/coder/internal/issues/619

Implement the `coderd` side of the AgentAPI for the upcoming
dev-container agents work.

`agent/agenttest/client.go` is left unimplemented for a future PR
working to implement the agent side of this feature.
This commit is contained in:
Danielle Maywood
2025-05-29 12:15:47 +01:00
committed by GitHub
parent bc83de2a72
commit b712d0b23f
25 changed files with 1767 additions and 252 deletions

View File

@ -51,6 +51,7 @@ type API struct {
*LogsAPI
*ScriptsAPI
*AuditAPI
*SubAgentAPI
*tailnet.DRPCService
mu sync.Mutex
@ -59,9 +60,10 @@ type API struct {
var _ agentproto.DRPCAgentServer = &API{}
type Options struct {
AgentID uuid.UUID
OwnerID uuid.UUID
WorkspaceID uuid.UUID
AgentID uuid.UUID
OwnerID uuid.UUID
WorkspaceID uuid.UUID
OrganizationID uuid.UUID
Ctx context.Context
Log slog.Logger
@ -193,6 +195,16 @@ func New(opts Options) *API {
NetworkTelemetryHandler: opts.NetworkTelemetryHandler,
}
api.SubAgentAPI = &SubAgentAPI{
OwnerID: opts.OwnerID,
OrganizationID: opts.OrganizationID,
AgentID: opts.AgentID,
AgentFn: api.agent,
Log: opts.Log,
Clock: opts.Clock,
Database: opts.Database,
}
return api
}