(ctx context.Context, toolCallId string)
| 96 | } |
| 97 | |
| 98 | func WaitForToolApproval(ctx context.Context, toolCallId string) (string, error) { |
| 99 | req, exists := getToolApprovalRequest(toolCallId) |
| 100 | if !exists { |
| 101 | return "", nil |
| 102 | } |
| 103 | |
| 104 | select { |
| 105 | case <-ctx.Done(): |
| 106 | return "", ctx.Err() |
| 107 | case <-req.doneChan: |
| 108 | } |
| 109 | |
| 110 | req.mu.Lock() |
| 111 | approval := req.approval |
| 112 | req.mu.Unlock() |
| 113 | |
| 114 | globalApprovalRegistry.mu.Lock() |
| 115 | delete(globalApprovalRegistry.requests, toolCallId) |
| 116 | globalApprovalRegistry.mu.Unlock() |
| 117 | |
| 118 | return approval, nil |
| 119 | } |
no test coverage detected