hippox-drivers 0.3.5

🦛All indivisible atomic driver units in Hippox.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
//! GitHub API driver module
//!
//! This module provides drivers for GitHub API operations including
//! repository information, issue management, searching, and user information.
use crate::DriverCallback;
use crate::DriverContext;
use crate::RequestConfig;
use crate::execute;
use crate::types::{Driver, DriverParameter};
use crate::{DriverCategory, DriverError, DriverResult};
use serde_json::{Value, json};
use std::collections::HashMap;
use tracing::{debug, info};
// ========== Helper functions ==========
/// Retrieves a string parameter from the parameters map
///
/// # Arguments
/// * `params` - Parameters map
/// * `name` - Parameter name
///
/// # Returns
/// * `DriverResult<String>` - Parameter value on success
fn get_param_string(params: &HashMap<String, Value>, name: &str) -> DriverResult<String> {
    return params.get(name).and_then(|v| v.as_str()).map(|s| s.to_string()).ok_or_else(|| DriverError::missing_parameter(name));
}
/// Retrieves a u64 parameter from the parameters map with a default value
///
/// # Arguments
/// * `params` - Parameters map
/// * `name` - Parameter name
/// * `default` - Default value if parameter is not present
///
/// # Returns
/// * `u64` - Parameter value or default
fn get_param_u64(params: &HashMap<String, Value>, name: &str, default: u64) -> u64 {
    return params.get(name).and_then(|v| v.as_u64()).unwrap_or(default);
}
/// Retrieves an array parameter from the parameters map
///
/// # Arguments
/// * `params` - Parameters map
/// * `name` - Parameter name
///
/// # Returns
/// * `Vec<Value>` - Array value or empty vector
fn get_param_array(params: &HashMap<String, Value>, name: &str) -> Vec<Value> {
    return params.get(name).and_then(|v| v.as_array()).cloned().unwrap_or_default();
}
/// Retrieves a boolean parameter from the parameters map with a default value
///
/// # Arguments
/// * `params` - Parameters map
/// * `name` - Parameter name
/// * `default` - Default value if parameter is not present
///
/// # Returns
/// * `bool` - Parameter value or default
fn get_param_bool(params: &HashMap<String, Value>, name: &str, default: bool) -> bool {
    return params.get(name).and_then(|v| v.as_bool()).unwrap_or(default);
}
// ========== GitHub API Helper ==========
/// GitHub API client wrapper
struct GitHubApi;
impl GitHubApi {
    /// Builds the full URL for a GitHub API endpoint
    ///
    /// # Arguments
    /// * `api_url` - Base API URL
    /// * `endpoint` - API endpoint path
    ///
    /// # Returns
    /// * `String` - Full URL
    fn build_url(api_url: &str, endpoint: &str) -> String {
        return format!("{}/{}", api_url.trim_end_matches('/'), endpoint);
    }
    /// Builds HTTP headers for GitHub API requests
    ///
    /// # Arguments
    /// * `token` - GitHub personal access token
    ///
    /// # Returns
    /// * `HashMap<String, String>` - HTTP headers
    fn build_headers(token: &str) -> HashMap<String, String> {
        let mut headers = HashMap::new();
        headers.insert("Accept".to_string(), "application/vnd.github.v3+json".to_string());
        headers.insert("Authorization".to_string(), format!("Bearer {}", token));
        headers.insert("User-Agent".to_string(), "Hippox-Engine".to_string());
        return headers;
    }
    /// Performs a GET request to the GitHub API
    ///
    /// # Arguments
    /// * `endpoint` - API endpoint path
    /// * `token` - GitHub personal access token
    /// * `api_url` - Base API URL
    /// * `timeout` - Request timeout in seconds
    ///
    /// # Returns
    /// * `DriverResult<String>` - Response body on success
    async fn get(endpoint: &str, token: &str, api_url: &str, timeout: u64) -> DriverResult<String> {
        debug!("GitHub GET request to: {}", endpoint);
        let req_config = RequestConfig {
            url: Self::build_url(api_url, endpoint),
            method: "GET".to_string(),
            headers: Some(Self::build_headers(token)),
            body: None,
            timeout_secs: Some(timeout),
        };
        let response = execute(&req_config).await.map_err(|e| DriverError::execution(format!("GitHub API request failed: {}", e)))?;
        if response.is_success {
            info!("GitHub GET request successful: {}", endpoint);
            return Ok(response.body);
        } else {
            return Err(DriverError::execution(format!("GitHub API error: {}", response.body)));
        }
    }
    /// Performs a POST request to the GitHub API
    ///
    /// # Arguments
    /// * `endpoint` - API endpoint path
    /// * `body` - Request body
    /// * `token` - GitHub personal access token
    /// * `api_url` - Base API URL
    /// * `timeout` - Request timeout in seconds
    ///
    /// # Returns
    /// * `DriverResult<String>` - Response body on success
    async fn post(endpoint: &str, body: &str, token: &str, api_url: &str, timeout: u64) -> DriverResult<String> {
        debug!("GitHub POST request to: {}", endpoint);
        let req_config = RequestConfig {
            url: Self::build_url(api_url, endpoint),
            method: "POST".to_string(),
            headers: Some(Self::build_headers(token)),
            body: Some(body.to_string()),
            timeout_secs: Some(timeout),
        };
        let response = execute(&req_config).await.map_err(|e| DriverError::execution(format!("GitHub API request failed: {}", e)))?;
        if response.is_success {
            info!("GitHub POST request successful: {}", endpoint);
            return Ok(response.body);
        } else {
            return Err(DriverError::execution(format!("GitHub API error: {}", response.body)));
        }
    }
    /// Performs a PUT request to the GitHub API
    ///
    /// # Arguments
    /// * `endpoint` - API endpoint path
    /// * `body` - Request body (optional)
    /// * `token` - GitHub personal access token
    /// * `api_url` - Base API URL
    /// * `timeout` - Request timeout in seconds
    ///
    /// # Returns
    /// * `DriverResult<String>` - Response body on success
    async fn put(endpoint: &str, body: Option<&str>, token: &str, api_url: &str, timeout: u64) -> DriverResult<String> {
        debug!("GitHub PUT request to: {}", endpoint);
        let req_config = RequestConfig {
            url: Self::build_url(api_url, endpoint),
            method: "PUT".to_string(),
            headers: Some(Self::build_headers(token)),
            body: body.map(|s| s.to_string()),
            timeout_secs: Some(timeout),
        };
        let response = execute(&req_config).await.map_err(|e| DriverError::execution(format!("GitHub API request failed: {}", e)))?;
        if response.is_success {
            info!("GitHub PUT request successful: {}", endpoint);
            return Ok(response.body);
        } else {
            return Err(DriverError::execution(format!("GitHub API error: {}", response.body)));
        }
    }
    /// Performs a DELETE request to the GitHub API
    ///
    /// # Arguments
    /// * `endpoint` - API endpoint path
    /// * `token` - GitHub personal access token
    /// * `api_url` - Base API URL
    /// * `timeout` - Request timeout in seconds
    ///
    /// # Returns
    /// * `DriverResult<String>` - Response body on success
    async fn delete(endpoint: &str, token: &str, api_url: &str, timeout: u64) -> DriverResult<String> {
        debug!("GitHub DELETE request to: {}", endpoint);
        let req_config = RequestConfig {
            url: Self::build_url(api_url, endpoint),
            method: "DELETE".to_string(),
            headers: Some(Self::build_headers(token)),
            body: None,
            timeout_secs: Some(timeout),
        };
        let response = execute(&req_config).await.map_err(|e| DriverError::execution(format!("GitHub API request failed: {}", e)))?;
        if response.is_success {
            info!("GitHub DELETE request successful: {}", endpoint);
            return Ok(response.body);
        } else {
            return Err(DriverError::execution(format!("GitHub API error: {}", response.body)));
        }
    }
}
// ========== Get repository information ==========
/// Driver for getting GitHub repository information
#[derive(Debug)]
pub struct GithubGetRepo;
#[async_trait::async_trait]
impl Driver for GithubGetRepo {
    /// Returns the unique name of this driver
    fn name(&self) -> &str {
        return "github_get_repo";
    }
    /// Returns a brief description of the driver's functionality
    fn description(&self) -> &str {
        return "Get information about a GitHub repository";
    }
    /// Returns detailed usage guidance for LLMs
    fn usage_hint(&self) -> &str {
        return "Use this skill when the user needs to get repository details like stars, forks, description";
    }
    /// Returns the category of this driver
    fn category(&self) -> DriverCategory {
        return DriverCategory::Devops;
    }
    /// Returns the parameter definitions for this driver
    fn parameters(&self) -> Vec<DriverParameter> {
        return vec![
            DriverParameter {
                name: "token".to_string(),
                param_type: "string".to_string(),
                description: "GitHub personal access token".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("ghp_xxxxxxxx".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "owner".to_string(),
                param_type: "string".to_string(),
                description: "Repository owner (username or organization)".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust-lang".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "repo".to_string(),
                param_type: "string".to_string(),
                description: "Repository name".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "api_url".to_string(),
                param_type: "string".to_string(),
                description: "GitHub API URL (default: https://api.github.com)".to_string(),
                required: false,
                default: Some(Value::String("https://api.github.com".to_string())),
                example: Some(Value::String("https://api.github.com".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "timeout".to_string(),
                param_type: "integer".to_string(),
                description: "Request timeout in seconds".to_string(),
                required: false,
                default: Some(Value::Number(30.into())),
                example: Some(Value::Number(60.into())),
                enum_values: None,
            },
        ];
    }
    /// Returns an example call for this driver
    fn example_call(&self) -> DriverResult<Value> {
        return Ok(json!({
            "action": "github_get_repo",
            "parameters": {
                "token": "ghp_xxxxxxxx",
                "owner": "rust-lang",
                "repo": "rust"
            }
        }));
    }
    /// Returns an example output from this driver
    fn example_output(&self) -> String {
        return r#"{"name": "rust", "full_name": "rust-lang/rust", "description": "Empowering everyone...", "stargazers_count": 85000, "forks_count": 11000}"#.to_string();
    }
    /// Executes the driver with the given parameters
    async fn execute(
        &self,
        parameters: &HashMap<String, Value>,
        _callback: Option<&dyn DriverCallback>,
        _context: Option<&DriverContext>,
    ) -> DriverResult<String> {
        debug!("Executing github_get_repo driver");
        // Extract required parameters
        let token = get_param_string(parameters, "token")?;
        let owner = get_param_string(parameters, "owner")?;
        let repo = get_param_string(parameters, "repo")?;
        let api_url = parameters.get("api_url").and_then(|v| v.as_str()).unwrap_or("https://api.github.com");
        let timeout = get_param_u64(parameters, "timeout", 30);
        let endpoint = format!("repos/{}/{}", owner, repo);
        debug!("Fetching repository info: {}/{}", owner, repo);
        let result = GitHubApi::get(&endpoint, &token, api_url, timeout).await?;
        info!("Successfully fetched repository info: {}/{}", owner, repo);
        return Ok(result);
    }
}
// ========== Create an issue ==========
/// Driver for creating a GitHub issue
#[derive(Debug)]
pub struct GithubCreateIssue;
#[async_trait::async_trait]
impl Driver for GithubCreateIssue {
    /// Returns the unique name of this driver
    fn name(&self) -> &str {
        return "github_create_issue";
    }
    /// Returns a brief description of the driver's functionality
    fn description(&self) -> &str {
        return "Create an issue in a GitHub repository";
    }
    /// Returns detailed usage guidance for LLMs
    fn usage_hint(&self) -> &str {
        return "Use this skill when the user needs to report a bug or request a feature";
    }
    /// Returns the category of this driver
    fn category(&self) -> DriverCategory {
        return DriverCategory::Devops;
    }
    /// Returns the parameter definitions for this driver
    fn parameters(&self) -> Vec<DriverParameter> {
        return vec![
            DriverParameter {
                name: "token".to_string(),
                param_type: "string".to_string(),
                description: "GitHub personal access token".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("ghp_xxxxxxxx".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "owner".to_string(),
                param_type: "string".to_string(),
                description: "Repository owner".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust-lang".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "repo".to_string(),
                param_type: "string".to_string(),
                description: "Repository name".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "title".to_string(),
                param_type: "string".to_string(),
                description: "Issue title".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("Bug: compilation error".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "body".to_string(),
                param_type: "string".to_string(),
                description: "Issue body/description".to_string(),
                required: false,
                default: None,
                example: Some(Value::String("When compiling with nightly...".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "labels".to_string(),
                param_type: "array".to_string(),
                description: "Labels to apply".to_string(),
                required: false,
                default: Some(Value::Array(vec![])),
                example: Some(json!(["bug", "help-wanted"])),
                enum_values: None,
            },
            DriverParameter {
                name: "api_url".to_string(),
                param_type: "string".to_string(),
                description: "GitHub API URL".to_string(),
                required: false,
                default: Some(Value::String("https://api.github.com".to_string())),
                example: Some(Value::String("https://api.github.com".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "timeout".to_string(),
                param_type: "integer".to_string(),
                description: "Request timeout in seconds".to_string(),
                required: false,
                default: Some(Value::Number(30.into())),
                example: Some(Value::Number(60.into())),
                enum_values: None,
            },
        ];
    }
    /// Returns an example call for this driver
    fn example_call(&self) -> DriverResult<Value> {
        return Ok(json!({
            "action": "github_create_issue",
            "parameters": {
                "token": "ghp_xxxxxxxx",
                "owner": "rust-lang",
                "repo": "rust",
                "title": "Bug: compilation error",
                "body": "When compiling with nightly...",
                "labels": ["bug"]
            }
        }));
    }
    /// Returns an example output from this driver
    fn example_output(&self) -> String {
        return r#"{"number": 12345, "html_url": "https://github.com/rust-lang/rust/issues/12345"}"#.to_string();
    }
    /// Executes the driver with the given parameters
    async fn execute(
        &self,
        parameters: &HashMap<String, Value>,
        _callback: Option<&dyn DriverCallback>,
        _context: Option<&DriverContext>,
    ) -> DriverResult<String> {
        debug!("Executing github_create_issue driver");
        // Extract required parameters
        let token = get_param_string(parameters, "token")?;
        let owner = get_param_string(parameters, "owner")?;
        let repo = get_param_string(parameters, "repo")?;
        let title = get_param_string(parameters, "title")?;
        let body = parameters.get("body").and_then(|v| v.as_str());
        let labels = get_param_array(parameters, "labels");
        let api_url = parameters.get("api_url").and_then(|v| v.as_str()).unwrap_or("https://api.github.com");
        let timeout = get_param_u64(parameters, "timeout", 30);
        // Build request body
        let mut body_json = json!({ "title": title });
        if let Some(b) = body {
            body_json["body"] = json!(b);
        }
        if !labels.is_empty() {
            let label_strings: Vec<String> = labels.iter().filter_map(|l| l.as_str()).map(|s| s.to_string()).collect();
            body_json["labels"] = json!(label_strings);
        }
        let endpoint = format!("repos/{}/{}/issues", owner, repo);
        debug!("Creating issue in {}/{}: {}", owner, repo, title);
        let result = GitHubApi::post(&endpoint, &body_json.to_string(), &token, api_url, timeout).await?;
        info!("Successfully created issue in {}/{}", owner, repo);
        return Ok(result);
    }
}
// ========== List issues ==========
/// Driver for listing GitHub issues
#[derive(Debug)]
pub struct GithubListIssues;
#[async_trait::async_trait]
impl Driver for GithubListIssues {
    /// Returns the unique name of this driver
    fn name(&self) -> &str {
        return "github_list_issues";
    }
    /// Returns a brief description of the driver's functionality
    fn description(&self) -> &str {
        return "List issues from a GitHub repository";
    }
    /// Returns detailed usage guidance for LLMs
    fn usage_hint(&self) -> &str {
        return "Use this skill when the user needs to see existing issues";
    }
    /// Returns the category of this driver
    fn category(&self) -> DriverCategory {
        return DriverCategory::Devops;
    }
    /// Returns the parameter definitions for this driver
    fn parameters(&self) -> Vec<DriverParameter> {
        return vec![
            DriverParameter {
                name: "token".to_string(),
                param_type: "string".to_string(),
                description: "GitHub personal access token".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("ghp_xxxxxxxx".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "owner".to_string(),
                param_type: "string".to_string(),
                description: "Repository owner".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust-lang".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "repo".to_string(),
                param_type: "string".to_string(),
                description: "Repository name".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "state".to_string(),
                param_type: "string".to_string(),
                description: "Issue state (open, closed, all)".to_string(),
                required: false,
                default: Some(Value::String("open".to_string())),
                example: Some(Value::String("open".to_string())),
                enum_values: Some(vec!["open".to_string(), "closed".to_string(), "all".to_string()]),
            },
            DriverParameter {
                name: "limit".to_string(),
                param_type: "integer".to_string(),
                description: "Maximum number of issues to return".to_string(),
                required: false,
                default: Some(Value::Number(30.into())),
                example: Some(Value::Number(10.into())),
                enum_values: None,
            },
            DriverParameter {
                name: "api_url".to_string(),
                param_type: "string".to_string(),
                description: "GitHub API URL".to_string(),
                required: false,
                default: Some(Value::String("https://api.github.com".to_string())),
                example: Some(Value::String("https://api.github.com".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "timeout".to_string(),
                param_type: "integer".to_string(),
                description: "Request timeout in seconds".to_string(),
                required: false,
                default: Some(Value::Number(30.into())),
                example: Some(Value::Number(60.into())),
                enum_values: None,
            },
        ];
    }
    /// Returns an example call for this driver
    fn example_call(&self) -> DriverResult<Value> {
        return Ok(json!({
            "action": "github_list_issues",
            "parameters": {
                "token": "ghp_xxxxxxxx",
                "owner": "rust-lang",
                "repo": "rust",
                "state": "open",
                "limit": 10
            }
        }));
    }
    /// Returns an example output from this driver
    fn example_output(&self) -> String {
        return r#"[{"number": 12345, "title": "Bug report", "state": "open"}]"#.to_string();
    }
    /// Executes the driver with the given parameters
    async fn execute(
        &self,
        parameters: &HashMap<String, Value>,
        _callback: Option<&dyn DriverCallback>,
        _context: Option<&DriverContext>,
    ) -> DriverResult<String> {
        debug!("Executing github_list_issues driver");
        // Extract required parameters
        let token = get_param_string(parameters, "token")?;
        let owner = get_param_string(parameters, "owner")?;
        let repo = get_param_string(parameters, "repo")?;
        let state = parameters.get("state").and_then(|v| v.as_str()).unwrap_or("open");
        let limit = get_param_u64(parameters, "limit", 30);
        let api_url = parameters.get("api_url").and_then(|v| v.as_str()).unwrap_or("https://api.github.com");
        let timeout = get_param_u64(parameters, "timeout", 30);
        let endpoint = format!("repos/{}/{}/issues?state={}&per_page={}", owner, repo, state, limit);
        debug!("Listing issues from {}/{} with state: {}", owner, repo, state);
        let result = GitHubApi::get(&endpoint, &token, api_url, timeout).await?;
        info!("Successfully listed issues from {}/{}", owner, repo);
        return Ok(result);
    }
}
// ========== Star a repository ==========
/// Driver for starring a GitHub repository
#[derive(Debug)]
pub struct GithubStarRepo;
#[async_trait::async_trait]
impl Driver for GithubStarRepo {
    /// Returns the unique name of this driver
    fn name(&self) -> &str {
        return "github_star_repo";
    }
    /// Returns a brief description of the driver's functionality
    fn description(&self) -> &str {
        return "Star a GitHub repository";
    }
    /// Returns detailed usage guidance for LLMs
    fn usage_hint(&self) -> &str {
        return "Use this skill when the user wants to star/favorite a repository";
    }
    /// Returns the category of this driver
    fn category(&self) -> DriverCategory {
        return DriverCategory::Devops;
    }
    /// Returns the parameter definitions for this driver
    fn parameters(&self) -> Vec<DriverParameter> {
        return vec![
            DriverParameter {
                name: "token".to_string(),
                param_type: "string".to_string(),
                description: "GitHub personal access token".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("ghp_xxxxxxxx".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "owner".to_string(),
                param_type: "string".to_string(),
                description: "Repository owner".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust-lang".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "repo".to_string(),
                param_type: "string".to_string(),
                description: "Repository name".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "api_url".to_string(),
                param_type: "string".to_string(),
                description: "GitHub API URL".to_string(),
                required: false,
                default: Some(Value::String("https://api.github.com".to_string())),
                example: Some(Value::String("https://api.github.com".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "timeout".to_string(),
                param_type: "integer".to_string(),
                description: "Request timeout in seconds".to_string(),
                required: false,
                default: Some(Value::Number(30.into())),
                example: Some(Value::Number(60.into())),
                enum_values: None,
            },
        ];
    }
    /// Returns an example call for this driver
    fn example_call(&self) -> DriverResult<Value> {
        return Ok(json!({
            "action": "github_star_repo",
            "parameters": {
                "token": "ghp_xxxxxxxx",
                "owner": "rust-lang",
                "repo": "rust"
            }
        }));
    }
    /// Returns an example output from this driver
    fn example_output(&self) -> String {
        return "Successfully starred rust-lang/rust".to_string();
    }
    /// Executes the driver with the given parameters
    async fn execute(
        &self,
        parameters: &HashMap<String, Value>,
        _callback: Option<&dyn DriverCallback>,
        _context: Option<&DriverContext>,
    ) -> DriverResult<String> {
        debug!("Executing github_star_repo driver");
        // Extract required parameters
        let token = get_param_string(parameters, "token")?;
        let owner = get_param_string(parameters, "owner")?;
        let repo = get_param_string(parameters, "repo")?;
        let api_url = parameters.get("api_url").and_then(|v| v.as_str()).unwrap_or("https://api.github.com");
        let timeout = get_param_u64(parameters, "timeout", 30);
        let endpoint = format!("user/starred/{}/{}", owner, repo);
        debug!("Starring repository: {}/{}", owner, repo);
        GitHubApi::put(&endpoint, None, &token, api_url, timeout).await?;
        info!("Successfully starred {}/{}", owner, repo);
        return Ok(format!("Successfully starred {}/{}", owner, repo));
    }
}
// ========== Search repositories ==========
/// Driver for searching GitHub repositories
#[derive(Debug)]
pub struct GithubSearchRepos;
#[async_trait::async_trait]
impl Driver for GithubSearchRepos {
    /// Returns the unique name of this driver
    fn name(&self) -> &str {
        return "github_search_repos";
    }
    /// Returns a brief description of the driver's functionality
    fn description(&self) -> &str {
        return "Search GitHub repositories by query";
    }
    /// Returns detailed usage guidance for LLMs
    fn usage_hint(&self) -> &str {
        return "Use this skill when the user needs to find repositories";
    }
    /// Returns the category of this driver
    fn category(&self) -> DriverCategory {
        return DriverCategory::Devops;
    }
    /// Returns the parameter definitions for this driver
    fn parameters(&self) -> Vec<DriverParameter> {
        return vec![
            DriverParameter {
                name: "token".to_string(),
                param_type: "string".to_string(),
                description: "GitHub personal access token".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("ghp_xxxxxxxx".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "query".to_string(),
                param_type: "string".to_string(),
                description: "Search query (e.g., 'rust language:rust')".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust language:rust".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "limit".to_string(),
                param_type: "integer".to_string(),
                description: "Maximum number of results".to_string(),
                required: false,
                default: Some(Value::Number(10.into())),
                example: Some(Value::Number(5.into())),
                enum_values: None,
            },
            DriverParameter {
                name: "api_url".to_string(),
                param_type: "string".to_string(),
                description: "GitHub API URL".to_string(),
                required: false,
                default: Some(Value::String("https://api.github.com".to_string())),
                example: Some(Value::String("https://api.github.com".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "timeout".to_string(),
                param_type: "integer".to_string(),
                description: "Request timeout in seconds".to_string(),
                required: false,
                default: Some(Value::Number(30.into())),
                example: Some(Value::Number(60.into())),
                enum_values: None,
            },
        ];
    }
    /// Returns an example call for this driver
    fn example_call(&self) -> DriverResult<Value> {
        return Ok(json!({
            "action": "github_search_repos",
            "parameters": {
                "token": "ghp_xxxxxxxx",
                "query": "rust language:rust",
                "limit": 5
            }
        }));
    }
    /// Returns an example output from this driver
    fn example_output(&self) -> String {
        return r#"{"total_count": 12345, "items": [{"full_name": "rust-lang/rust", "description": "..."}]}"#.to_string();
    }
    /// Executes the driver with the given parameters
    async fn execute(
        &self,
        parameters: &HashMap<String, Value>,
        _callback: Option<&dyn DriverCallback>,
        _context: Option<&DriverContext>,
    ) -> DriverResult<String> {
        debug!("Executing github_search_repos driver");
        // Extract required parameters
        let token = get_param_string(parameters, "token")?;
        let query = get_param_string(parameters, "query")?;
        let limit = get_param_u64(parameters, "limit", 10);
        let api_url = parameters.get("api_url").and_then(|v| v.as_str()).unwrap_or("https://api.github.com");
        let timeout = get_param_u64(parameters, "timeout", 30);
        let encoded_query = urlencoding::encode(&query);
        let endpoint = format!("search/repositories?q={}&per_page={}", encoded_query, limit);
        debug!("Searching repositories with query: {}", query);
        let result = GitHubApi::get(&endpoint, &token, api_url, timeout).await?;
        info!("Successfully searched repositories with query: {}", query);
        return Ok(result);
    }
}
// ========== Get user information ==========
/// Driver for getting GitHub user information
#[derive(Debug)]
pub struct GithubGetUser;
#[async_trait::async_trait]
impl Driver for GithubGetUser {
    /// Returns the unique name of this driver
    fn name(&self) -> &str {
        return "github_get_user";
    }
    /// Returns a brief description of the driver's functionality
    fn description(&self) -> &str {
        return "Get GitHub user information";
    }
    /// Returns detailed usage guidance for LLMs
    fn usage_hint(&self) -> &str {
        return "Use this skill when the user needs to get profile info of a GitHub user";
    }
    /// Returns the category of this driver
    fn category(&self) -> DriverCategory {
        return DriverCategory::Devops;
    }
    /// Returns the parameter definitions for this driver
    fn parameters(&self) -> Vec<DriverParameter> {
        return vec![
            DriverParameter {
                name: "token".to_string(),
                param_type: "string".to_string(),
                description: "GitHub personal access token".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("ghp_xxxxxxxx".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "username".to_string(),
                param_type: "string".to_string(),
                description: "GitHub username".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("octocat".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "api_url".to_string(),
                param_type: "string".to_string(),
                description: "GitHub API URL".to_string(),
                required: false,
                default: Some(Value::String("https://api.github.com".to_string())),
                example: Some(Value::String("https://api.github.com".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "timeout".to_string(),
                param_type: "integer".to_string(),
                description: "Request timeout in seconds".to_string(),
                required: false,
                default: Some(Value::Number(30.into())),
                example: Some(Value::Number(60.into())),
                enum_values: None,
            },
        ];
    }
    /// Returns an example call for this driver
    fn example_call(&self) -> DriverResult<Value> {
        return Ok(json!({
            "action": "github_get_user",
            "parameters": {
                "token": "ghp_xxxxxxxx",
                "username": "octocat"
            }
        }));
    }
    /// Returns an example output from this driver
    fn example_output(&self) -> String {
        return r#"{"login": "octocat", "name": "The Octocat", "public_repos": 8}"#.to_string();
    }
    /// Executes the driver with the given parameters
    async fn execute(
        &self,
        parameters: &HashMap<String, Value>,
        _callback: Option<&dyn DriverCallback>,
        _context: Option<&DriverContext>,
    ) -> DriverResult<String> {
        debug!("Executing github_get_user driver");
        // Extract required parameters
        let token = get_param_string(parameters, "token")?;
        let username = get_param_string(parameters, "username")?;
        let api_url = parameters.get("api_url").and_then(|v| v.as_str()).unwrap_or("https://api.github.com");
        let timeout = get_param_u64(parameters, "timeout", 30);
        let endpoint = format!("users/{}", username);
        debug!("Fetching user info: {}", username);
        let result = GitHubApi::get(&endpoint, &token, api_url, timeout).await?;
        info!("Successfully fetched user info: {}", username);
        return Ok(result);
    }
}
// ========== List pull requests ==========
/// Driver for listing GitHub pull requests
#[derive(Debug)]
pub struct GithubListPRs;
#[async_trait::async_trait]
impl Driver for GithubListPRs {
    /// Returns the unique name of this driver
    fn name(&self) -> &str {
        return "github_list_prs";
    }
    /// Returns a brief description of the driver's functionality
    fn description(&self) -> &str {
        return "List pull requests from a GitHub repository";
    }
    /// Returns detailed usage guidance for LLMs
    fn usage_hint(&self) -> &str {
        return "Use this skill when the user needs to see open pull requests";
    }
    /// Returns the category of this driver
    fn category(&self) -> DriverCategory {
        return DriverCategory::Devops;
    }
    /// Returns the parameter definitions for this driver
    fn parameters(&self) -> Vec<DriverParameter> {
        return vec![
            DriverParameter {
                name: "token".to_string(),
                param_type: "string".to_string(),
                description: "GitHub personal access token".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("ghp_xxxxxxxx".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "owner".to_string(),
                param_type: "string".to_string(),
                description: "Repository owner".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust-lang".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "repo".to_string(),
                param_type: "string".to_string(),
                description: "Repository name".to_string(),
                required: true,
                default: None,
                example: Some(Value::String("rust".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "state".to_string(),
                param_type: "string".to_string(),
                description: "PR state (open, closed, all)".to_string(),
                required: false,
                default: Some(Value::String("open".to_string())),
                example: Some(Value::String("open".to_string())),
                enum_values: Some(vec!["open".to_string(), "closed".to_string(), "all".to_string()]),
            },
            DriverParameter {
                name: "limit".to_string(),
                param_type: "integer".to_string(),
                description: "Maximum number of PRs to return".to_string(),
                required: false,
                default: Some(Value::Number(30.into())),
                example: Some(Value::Number(10.into())),
                enum_values: None,
            },
            DriverParameter {
                name: "api_url".to_string(),
                param_type: "string".to_string(),
                description: "GitHub API URL".to_string(),
                required: false,
                default: Some(Value::String("https://api.github.com".to_string())),
                example: Some(Value::String("https://api.github.com".to_string())),
                enum_values: None,
            },
            DriverParameter {
                name: "timeout".to_string(),
                param_type: "integer".to_string(),
                description: "Request timeout in seconds".to_string(),
                required: false,
                default: Some(Value::Number(30.into())),
                example: Some(Value::Number(60.into())),
                enum_values: None,
            },
        ];
    }
    /// Returns an example call for this driver
    fn example_call(&self) -> DriverResult<Value> {
        return Ok(json!({
            "action": "github_list_prs",
            "parameters": {
                "token": "ghp_xxxxxxxx",
                "owner": "rust-lang",
                "repo": "rust",
                "state": "open",
                "limit": 10
            }
        }));
    }
    /// Returns an example output from this driver
    fn example_output(&self) -> String {
        return r#"[{"number": 123, "title": "Add feature", "user": {"login": "contributor"}}]"#.to_string();
    }
    /// Executes the driver with the given parameters
    async fn execute(
        &self,
        parameters: &HashMap<String, Value>,
        _callback: Option<&dyn DriverCallback>,
        _context: Option<&DriverContext>,
    ) -> DriverResult<String> {
        debug!("Executing github_list_prs driver");
        // Extract required parameters
        let token = get_param_string(parameters, "token")?;
        let owner = get_param_string(parameters, "owner")?;
        let repo = get_param_string(parameters, "repo")?;
        let state = parameters.get("state").and_then(|v| v.as_str()).unwrap_or("open");
        let limit = get_param_u64(parameters, "limit", 30);
        let api_url = parameters.get("api_url").and_then(|v| v.as_str()).unwrap_or("https://api.github.com");
        let timeout = get_param_u64(parameters, "timeout", 30);
        let endpoint = format!("repos/{}/{}/pulls?state={}&per_page={}", owner, repo, state, limit);
        debug!("Listing PRs from {}/{} with state: {}", owner, repo, state);
        let result = GitHubApi::get(&endpoint, &token, api_url, timeout).await?;
        info!("Successfully listed PRs from {}/{}", owner, repo);
        return Ok(result);
    }
}