getUserAgent function

String getUserAgent({
  1. required String version,
  2. String? userType,
  3. String? entrypoint,
  4. String? agentSdkVersion,
  5. String? clientApp,
  6. String? workload,
})

Get the user agent string for API requests.

Implementation

String getUserAgent({
  required String version,
  String? userType,
  String? entrypoint,
  String? agentSdkVersion,
  String? clientApp,
  String? workload,
}) {
  final parts = <String>[];
  if (agentSdkVersion != null) parts.add('agent-sdk/$agentSdkVersion');
  if (clientApp != null) parts.add('client-app/$clientApp');
  if (workload != null) parts.add('workload/$workload');

  final suffix = parts.isNotEmpty ? ', ${parts.join(", ")}' : '';
  return 'neomage-cli/$version (${userType ?? "external"}, ${entrypoint ?? "cli"}$suffix)';
}