isSyntheticUserText function

bool isSyntheticUserText(
  1. String text
)

Whether a user-role text is synthetic harness content (system-notice envelope, widget/extension/TTSR injection, agent mail, or a projected branch summary) rather than the user's own words.

Canonical semantics (superset of the historical copies): the text is trimmed first, <system-notice> matches anywhere, and the widget/extension/system-interrupt prefixes and the whitespace-tolerant agent-mail anchor apply on the trimmed text. Empty text is NOT synthetic (callers skip it separately).

Implementation

bool isSyntheticUserText(String text) {
  final trimmed = text.trim();
  return _systemNoticePattern.hasMatch(trimmed) ||
      _syntheticPrefixPattern.hasMatch(trimmed) ||
      _agentMailPattern.hasMatch(trimmed) ||
      _branchSummaryPattern.hasMatch(trimmed);
}