MCPcopy Create free account
hub / github.com/compozy/agh / request

Method request

internal/cli/spawn.go:109–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107}
108
109func (flags *spawnCommandFlags) request() (AgentSpawnRequest, error) {
110 if strings.TrimSpace(flags.agentName) == "" {
111 return AgentSpawnRequest{}, fmt.Errorf("cli: --agent is required")
112 }
113 if flags.ttlSeconds <= 0 {
114 return AgentSpawnRequest{}, fmt.Errorf("cli: --ttl-seconds must be positive")
115 }
116 if strings.EqualFold(strings.TrimSpace(flags.spawnRole), "coordinator") {
117 return AgentSpawnRequest{}, fmt.Errorf("cli: coordinator spawn role is not supported")
118 }
119 return AgentSpawnRequest{
120 AgentName: strings.TrimSpace(flags.agentName),
121 Provider: strings.TrimSpace(flags.provider),
122 Model: strings.TrimSpace(flags.model),
123 Name: strings.TrimSpace(flags.name),
124 PromptOverlay: strings.TrimSpace(flags.promptOverlay),
125 SpawnRole: firstCLIValue(flags.spawnRole, "worker"),
126 TTLSeconds: flags.ttlSeconds,
127 AutoStopOnParent: flags.autoStopOnParent,
128 Permissions: SpawnPermissionPolicyRecord{
129 Tools: trimSpawnAtoms(flags.tools),
130 Skills: trimSpawnAtoms(flags.skills),
131 MCPServers: trimSpawnAtoms(flags.mcpServers),
132 WorkspacePaths: trimSpawnAtoms(flags.workspacePaths),
133 NetworkChannels: trimSpawnAtoms(flags.networkChannels),
134 SandboxProfiles: trimSpawnAtoms(flags.sandboxProfiles),
135 },
136 IdempotencyKey: strings.TrimSpace(flags.idempotencyKey),
137 }, nil
138}
139
140func trimSpawnAtoms(values []string) []string {
141 atoms := make([]string, 0, len(values))

Callers 1

runSpawnCommandFunction · 0.45

Calls 2

firstCLIValueFunction · 0.85
trimSpawnAtomsFunction · 0.85

Tested by

no test coverage detected