11use codex_protocol:: items:: HookPromptItem ;
2+ use codex_protocol:: items:: is_contextual_user_fragment as protocol_is_contextual_user_fragment;
23use codex_protocol:: items:: parse_hook_prompt_fragment;
34use codex_protocol:: models:: ContentItem ;
45
5- use super :: AdditionalContextUserFragment ;
6- use super :: EnvironmentContext ;
7- use super :: FragmentRegistration ;
8- use super :: FragmentRegistrationProxy ;
9- use super :: GoalContext ;
10- use super :: LegacyApplyPatchExecCommandWarning ;
11- use super :: LegacyModelMismatchWarning ;
12- use super :: LegacyUnifiedExecProcessLimitWarning ;
13- use super :: SkillInstructions ;
14- use super :: SubagentNotification ;
15- use super :: TurnAborted ;
16- use super :: UserInstructions ;
17- use super :: UserShellCommand ;
18-
19- static USER_INSTRUCTIONS_REGISTRATION : FragmentRegistrationProxy < UserInstructions > =
20- FragmentRegistrationProxy :: new ( ) ;
21- static ENVIRONMENT_CONTEXT_REGISTRATION : FragmentRegistrationProxy < EnvironmentContext > =
22- FragmentRegistrationProxy :: new ( ) ;
23- static ADDITIONAL_CONTEXT_REGISTRATION : FragmentRegistrationProxy < AdditionalContextUserFragment > =
24- FragmentRegistrationProxy :: new ( ) ;
25- static SKILL_INSTRUCTIONS_REGISTRATION : FragmentRegistrationProxy < SkillInstructions > =
26- FragmentRegistrationProxy :: new ( ) ;
27- static USER_SHELL_COMMAND_REGISTRATION : FragmentRegistrationProxy < UserShellCommand > =
28- FragmentRegistrationProxy :: new ( ) ;
29- static TURN_ABORTED_REGISTRATION : FragmentRegistrationProxy < TurnAborted > =
30- FragmentRegistrationProxy :: new ( ) ;
31- static SUBAGENT_NOTIFICATION_REGISTRATION : FragmentRegistrationProxy < SubagentNotification > =
32- FragmentRegistrationProxy :: new ( ) ;
33- static GOAL_CONTEXT_REGISTRATION : FragmentRegistrationProxy < GoalContext > =
34- FragmentRegistrationProxy :: new ( ) ;
35- static LEGACY_UNIFIED_EXEC_PROCESS_LIMIT_WARNING_REGISTRATION : FragmentRegistrationProxy <
36- LegacyUnifiedExecProcessLimitWarning ,
37- > = FragmentRegistrationProxy :: new ( ) ;
38- static LEGACY_APPLY_PATCH_EXEC_COMMAND_WARNING_REGISTRATION : FragmentRegistrationProxy <
39- LegacyApplyPatchExecCommandWarning ,
40- > = FragmentRegistrationProxy :: new ( ) ;
41- static LEGACY_MODEL_MISMATCH_WARNING_REGISTRATION : FragmentRegistrationProxy <
42- LegacyModelMismatchWarning ,
43- > = FragmentRegistrationProxy :: new ( ) ;
44-
45- static CONTEXTUAL_USER_FRAGMENTS : & [ & dyn FragmentRegistration ] = & [
46- & USER_INSTRUCTIONS_REGISTRATION ,
47- & ENVIRONMENT_CONTEXT_REGISTRATION ,
48- & ADDITIONAL_CONTEXT_REGISTRATION ,
49- & SKILL_INSTRUCTIONS_REGISTRATION ,
50- & USER_SHELL_COMMAND_REGISTRATION ,
51- & TURN_ABORTED_REGISTRATION ,
52- & SUBAGENT_NOTIFICATION_REGISTRATION ,
53- & GOAL_CONTEXT_REGISTRATION ,
54- & LEGACY_UNIFIED_EXEC_PROCESS_LIMIT_WARNING_REGISTRATION ,
55- & LEGACY_APPLY_PATCH_EXEC_COMMAND_WARNING_REGISTRATION ,
56- & LEGACY_MODEL_MISMATCH_WARNING_REGISTRATION ,
57- ] ;
58-
59- fn is_standard_contextual_user_text ( text : & str ) -> bool {
60- CONTEXTUAL_USER_FRAGMENTS
61- . iter ( )
62- . any ( |fragment| fragment. matches_text ( text) )
63- }
64-
656pub ( crate ) fn is_contextual_user_fragment ( content_item : & ContentItem ) -> bool {
66- let ContentItem :: InputText { text } = content_item else {
67- return false ;
68- } ;
69- parse_hook_prompt_fragment ( text) . is_some ( ) || is_standard_contextual_user_text ( text)
7+ protocol_is_contextual_user_fragment ( content_item)
708}
719
7210pub ( crate ) fn parse_visible_hook_prompt_message (
@@ -83,7 +21,7 @@ pub(crate) fn parse_visible_hook_prompt_message(
8321 fragments. push ( fragment) ;
8422 continue ;
8523 }
86- if is_standard_contextual_user_text ( text ) {
24+ if is_contextual_user_fragment ( content_item ) {
8725 continue ;
8826 }
8927 return None ;
0 commit comments