metadataUtils.js 954 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getDisplayName = getDisplayName;
  4. /**
  5. * Utilities for working with BaseMetadata objects.
  6. */
  7. /**
  8. * Gets the display name for an object with BaseMetadata.
  9. * For tools, the precedence is: title → annotations.title → name
  10. * For other objects: title → name
  11. * This implements the spec requirement: "if no title is provided, name should be used for display purposes"
  12. */
  13. function getDisplayName(metadata) {
  14. // First check for title (not undefined and not empty string)
  15. if (metadata.title !== undefined && metadata.title !== '') {
  16. return metadata.title;
  17. }
  18. // Then check for annotations.title (only present in Tool objects)
  19. if ('annotations' in metadata && metadata.annotations?.title) {
  20. return metadata.annotations.title;
  21. }
  22. // Finally fall back to name
  23. return metadata.name;
  24. }
  25. //# sourceMappingURL=metadataUtils.js.map