MCPcopy Index your code
hub / github.com/coder/coder / CreateSubAgent

Method CreateSubAgent

agent/agenttest/client.go:444–485  ·  view source on GitHub ↗
(ctx context.Context, req *agentproto.CreateSubAgentRequest)

Source from the content-addressed store, hash-verified

442}
443
444func (f *FakeAgentAPI) CreateSubAgent(ctx context.Context, req *agentproto.CreateSubAgentRequest) (*agentproto.CreateSubAgentResponse, error) {
445 f.Lock()
446 defer f.Unlock()
447
448 f.logger.Debug(ctx, "create sub agent called", slog.F("req", req))
449
450 // Generate IDs for the new sub-agent.
451 subAgentID := uuid.New()
452 authToken := uuid.New()
453
454 // Create the sub-agent proto object.
455 subAgent := &agentproto.SubAgent{
456 Id: subAgentID[:],
457 Name: req.Name,
458 AuthToken: authToken[:],
459 }
460
461 // Store the sub-agent in our map.
462 if f.subAgents == nil {
463 f.subAgents = make(map[uuid.UUID]*agentproto.SubAgent)
464 }
465 f.subAgents[subAgentID] = subAgent
466 if f.subAgentDirs == nil {
467 f.subAgentDirs = make(map[uuid.UUID]string)
468 }
469 f.subAgentDirs[subAgentID] = req.GetDirectory()
470 if f.subAgentDisplayApps == nil {
471 f.subAgentDisplayApps = make(map[uuid.UUID][]agentproto.CreateSubAgentRequest_DisplayApp)
472 }
473 f.subAgentDisplayApps[subAgentID] = req.GetDisplayApps()
474 if f.subAgentApps == nil {
475 f.subAgentApps = make(map[uuid.UUID][]*agentproto.CreateSubAgentRequest_App)
476 }
477 f.subAgentApps[subAgentID] = req.GetApps()
478
479 // For a fake implementation, we don't create workspace apps.
480 // Real implementations would handle req.Apps here.
481 return &agentproto.CreateSubAgentResponse{
482 Agent: subAgent,
483 AppCreationErrors: nil,
484 }, nil
485}
486
487func (f *FakeAgentAPI) DeleteSubAgent(ctx context.Context, req *agentproto.DeleteSubAgentRequest) (*agentproto.DeleteSubAgentResponse, error) {
488 f.Lock()

Callers

nothing calls this directly

Calls 6

NewMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
GetDirectoryMethod · 0.45
GetDisplayAppsMethod · 0.45
GetAppsMethod · 0.45

Tested by

no test coverage detected