taskItemNameBase function

String taskItemNameBase(
  1. TaskItem item
)

The requested id base for item (omp's sanitizeAgentId): its name scrubbed to A-Za-z0-9_- (≤48 chars), defaulting to the capitalized agent type name (omp's AdjectiveNoun name-generator is not ported).

Implementation

String taskItemNameBase(TaskItem item) {
  final sanitized = item.name?.trim().replaceAll(RegExp('[^A-Za-z0-9_-]+'), '');
  if (sanitized != null && sanitized.isNotEmpty) {
    return sanitized.length > 48 ? sanitized.substring(0, 48) : sanitized;
  }
  final agent = taskItemAgentName(item);
  return agent[0].toUpperCase() + agent.substring(1);
}