Reject unsupported Reddit chat capabilities
This commit is contained in:
1 parent
8d932fcf36
commit
712226cd43
8 files changed
+100
-8
No files matched your search
@@ -1,5 +1,8 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
import { isSafeOutboundMessage } from './outbound-message-safety.js';
|
||||
import {
|
||||
isSafeOutboundMessage,
|
||||
isSafeRedditChatMessage,
|
||||
} from './outbound-message-safety.js';
|
||||
import { containsMediaRequest, detectConversationBoundaries } from './conversation-boundaries.js';
|
||||
|
||||
export interface ConversationMessage {
|
||||
@@ -209,6 +212,7 @@ export type ConversationReplySafetyFailure =
|
||||
| 'reply exceeds 600 characters'
|
||||
| 'reply contains instruction or prompt leakage'
|
||||
| 'reply implies shared location or an in-person meeting'
|
||||
| 'reply suggests an unsupported Reddit chat capability'
|
||||
| 'reply exceeds the three-sentence limit'
|
||||
| 'reply solicits media outside the configured media-ask phase'
|
||||
| 'media ask does not contain a recognizable image or video request'
|
||||
@@ -224,6 +228,7 @@ export function conversationReplySafetyFailure(message: string): ConversationRep
|
||||
return 'reply contains instruction or prompt leakage';
|
||||
}
|
||||
if (!isSafeOutboundMessage(trimmed)) return 'reply implies shared location or an in-person meeting';
|
||||
if (!isSafeRedditChatMessage(trimmed)) return 'reply suggests an unsupported Reddit chat capability';
|
||||
const sentences = trimmed.match(/[^.!?]+[.!?]+/g) ?? [];
|
||||
if (sentences.length > 3) return 'reply exceeds the three-sentence limit';
|
||||
return null;
|
||||
|
||||
@@ -18,6 +18,13 @@ const IN_PERSON_INVITATION_PATTERNS: readonly RegExp[] = [
|
||||
/\b(?:come over|come round|visit me|see you in person)\b/i,
|
||||
];
|
||||
|
||||
const UNSUPPORTED_REDDIT_CHAT_CAPABILITY_PATTERNS: readonly RegExp[] = [
|
||||
/\b(?:voice|audio)\s*(?:note|message|memo|clip|recording)s?\b/i,
|
||||
/\b(?:phone|voice|audio|video)\s*call(?:s|ing)?\b/i,
|
||||
/\b(?:face\s*time|facetime|video\s*chat(?:s|ting)?)\b/i,
|
||||
/\b(?:hop|jump|get|go)\s+(?:on|into)\s+(?:a\s+)?call\b/i,
|
||||
];
|
||||
|
||||
/**
|
||||
* Prevent generated messages from implying physical proximity or inviting an
|
||||
* in-person meeting. Stating the configured persona location by itself remains
|
||||
@@ -28,3 +35,13 @@ export function isSafeOutboundMessage(message: string): boolean {
|
||||
return !SHARED_LOCATION_PATTERNS.some((pattern) => pattern.test(message))
|
||||
&& !IN_PERSON_INVITATION_PATTERNS.some((pattern) => pattern.test(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep private Reddit chat text within capabilities this application can
|
||||
* actually deliver. Approved saved-picture sharing is handled separately;
|
||||
* generated text must not suggest unsupported audio or live-call features.
|
||||
*/
|
||||
export function isSafeRedditChatMessage(message: string): boolean {
|
||||
return isSafeOutboundMessage(message)
|
||||
&& !UNSUPPORTED_REDDIT_CHAT_CAPABILITY_PATTERNS.some((pattern) => pattern.test(message));
|
||||
}
|
||||
Reference in new issue
Block a user