@@ -145,9 +145,9 @@ public void onOpen(WebSocket socket) {
145145 * {@link #sentMessages} when no socket is attached.</p>
146146 */
147147 void begin () {
148- CompletableFuture <JsonNode > initRpc = newRpc ("initialize" , buildInitializeParams ());
148+ CompletableFuture <JsonNode > initRpc = newRpc (CodexAppServerProtocol . INITIALIZE , buildInitializeParams ());
149149 initRpc .thenAccept (result -> {
150- sendNotification ("notifications/initialized" );
150+ sendNotification (CodexAppServerProtocol . INITIALIZED );
151151 startOrResumeThread ();
152152 }).exceptionally (error -> {
153153 completeError (unwrap (error ));
@@ -159,15 +159,15 @@ private void startOrResumeThread() {
159159 String sessionKey = request .normalizedSessionKey ();
160160 String previousThreadId = Objects .isNull (sessionKey ) ? null : threadBySession .get (sessionKey );
161161 boolean resume = hasText (previousThreadId );
162- CompletableFuture <JsonNode > rpc = newRpc (resume ? "thread/resume" : "thread/start" ,
162+ CompletableFuture <JsonNode > rpc = newRpc (resume ? CodexAppServerProtocol . THREAD_RESUME : CodexAppServerProtocol . THREAD_START ,
163163 buildThreadStartParams (resume ? previousThreadId : null ));
164164 rpc .thenAccept (result -> {
165165 threadId = extractThreadId (result );
166166 if (!hasText (threadId )) {
167167 completeError (new CodexAppServerException ("Codex thread/start returned no threadId" ));
168168 return ;
169169 }
170- newRpc ("turn/start" , buildTurnStartParams (threadId ));
170+ newRpc (CodexAppServerProtocol . TURN_START , buildTurnStartParams (threadId ));
171171 }).exceptionally (error -> {
172172 completeError (unwrap (error ));
173173 return null ;
@@ -235,12 +235,12 @@ void handleFrame(String frame) {
235235 String method = node .path ("method" ).asText ("" );
236236 JsonNode params = node .path ("params" );
237237 switch (method ) {
238- case "turn/started" -> onTurnStarted (params );
239- case "item/completed" -> onItemCompleted (params );
240- case "turn/completed" -> onTurnCompleted (params );
241- case "turn/failed" -> completeError (new CodexAppServerException (
238+ case CodexAppServerProtocol . TURN_STARTED -> onTurnStarted (params );
239+ case CodexAppServerProtocol . ITEM_COMPLETED -> onItemCompleted (params );
240+ case CodexAppServerProtocol . TURN_COMPLETED -> onTurnCompleted (params );
241+ case CodexAppServerProtocol . TURN_FAILED -> completeError (new CodexAppServerException (
242242 "Codex turn failed: " + params .path ("message" ).asText ("unknown" )));
243- case "error" -> completeError (new CodexAppServerException (
243+ case CodexAppServerProtocol . ERROR -> completeError (new CodexAppServerException (
244244 "Codex server error: " + params .toString ()));
245245 default -> log .debug ("Ignored Codex notification: method={}" , method );
246246 }
0 commit comments