@@ -281,14 +281,13 @@ private void handleToolCall(JsonRpcClient rpc, String requestId, JsonNode params
281281
282282 ToolDefinition tool = session .getTool (toolName );
283283 if (tool == null || tool .getHandler () == null ) {
284- ToolResultObject result = new ToolResultObject ()
285- .setTextResultForLlm ("Tool '" + toolName + "' is not supported." ).setResultType ("failure" )
286- .setError ("tool '" + toolName + "' not supported" );
284+ var result = new ToolResultObject ().setTextResultForLlm ("Tool '" + toolName + "' is not supported." )
285+ .setResultType ("failure" ).setError ("tool '" + toolName + "' not supported" );
287286 rpc .sendResponse (Long .parseLong (requestId ), Map .of ("result" , result ));
288287 return ;
289288 }
290289
291- ToolInvocation invocation = new ToolInvocation ().setSessionId (sessionId ).setToolCallId (toolCallId )
290+ var invocation = new ToolInvocation ().setSessionId (sessionId ).setToolCallId (toolCallId )
292291 .setToolName (toolName ).setArguments (arguments );
293292
294293 tool .getHandler ().invoke (invocation ).thenAccept (result -> {
@@ -306,7 +305,7 @@ private void handleToolCall(JsonRpcClient rpc, String requestId, JsonNode params
306305 }
307306 }).exceptionally (ex -> {
308307 try {
309- ToolResultObject result = new ToolResultObject ()
308+ var result = new ToolResultObject ()
310309 .setTextResultForLlm (
311310 "Invoking this tool produced an error. Detailed information is not available." )
312311 .setResultType ("failure" ).setError (ex .getMessage ());
@@ -335,7 +334,7 @@ private void handlePermissionRequest(JsonRpcClient rpc, String requestId, JsonNo
335334
336335 CopilotSession session = sessions .get (sessionId );
337336 if (session == null ) {
338- PermissionRequestResult result = new PermissionRequestResult ()
337+ var result = new PermissionRequestResult ()
339338 .setKind ("denied-no-approval-rule-and-could-not-request-from-user" );
340339 rpc .sendResponse (Long .parseLong (requestId ), Map .of ("result" , result ));
341340 return ;
@@ -349,7 +348,7 @@ private void handlePermissionRequest(JsonRpcClient rpc, String requestId, JsonNo
349348 }
350349 }).exceptionally (ex -> {
351350 try {
352- PermissionRequestResult result = new PermissionRequestResult ()
351+ var result = new PermissionRequestResult ()
353352 .setKind ("denied-no-approval-rule-and-could-not-request-from-user" );
354353 rpc .sendResponse (Long .parseLong (requestId ), Map .of ("result" , result ));
355354 } catch (IOException e ) {
@@ -381,10 +380,9 @@ private void handleUserInputRequest(JsonRpcClient rpc, String requestId, JsonNod
381380 return ;
382381 }
383382
384- com .github .copilot .sdk .json .UserInputRequest request = new com .github .copilot .sdk .json .UserInputRequest ()
385- .setQuestion (question );
383+ var request = new com .github .copilot .sdk .json .UserInputRequest ().setQuestion (question );
386384 if (choicesNode != null && choicesNode .isArray ()) {
387- List < String > choices = new ArrayList <>();
385+ var choices = new ArrayList <String >();
388386 for (JsonNode choice : choicesNode ) {
389387 choices .add (choice .asText ());
390388 }
@@ -461,7 +459,7 @@ private void handleHooksInvoke(JsonRpcClient rpc, String requestId, JsonNode par
461459
462460 private void verifyProtocolVersion (Connection connection ) throws Exception {
463461 int expectedVersion = SdkProtocolVersion .get ();
464- Map < String , Object > params = new HashMap <>();
462+ var params = new HashMap <String , Object >();
465463 params .put ("message" , null );
466464 PingResponse pingResponse = connection .rpc .invoke ("ping" , params , PingResponse .class ).get (30 , TimeUnit .SECONDS );
467465
@@ -484,7 +482,7 @@ private void verifyProtocolVersion(Connection connection) throws Exception {
484482 * @return A future that completes when the client is stopped
485483 */
486484 public CompletableFuture <Void > stop () {
487- List < CompletableFuture < Void >> closeFutures = new ArrayList <>();
485+ var closeFutures = new ArrayList <CompletableFuture < Void > >();
488486
489487 for (CopilotSession session : new ArrayList <>(sessions .values ())) {
490488 closeFutures .add (CompletableFuture .runAsync (() -> {
@@ -555,7 +553,7 @@ private CompletableFuture<Void> cleanupConnection() {
555553 */
556554 public CompletableFuture <CopilotSession > createSession (SessionConfig config ) {
557555 return ensureConnected ().thenCompose (connection -> {
558- CreateSessionRequest request = new CreateSessionRequest ();
556+ var request = new CreateSessionRequest ();
559557 if (config != null ) {
560558 request .setModel (config .getModel ());
561559 request .setSessionId (config .getSessionId ());
@@ -585,8 +583,7 @@ public CompletableFuture<CopilotSession> createSession(SessionConfig config) {
585583 }
586584
587585 return connection .rpc .invoke ("session.create" , request , CreateSessionResponse .class ).thenApply (response -> {
588- CopilotSession session = new CopilotSession (response .getSessionId (), connection .rpc ,
589- response .getWorkspacePath ());
586+ var session = new CopilotSession (response .getSessionId (), connection .rpc , response .getWorkspacePath ());
590587 if (config != null && config .getTools () != null ) {
591588 session .registerTools (config .getTools ());
592589 }
@@ -632,7 +629,7 @@ public CompletableFuture<CopilotSession> createSession() {
632629 */
633630 public CompletableFuture <CopilotSession > resumeSession (String sessionId , ResumeSessionConfig config ) {
634631 return ensureConnected ().thenCompose (connection -> {
635- ResumeSessionRequest request = new ResumeSessionRequest ();
632+ var request = new ResumeSessionRequest ();
636633 request .setSessionId (sessionId );
637634 if (config != null ) {
638635 request .setReasoningEffort (config .getReasoningEffort ());
@@ -655,8 +652,7 @@ public CompletableFuture<CopilotSession> resumeSession(String sessionId, ResumeS
655652 }
656653
657654 return connection .rpc .invoke ("session.resume" , request , ResumeSessionResponse .class ).thenApply (response -> {
658- CopilotSession session = new CopilotSession (response .getSessionId (), connection .rpc ,
659- response .getWorkspacePath ());
655+ var session = new CopilotSession (response .getSessionId (), connection .rpc , response .getWorkspacePath ());
660656 if (config != null && config .getTools () != null ) {
661657 session .registerTools (config .getTools ());
662658 }
@@ -960,7 +956,7 @@ private CompletableFuture<Connection> ensureConnected() {
960956
961957 private ProcessInfo startCliServer () throws IOException , InterruptedException {
962958 String cliPath = options .getCliPath () != null ? options .getCliPath () : "copilot" ;
963- List < String > args = new ArrayList <>();
959+ var args = new ArrayList <String >();
964960
965961 if (options .getCliArgs () != null ) {
966962 args .addAll (Arrays .asList (options .getCliArgs ()));
@@ -993,7 +989,7 @@ private ProcessInfo startCliServer() throws IOException, InterruptedException {
993989
994990 List <String > command = resolveCliCommand (cliPath , args );
995991
996- ProcessBuilder pb = new ProcessBuilder (command );
992+ var pb = new ProcessBuilder (command );
997993 pb .redirectErrorStream (false );
998994
999995 if (options .getCwd () != null ) {
@@ -1014,7 +1010,7 @@ private ProcessInfo startCliServer() throws IOException, InterruptedException {
10141010 Process process = pb .start ();
10151011
10161012 // Forward stderr to logger in background
1017- Thread stderrThread = new Thread (() -> {
1013+ var stderrThread = new Thread (() -> {
10181014 try (BufferedReader reader = new BufferedReader (
10191015 new InputStreamReader (process .getErrorStream (), StandardCharsets .UTF_8 ))) {
10201016 String line ;
@@ -1063,7 +1059,7 @@ private List<String> resolveCliCommand(String cliPath, List<String> args) {
10631059 boolean isJsFile = cliPath .toLowerCase ().endsWith (".js" );
10641060
10651061 if (isJsFile ) {
1066- List < String > result = new ArrayList <>();
1062+ var result = new ArrayList <String >();
10671063 result .add ("node" );
10681064 result .add (cliPath );
10691065 result .addAll (args );
@@ -1073,15 +1069,15 @@ private List<String> resolveCliCommand(String cliPath, List<String> args) {
10731069 // On Windows, use cmd /c to resolve the executable
10741070 String os = System .getProperty ("os.name" ).toLowerCase ();
10751071 if (os .contains ("win" ) && !new File (cliPath ).isAbsolute ()) {
1076- List < String > result = new ArrayList <>();
1072+ var result = new ArrayList <String >();
10771073 result .add ("cmd" );
10781074 result .add ("/c" );
10791075 result .add (cliPath );
10801076 result .addAll (args );
10811077 return result ;
10821078 }
10831079
1084- List < String > result = new ArrayList <>();
1080+ var result = new ArrayList <String >();
10851081 result .add (cliPath );
10861082 result .addAll (args );
10871083 return result ;
0 commit comments