@@ -46,16 +46,17 @@ type sessionHandler struct {
4646// })
4747type Session struct {
4848 // SessionID is the unique identifier for this session.
49- SessionID string
50- workspacePath string
51- client * JSONRPCClient
52- handlers []sessionHandler
53- nextHandlerID uint64
54- handlerMutex sync.RWMutex
55- toolHandlers map [string ]ToolHandler
56- toolHandlersM sync.RWMutex
57- permissionHandler PermissionHandler
58- permissionMux sync.RWMutex
49+ SessionID string
50+ workspacePath string
51+ client * JSONRPCClient
52+ handlers []sessionHandler
53+ nextHandlerID uint64
54+ handlerMutex sync.RWMutex
55+ toolHandlers map [string ]ToolHandler
56+ toolRequiresApproval map [string ]bool
57+ toolHandlersM sync.RWMutex
58+ permissionHandler PermissionHandler
59+ permissionMux sync.RWMutex
5960}
6061
6162// WorkspacePath returns the path to the session workspace directory when infinite
@@ -71,11 +72,12 @@ func (s *Session) WorkspacePath() string {
7172// to create sessions with proper initialization.
7273func NewSession (sessionID string , client * JSONRPCClient , workspacePath string ) * Session {
7374 return & Session {
74- SessionID : sessionID ,
75- workspacePath : workspacePath ,
76- client : client ,
77- handlers : make ([]sessionHandler , 0 ),
78- toolHandlers : make (map [string ]ToolHandler ),
75+ SessionID : sessionID ,
76+ workspacePath : workspacePath ,
77+ client : client ,
78+ handlers : make ([]sessionHandler , 0 ),
79+ toolHandlers : make (map [string ]ToolHandler ),
80+ toolRequiresApproval : make (map [string ]bool ),
7981 }
8082}
8183
@@ -262,11 +264,13 @@ func (s *Session) registerTools(tools []Tool) {
262264 defer s .toolHandlersM .Unlock ()
263265
264266 s .toolHandlers = make (map [string ]ToolHandler )
267+ s .toolRequiresApproval = make (map [string ]bool )
265268 for _ , tool := range tools {
266269 if tool .Name == "" || tool .Handler == nil {
267270 continue
268271 }
269272 s .toolHandlers [tool .Name ] = tool .Handler
273+ s .toolRequiresApproval [tool .Name ] = tool .RequiresApproval
270274 }
271275}
272276
@@ -279,6 +283,15 @@ func (s *Session) getToolHandler(name string) (ToolHandler, bool) {
279283 return handler , ok
280284}
281285
286+ // toolRequiresApprovalCheck checks if a tool requires approval before execution.
287+ // Returns true if the tool requires approval, false otherwise.
288+ func (s * Session ) toolRequiresApprovalCheck (name string ) bool {
289+ s .toolHandlersM .RLock ()
290+ defer s .toolHandlersM .RUnlock ()
291+ requiresApproval , ok := s .toolRequiresApproval [name ]
292+ return ok && requiresApproval
293+ }
294+
282295// registerPermissionHandler registers a permission handler for this session.
283296//
284297// When the assistant needs permission to perform certain actions (e.g., file
0 commit comments