@@ -27,7 +27,7 @@ var hooks = new SessionHooks()
2727 .setOnPreToolUse((input, invocation) - > {
2828 System . out. println(" Tool: " + input. getToolName());
2929 return CompletableFuture . completedFuture(
30- new PreToolUseHookOutput () . setPermissionDecision( " allow" )
30+ new PreToolUseHookOutput (" allow" , null , null , null , null )
3131 );
3232 })
3333 .setOnPostToolUse((input, invocation) - > {
@@ -83,23 +83,20 @@ var hooks = new SessionHooks()
8383 // Block file deletion
8484 if (tool. equals(" delete_file" )) {
8585 return CompletableFuture . completedFuture(
86- new PreToolUseHookOutput ()
87- .setPermissionDecision(" deny" )
88- .setPermissionDecisionReason(" File deletion is not allowed" )
86+ new PreToolUseHookOutput (" deny" , " File deletion is not allowed" , null , null , null )
8987 );
9088 }
9189
9290 // Require confirmation for shell commands
9391 if (tool. equals(" run_terminal_cmd" )) {
9492 return CompletableFuture . completedFuture(
95- new PreToolUseHookOutput ()
96- .setPermissionDecision(" ask" )
93+ new PreToolUseHookOutput (" ask" , null , null , null , null )
9794 );
9895 }
9996
10097 // Allow everything else
10198 return CompletableFuture . completedFuture(
102- new PreToolUseHookOutput () . setPermissionDecision( " allow" )
99+ new PreToolUseHookOutput (" allow" , null , null , null , null )
103100 );
104101 });
105102```
@@ -119,13 +116,11 @@ var hooks = new SessionHooks()
119116 modifiedArgs. set(" query" , input. getToolArgs(). get(" query" ));
120117
121118 return CompletableFuture . completedFuture(
122- new PreToolUseHookOutput ()
123- .setPermissionDecision(" allow" )
124- .setModifiedArgs(modifiedArgs)
119+ new PreToolUseHookOutput (" allow" , null , modifiedArgs, null , null )
125120 );
126121 }
127122 return CompletableFuture . completedFuture(
128- new PreToolUseHookOutput () . setPermissionDecision( " allow" )
123+ new PreToolUseHookOutput (" allow" , null , null , null , null )
129124 );
130125 });
131126```
@@ -315,14 +310,12 @@ public class HooksExample {
315310 // Deny dangerous operations
316311 if (input. getToolName(). contains(" delete" )) {
317312 return CompletableFuture . completedFuture(
318- new PreToolUseHookOutput ()
319- .setPermissionDecision(" deny" )
320- .setPermissionDecisionReason(" Deletion not allowed" )
313+ new PreToolUseHookOutput (" deny" , " Deletion not allowed" , null , null , null )
321314 );
322315 }
323316
324317 return CompletableFuture . completedFuture(
325- new PreToolUseHookOutput () . setPermissionDecision( " allow" )
318+ new PreToolUseHookOutput (" allow" , null , null , null , null )
326319 );
327320 })
328321
@@ -391,15 +384,13 @@ To handle errors gracefully in your hooks:
391384 try {
392385 // Your logic here
393386 return CompletableFuture . completedFuture(
394- new PreToolUseHookOutput () . setPermissionDecision( " allow" )
387+ new PreToolUseHookOutput (" allow" , null , null , null , null )
395388 );
396389 } catch (Exception e) {
397390 logger. error(" Hook error" , e);
398391 // Fail-safe: deny if something goes wrong
399392 return CompletableFuture . completedFuture(
400- new PreToolUseHookOutput ()
401- .setPermissionDecision(" deny" )
402- .setPermissionDecisionReason(" Internal error" )
393+ new PreToolUseHookOutput (" deny" , " Internal error" , null , null , null )
403394 );
404395 }
405396})
0 commit comments