( id toolspkg.ToolID, scope toolspkg.Scope, input agentCreateInput, )
| 176 | } |
| 177 | |
| 178 | func (n *daemonNativeTools) agentCreateRequest( |
| 179 | id toolspkg.ToolID, |
| 180 | scope toolspkg.Scope, |
| 181 | input agentCreateInput, |
| 182 | ) (contract.CreateAgentRequest, error) { |
| 183 | createReq := contract.CreateAgentRequest{ |
| 184 | Scope: contract.AgentCreateScope(strings.TrimSpace(input.Scope)), |
| 185 | Workspace: strings.TrimSpace(input.Workspace), |
| 186 | Agent: contract.CreateAgentPayload{ |
| 187 | Name: strings.TrimSpace(input.Name), |
| 188 | Provider: strings.TrimSpace(input.Provider), |
| 189 | Command: strings.TrimSpace(input.Command), |
| 190 | Model: strings.TrimSpace(input.Model), |
| 191 | Prompt: input.Prompt, |
| 192 | Permissions: contract.SettingsPermissionMode(strings.TrimSpace(input.Permissions)), |
| 193 | Tools: trimNativeStrings(input.Tools), |
| 194 | Toolsets: trimNativeStrings(input.Toolsets), |
| 195 | DenyTools: trimNativeStrings(input.DenyTools), |
| 196 | CategoryPath: trimNativeStrings(input.CategoryPath), |
| 197 | }, |
| 198 | } |
| 199 | if len(input.DisabledSkills) > 0 { |
| 200 | createReq.Agent.Skills = &contract.CreateAgentSkillsConfig{ |
| 201 | Disabled: trimNativeStrings(input.DisabledSkills), |
| 202 | } |
| 203 | } |
| 204 | // The bundled onboarding agent runs with approve-all over its toolsets, so a prompt-injection |
| 205 | // attempt could try to author a global-scope agent. Pin it to workspace-scoped authoring. |
| 206 | if createReq.Scope == contract.AgentCreateScopeGlobal && |
| 207 | aghconfig.NormalizeAgentName(scope.AgentName) == aghconfig.OnboardingAgentName { |
| 208 | return contract.CreateAgentRequest{}, toolspkg.NewToolError( |
| 209 | toolspkg.ErrorCodeDenied, |
| 210 | id, |
| 211 | "the onboarding agent may only author workspace-scoped agents", |
| 212 | toolspkg.ErrToolDenied, |
| 213 | toolspkg.ReasonScopeMismatch, |
| 214 | ) |
| 215 | } |
| 216 | if createReq.Scope == contract.AgentCreateScopeWorkspace { |
| 217 | workspaceRef, err := nativeCallerWorkspaceInput(id, "workspace", createReq.Workspace, scope) |
| 218 | if err != nil { |
| 219 | return contract.CreateAgentRequest{}, err |
| 220 | } |
| 221 | if strings.TrimSpace(workspaceRef) == "" { |
| 222 | return contract.CreateAgentRequest{}, nativeRequiredInputError(id, "workspace") |
| 223 | } |
| 224 | createReq.Workspace = workspaceRef |
| 225 | } |
| 226 | return createReq, nil |
| 227 | } |
| 228 | |
| 229 | func nativeAgentCreateToolError(id toolspkg.ToolID, err error) error { |
| 230 | switch { |
no test coverage detected