@@ -27,7 +27,7 @@ pub async fn run(workspace: WorkspacePaths) -> Result<(), String> {
2727 event_sink. clone ( ) as Arc < dyn altai_agent_service:: AgentEventSink > ,
2828 run_coordinator. clone ( ) ,
2929 ) ) ;
30- let service = Arc :: new ( AgentService :: with_coordinator ( host, run_coordinator. clone ( ) ) ) ;
30+ let service = Arc :: new ( AgentService :: with_coordinator ( host. clone ( ) , run_coordinator. clone ( ) ) ) ;
3131
3232 let mut stdin = tokio:: io:: stdin ( ) ;
3333 let mut decoder = FrameDecoder :: new ( FrameLimits :: default ( ) ) ;
@@ -96,6 +96,7 @@ pub async fn run(workspace: WorkspacePaths) -> Result<(), String> {
9696 "run/cancel" ,
9797 "run/steer" ,
9898 "run/replay" ,
99+ "clarification/respond" ,
99100 "context/compact" ,
100101 "checkpoints/list" ,
101102 "checkpoints/restore" ,
@@ -434,6 +435,21 @@ pub async fn run(workspace: WorkspacePaths) -> Result<(), String> {
434435 "run/replay" if initialized => {
435436 handle_run_replay ( & workspace, & writer, id, params) . await ?;
436437 }
438+ "clarification/respond" if initialized => {
439+ let params = params
440+ . and_then ( |value| value. as_object ( ) . cloned ( ) )
441+ . unwrap_or_default ( ) ;
442+ let chat_id = params. get ( "chat_id" ) . and_then ( Value :: as_str) . unwrap_or ( "" ) ;
443+ let text = params. get ( "text" ) . and_then ( Value :: as_str) . unwrap_or ( "" ) ;
444+ if chat_id. trim ( ) . is_empty ( ) || chat_id. len ( ) > 256 || text. trim ( ) . is_empty ( ) || text. len ( ) > 16_384 {
445+ respond ( & writer, id, None , Some ( error_value ( -32602 , "invalid_clarification_response" ) ) ) . await ?;
446+ continue ;
447+ }
448+ match host. deliver_clarification_reply ( chat_id, text. to_string ( ) ) . await {
449+ Ok ( ( ) ) => respond ( & writer, id, Some ( json ! ( { "accepted" : true } ) ) , None ) . await ?,
450+ Err ( error) => respond ( & writer, id, None , Some ( error_value ( -32002 , & error) ) ) . await ?,
451+ }
452+ }
437453 "context/compact" if initialized => {
438454 let params = params
439455 . and_then ( |value| value. as_object ( ) . cloned ( ) )
0 commit comments