this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

more

+33 -8
+33 -8
claudeio/test/permission_demo.ml
··· 28 28 29 29 (* Interactive permission callback *) 30 30 let interactive_permission_callback ~tool_name ~input ~context:_ = 31 + Log.info (fun m -> m "๐Ÿ”” Permission callback invoked for tool: %s" tool_name); 31 32 Log.app (fun m -> m "\n๐Ÿ” PERMISSION REQUEST ๐Ÿ”"); 32 33 Log.app (fun m -> m "Tool: %s" tool_name); 34 + 35 + (* Log the full input for debugging *) 36 + Log.info (fun m -> m "Full input JSON: %s" (Ezjsonm.value_to_string input)); 33 37 34 38 (* Show input details *) 35 39 (* Try to extract key information from the input *) ··· 44 48 | "Write" | "Edit" -> 45 49 let file_path = Ezjsonm.find input ["file_path"] |> Ezjsonm.get_string in 46 50 Log.app (fun m -> m "File: %s" file_path) 51 + | "Glob" -> 52 + let pattern = Ezjsonm.find input ["pattern"] |> Ezjsonm.get_string in 53 + Log.app (fun m -> m "Pattern: %s" pattern); 54 + (try 55 + let path = Ezjsonm.find input ["path"] |> Ezjsonm.get_string in 56 + Log.app (fun m -> m "Path: %s" path) 57 + with _ -> Log.app (fun m -> m "Path: (current directory)")) 58 + | "Grep" -> 59 + let pattern = Ezjsonm.find input ["pattern"] |> Ezjsonm.get_string in 60 + Log.app (fun m -> m "Pattern: %s" pattern); 61 + (try 62 + let path = Ezjsonm.find input ["path"] |> Ezjsonm.get_string in 63 + Log.app (fun m -> m "Path: %s" path) 64 + with _ -> Log.app (fun m -> m "Path: (current directory)")) 47 65 | _ -> 48 66 Log.app (fun m -> m "Input: %s" (Ezjsonm.value_to_string input)) 49 - with _ -> ()); 67 + with exn -> 68 + Log.info (fun m -> m "Failed to parse input details: %s" (Printexc.to_string exn))); 50 69 51 70 (* Check if already granted *) 52 71 if Granted.is_granted tool_name then begin 53 72 Log.app (fun m -> m "โ†’ Auto-approved (previously granted)"); 73 + Log.info (fun m -> m "Returning allow result for %s" tool_name); 54 74 Claude.Permissions.Result.allow () 55 75 end else begin 56 76 (* Ask user *) ··· 58 78 match read_line () |> String.lowercase_ascii with 59 79 | "y" | "yes" -> 60 80 Log.app (fun m -> m "โ†’ Allowed (this time only)"); 81 + Log.info (fun m -> m "User approved %s for this request only" tool_name); 61 82 Claude.Permissions.Result.allow () 62 83 | "a" | "always" -> 63 84 Granted.grant tool_name; 85 + Log.info (fun m -> m "User granted permanent permission for %s" tool_name); 64 86 Claude.Permissions.Result.allow () 65 87 | _ -> 66 88 Granted.deny tool_name; 89 + Log.info (fun m -> m "User denied permission for %s" tool_name); 67 90 Claude.Permissions.Result.deny ~message:(Printf.sprintf "User denied access to %s" tool_name) ~interrupt:false 68 91 end 69 92 ··· 102 125 Log.app (fun m -> m "Claude will request permissions as needed.\n"); 103 126 104 127 (* Create options with custom permission callback *) 105 - (* Don't use disallowed_tools - rely on permission callback for all access control *) 128 + (* DON'T specify allowed_tools - let the permission callback handle everything. 129 + The Default permission mode with a callback should send requests for all tools. *) 106 130 let options = Claude.Options.create 107 131 ~model:"sonnet" 132 + ~permission_mode:Claude.Permissions.Mode.Default 108 133 ~permission_callback:interactive_permission_callback 109 134 () in 110 135 ··· 112 137 ~process_mgr:env#process_mgr 113 138 () in 114 139 115 - (* First prompt - Claude will need to request Read permission *) 116 - Log.app (fun m -> m "\n๐Ÿ“ค Sending first prompt..."); 140 + (* First prompt - Claude will need to request Read permission for ../lib *) 141 + Log.app (fun m -> m "\n๐Ÿ“ค Sending first prompt (reading from ../lib)..."); 117 142 Claude.Client.query client 118 - "Please read the file 'permission_demo.ml' in the current directory and tell me what it does."; 143 + "Please read and analyze the source files in the ../lib directory. Focus on the main OCaml modules and their purpose. What is the overall architecture of this Claude library?"; 119 144 process_response client; 120 145 121 146 (* Show current permissions *) 122 147 Log.app (fun m -> m "\n๐Ÿ“‹ Current permission status:"); 123 148 Granted.list (); 124 149 125 - (* Second prompt - might need different permissions *) 126 - Log.app (fun m -> m "\n๐Ÿ“ค Sending second prompt..."); 150 + (* Second prompt - will need Write permission *) 151 + Log.app (fun m -> m "\n๐Ÿ“ค Sending second prompt (writing TEST.md)..."); 127 152 Claude.Client.query client 128 - "Now check if there's a README.md file in the test directory and tell me what tests exist."; 153 + "Now write a summary of what you learned about the Claude library architecture to a file called TEST.md in the current directory. Include the main modules, their purposes, and how they work together."; 129 154 process_response client; 130 155 131 156 (* Show final permissions *)