clawgarden-cli 0.1.4

ClawGarden CLI - Multi-bot/multi-agent Garden management tool
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
//! Provider Plugin Registry
//!
//! Static registry of known AI providers, ported from OpenClaw's plugin architecture.
//! Each provider can have multiple auth methods.
//! https://github.com/openclaw/openclaw

use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};

// =============================================================================
// Provider Auth Types (ported from OpenClaw's src/plugins/types.ts)
// =============================================================================

/// Authentication method kind
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ProviderAuthKind {
    #[serde(rename = "api_key")]
    ApiKey,
    #[serde(rename = "oauth")]
    OAuth,
    #[serde(rename = "token")]
    Token,
    #[serde(rename = "device_code")]
    DeviceCode,
    #[serde(rename = "custom")]
    Custom,
}

/// Wizard setup metadata for provider auth choices
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProviderPluginWizardSetup {
    /// Unique choice identifier
    pub choice_id: Option<String>,
    /// Display label
    pub choice_label: Option<String>,
    /// Hint text
    pub choice_hint: Option<String>,
    /// Assistant priority (-100 to 100, higher = more prominent)
    pub assistant_priority: Option<i32>,
    /// Visibility mode
    #[serde(rename = "assistantVisibility")]
    pub assistant_visibility: Option<String>,
    /// Group identifier
    #[serde(rename = "groupId")]
    pub group_id: Option<String>,
    /// Group display label
    #[serde(rename = "groupLabel")]
    pub group_label: Option<String>,
    /// Group hint
    #[serde(rename = "groupHint")]
    pub group_hint: Option<String>,
    /// Method ID for explicit method selection
    #[serde(rename = "methodId")]
    pub method_id: Option<String>,
    /// Onboarding scopes where this auth choice appears
    #[serde(rename = "onboardingScopes")]
    pub onboarding_scopes: Option<Vec<String>>,
    /// Model allowlist policy
    #[serde(rename = "modelAllowlist")]
    pub model_allowlist: Option<ModelAllowlist>,
    /// Model selection policy
    #[serde(rename = "modelSelection")]
    pub model_selection: Option<ModelSelection>,
}

/// Model allowlist policy
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModelAllowlist {
    /// Allowed model keys
    #[serde(rename = "allowedKeys")]
    pub allowed_keys: Option<Vec<String>>,
    /// Initial selections
    #[serde(rename = "initialSelections")]
    pub initial_selections: Option<Vec<String>>,
    /// Message to display
    pub message: Option<String>,
}

/// Model selection policy
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModelSelection {
    /// Prompt even when auth choice is provided
    #[serde(rename = "promptWhenAuthChoiceProvided")]
    pub prompt_when_auth_choice_provided: Option<bool>,
    /// Allow keeping current selection
    #[serde(rename = "allowKeepCurrent")]
    pub allow_keep_current: Option<bool>,
}

/// An authentication method for a provider
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProviderAuthMethod {
    /// Unique identifier for this auth method
    pub id: String,
    /// Human-readable label
    pub label: String,
    /// Hint text shown to user
    pub hint: Option<String>,
    /// Authentication kind
    pub kind: ProviderAuthKind,
    /// Wizard/onboarding metadata
    pub wizard: Option<ProviderPluginWizardSetup>,
}

/// A provider plugin definition (ported from OpenClaw's ProviderPlugin)
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProviderPlugin {
    /// Unique provider identifier (used in auth.json)
    pub id: String,
    /// Human-readable name
    pub label: String,
    /// Documentation path
    #[serde(rename = "docsPath")]
    pub docs_path: Option<String>,
    /// Provider icon/emoji for UI
    pub icon: &'static str,
    /// Internal-only aliases for config hook lookup
    #[serde(rename = "hookAliases")]
    pub hook_aliases: Option<Vec<String>>,
    /// Provider-related env vars shown in setup/help surfaces
    #[serde(rename = "envVars")]
    pub env_vars: Option<Vec<String>>,
    /// Available authentication methods
    pub auth: Vec<ProviderAuthMethod>,
    /// Optional default model
    #[serde(rename = "defaultModel")]
    pub default_model: Option<String>,
}

impl ProviderPlugin {
    /// Find an auth method by ID
    #[allow(dead_code)]
    pub fn auth_method(&self, method_id: &str) -> Option<&ProviderAuthMethod> {
        self.auth.iter().find(|m| m.id == method_id)
    }
}

/// Provider registry - static list of known providers
pub struct ProviderRegistry;

impl ProviderRegistry {
    /// Get all available providers
    pub fn providers() -> &'static [ProviderPlugin] {
        &PROVIDERS
    }

    /// Find a provider by ID
    #[allow(dead_code)]
    pub fn find(id: &str) -> Option<&'static ProviderPlugin> {
        let id_lower = id.to_lowercase();
        PROVIDERS.iter().find(|p| p.id.to_lowercase() == id_lower)
    }

    /// Get provider IDs as a list
    #[allow(dead_code)]
    pub fn ids() -> Vec<String> {
        PROVIDERS.iter().map(|p| p.id.clone()).collect()
    }
}

// =============================================================================
// Provider Definitions (ported from OpenClaw extensions)
// =============================================================================

/// Known providers - hardcoded list matching OpenClaw's plugin system
static PROVIDERS: Lazy<Vec<ProviderPlugin>> = Lazy::new(|| {
    vec![
        ProviderPlugin {
            id: "anthropic".to_string(),
            label: "Anthropic".to_string(),
            docs_path: Some("/providers/models".to_string()),
            icon: "🧠",
            hook_aliases: Some(vec!["claude-cli".to_string()]),
            env_vars: Some(vec![
                "ANTHROPIC_API_KEY".to_string(),
                "ANTHROPIC_OAUTH_TOKEN".to_string(),
            ]),
            default_model: Some("anthropic/claude-sonnet-4-6".to_string()),
            auth: vec![ProviderAuthMethod {
                id: "api-key".to_string(),
                label: "Anthropic API key".to_string(),
                hint: Some("Direct Anthropic API key".to_string()),
                kind: ProviderAuthKind::ApiKey,
                wizard: Some(ProviderPluginWizardSetup {
                    choice_id: Some("anthropic-api-key".to_string()),
                    choice_label: Some("Anthropic API key".to_string()),
                    choice_hint: Some("Direct API key path".to_string()),
                    assistant_priority: Some(0),
                    assistant_visibility: None,
                    group_id: Some("anthropic".to_string()),
                    group_label: Some("Anthropic".to_string()),
                    group_hint: Some("Claude API key".to_string()),
                    method_id: Some("api-key".to_string()),
                    onboarding_scopes: Some(vec!["text-inference".to_string()]),
                    model_allowlist: None,
                    model_selection: None,
                }),
            }],
        },
        ProviderPlugin {
            id: "openai".to_string(),
            label: "OpenAI".to_string(),
            docs_path: Some("/providers/models".to_string()),
            icon: "🤖",
            hook_aliases: Some(vec![
                "azure-openai".to_string(),
                "azure-openai-responses".to_string(),
            ]),
            env_vars: Some(vec!["OPENAI_API_KEY".to_string()]),
            default_model: Some("openai/gpt-5.4".to_string()),
            auth: vec![ProviderAuthMethod {
                id: "api-key".to_string(),
                label: "OpenAI API key".to_string(),
                hint: Some("Direct OpenAI API key".to_string()),
                kind: ProviderAuthKind::ApiKey,
                wizard: Some(ProviderPluginWizardSetup {
                    choice_id: Some("openai-api-key".to_string()),
                    choice_label: Some("OpenAI API key".to_string()),
                    choice_hint: Some("Direct API key path".to_string()),
                    assistant_priority: Some(0),
                    assistant_visibility: None,
                    group_id: Some("openai".to_string()),
                    group_label: Some("OpenAI".to_string()),
                    group_hint: Some("GPT models via OpenAI API".to_string()),
                    method_id: Some("api-key".to_string()),
                    onboarding_scopes: Some(vec!["text-inference".to_string()]),
                    model_allowlist: None,
                    model_selection: None,
                }),
            }],
        },
        ProviderPlugin {
            id: "google".to_string(),
            label: "Google".to_string(),
            docs_path: Some("/providers/models".to_string()),
            icon: "🔵",
            hook_aliases: None,
            env_vars: Some(vec!["GOOGLE_API_KEY".to_string()]),
            default_model: Some("google/gemini-2.5".to_string()),
            auth: vec![ProviderAuthMethod {
                id: "api-key".to_string(),
                label: "Google API key".to_string(),
                hint: Some("Google AI / Gemini API key".to_string()),
                kind: ProviderAuthKind::ApiKey,
                wizard: Some(ProviderPluginWizardSetup {
                    choice_id: Some("google-api-key".to_string()),
                    choice_label: Some("Google API key".to_string()),
                    choice_hint: Some("Direct API key path".to_string()),
                    assistant_priority: Some(0),
                    assistant_visibility: None,
                    group_id: Some("google".to_string()),
                    group_label: Some("Google".to_string()),
                    group_hint: Some("Gemini models via Google AI".to_string()),
                    method_id: Some("api-key".to_string()),
                    onboarding_scopes: Some(vec!["text-inference".to_string()]),
                    model_allowlist: None,
                    model_selection: None,
                }),
            }],
        },
        ProviderPlugin {
            id: "deepseek".to_string(),
            label: "DeepSeek".to_string(),
            docs_path: Some("/providers/deepseek".to_string()),
            icon: "🔮",
            hook_aliases: None,
            env_vars: Some(vec!["DEEPSEEK_API_KEY".to_string()]),
            default_model: Some("deepseek/deepseek-chat-v3".to_string()),
            auth: vec![ProviderAuthMethod {
                id: "api-key".to_string(),
                label: "DeepSeek API key".to_string(),
                hint: Some("DeepSeek API key".to_string()),
                kind: ProviderAuthKind::ApiKey,
                wizard: Some(ProviderPluginWizardSetup {
                    choice_id: Some("deepseek-api-key".to_string()),
                    choice_label: Some("DeepSeek API key".to_string()),
                    choice_hint: Some("Direct API key path".to_string()),
                    assistant_priority: Some(0),
                    assistant_visibility: None,
                    group_id: Some("deepseek".to_string()),
                    group_label: Some("DeepSeek".to_string()),
                    group_hint: Some("DeepSeek models via DeepSeek API".to_string()),
                    method_id: Some("api-key".to_string()),
                    onboarding_scopes: Some(vec!["text-inference".to_string()]),
                    model_allowlist: None,
                    model_selection: None,
                }),
            }],
        },
        ProviderPlugin {
            id: "openrouter".to_string(),
            label: "OpenRouter".to_string(),
            docs_path: Some("/providers/openrouter".to_string()),
            icon: "🛤️",
            hook_aliases: None,
            env_vars: Some(vec!["OPENROUTER_API_KEY".to_string()]),
            default_model: Some("openrouter/anthropic/claude-sonnet-4-6".to_string()),
            auth: vec![ProviderAuthMethod {
                id: "api-key".to_string(),
                label: "OpenRouter API key".to_string(),
                hint: Some("OpenRouter API key".to_string()),
                kind: ProviderAuthKind::ApiKey,
                wizard: Some(ProviderPluginWizardSetup {
                    choice_id: Some("openrouter-api-key".to_string()),
                    choice_label: Some("OpenRouter API key".to_string()),
                    choice_hint: Some("Direct API key path".to_string()),
                    assistant_priority: Some(0),
                    assistant_visibility: None,
                    group_id: Some("openrouter".to_string()),
                    group_label: Some("OpenRouter".to_string()),
                    group_hint: Some("Multiple models via OpenRouter".to_string()),
                    method_id: Some("api-key".to_string()),
                    onboarding_scopes: Some(vec!["text-inference".to_string()]),
                    model_allowlist: None,
                    model_selection: None,
                }),
            }],
        },
        ProviderPlugin {
            id: "azure".to_string(),
            label: "Azure OpenAI".to_string(),
            docs_path: Some("/providers/azure".to_string()),
            icon: "☁️",
            hook_aliases: None,
            env_vars: Some(vec!["AZURE_OPENAI_API_KEY".to_string()]),
            default_model: Some("azure/gpt-5.4".to_string()),
            auth: vec![ProviderAuthMethod {
                id: "api-key".to_string(),
                label: "Azure OpenAI API key".to_string(),
                hint: Some("Azure OpenAI API key".to_string()),
                kind: ProviderAuthKind::ApiKey,
                wizard: Some(ProviderPluginWizardSetup {
                    choice_id: Some("azure-api-key".to_string()),
                    choice_label: Some("Azure OpenAI API key".to_string()),
                    choice_hint: Some("Direct API key path".to_string()),
                    assistant_priority: Some(0),
                    assistant_visibility: None,
                    group_id: Some("azure".to_string()),
                    group_label: Some("Azure OpenAI".to_string()),
                    group_hint: Some("OpenAI models via Azure".to_string()),
                    method_id: Some("api-key".to_string()),
                    onboarding_scopes: Some(vec!["text-inference".to_string()]),
                    model_allowlist: None,
                    model_selection: None,
                }),
            }],
        },
        ProviderPlugin {
            id: "groq".to_string(),
            label: "Groq".to_string(),
            docs_path: Some("/providers/groq".to_string()),
            icon: "",
            hook_aliases: None,
            env_vars: Some(vec!["GROQ_API_KEY".to_string()]),
            default_model: Some("groq/llama-4-scout".to_string()),
            auth: vec![ProviderAuthMethod {
                id: "api-key".to_string(),
                label: "Groq API key".to_string(),
                hint: Some("Groq API key".to_string()),
                kind: ProviderAuthKind::ApiKey,
                wizard: Some(ProviderPluginWizardSetup {
                    choice_id: Some("groq-api-key".to_string()),
                    choice_label: Some("Groq API key".to_string()),
                    choice_hint: Some("Direct API key path".to_string()),
                    assistant_priority: Some(0),
                    assistant_visibility: None,
                    group_id: Some("groq".to_string()),
                    group_label: Some("Groq".to_string()),
                    group_hint: Some("Fast inference via Groq".to_string()),
                    method_id: Some("api-key".to_string()),
                    onboarding_scopes: Some(vec!["text-inference".to_string()]),
                    model_allowlist: None,
                    model_selection: None,
                }),
            }],
        },
        ProviderPlugin {
            id: "together".to_string(),
            label: "Together AI".to_string(),
            docs_path: Some("/providers/together".to_string()),
            icon: "🤝",
            hook_aliases: None,
            env_vars: Some(vec!["TOGETHER_API_KEY".to_string()]),
            default_model: Some("together/llama-4-scout".to_string()),
            auth: vec![ProviderAuthMethod {
                id: "api-key".to_string(),
                label: "Together AI API key".to_string(),
                hint: Some("Together AI API key".to_string()),
                kind: ProviderAuthKind::ApiKey,
                wizard: Some(ProviderPluginWizardSetup {
                    choice_id: Some("together-api-key".to_string()),
                    choice_label: Some("Together AI API key".to_string()),
                    choice_hint: Some("Direct API key path".to_string()),
                    assistant_priority: Some(0),
                    assistant_visibility: None,
                    group_id: Some("together".to_string()),
                    group_label: Some("Together AI".to_string()),
                    group_hint: Some("Open models via Together AI".to_string()),
                    method_id: Some("api-key".to_string()),
                    onboarding_scopes: Some(vec!["text-inference".to_string()]),
                    model_allowlist: None,
                    model_selection: None,
                }),
            }],
        },
        ProviderPlugin {
            id: "minimax".to_string(),
            label: "MiniMax".to_string(),
            docs_path: Some("/providers/minimax".to_string()),
            icon: "🟠",
            hook_aliases: Some(vec!["minimax-cn".to_string()]),
            env_vars: Some(vec![
                "MINIMAX_API_KEY".to_string(),
                "MINIMAX_CODING_API_KEY".to_string(),
            ]),
            default_model: Some("minimax/MiniMax-Text-01".to_string()),
            auth: vec![
                ProviderAuthMethod {
                    id: "api-global".to_string(),
                    label: "MiniMax API key (Global)".to_string(),
                    hint: Some("Global endpoint - api.minimax.io".to_string()),
                    kind: ProviderAuthKind::ApiKey,
                    wizard: Some(ProviderPluginWizardSetup {
                        choice_id: Some("minimax-global-api".to_string()),
                        choice_label: Some("MiniMax API key (Global)".to_string()),
                        choice_hint: Some("Global endpoint - api.minimax.io".to_string()),
                        assistant_priority: Some(0),
                        assistant_visibility: None,
                        group_id: Some("minimax".to_string()),
                        group_label: Some("MiniMax".to_string()),
                        group_hint: Some("M2.7 reasoning models".to_string()),
                        method_id: Some("api-global".to_string()),
                        onboarding_scopes: Some(vec!["text-inference".to_string()]),
                        model_allowlist: None,
                        model_selection: None,
                    }),
                },
                ProviderAuthMethod {
                    id: "api-cn".to_string(),
                    label: "MiniMax API key (CN)".to_string(),
                    hint: Some("CN endpoint - api.minimaxi.com".to_string()),
                    kind: ProviderAuthKind::ApiKey,
                    wizard: Some(ProviderPluginWizardSetup {
                        choice_id: Some("minimax-cn-api".to_string()),
                        choice_label: Some("MiniMax API key (CN)".to_string()),
                        choice_hint: Some("CN endpoint - api.minimaxi.com".to_string()),
                        assistant_priority: Some(0),
                        assistant_visibility: None,
                        group_id: Some("minimax".to_string()),
                        group_label: Some("MiniMax".to_string()),
                        group_hint: Some("M2.7 reasoning models".to_string()),
                        method_id: Some("api-cn".to_string()),
                        onboarding_scopes: Some(vec!["text-inference".to_string()]),
                        model_allowlist: None,
                        model_selection: None,
                    }),
                },
            ],
        },
        ProviderPlugin {
            id: "kimi".to_string(),
            label: "Kimi (Moonshot AI)".to_string(),
            docs_path: Some("/providers/moonshot".to_string()),
            icon: "🌙",
            hook_aliases: Some(vec!["kimi-code".to_string(), "kimi-coding".to_string()]),
            env_vars: Some(vec![
                "KIMI_API_KEY".to_string(),
                "KIMICODE_API_KEY".to_string(),
            ]),
            default_model: Some("kimi/kimi-k2.5".to_string()),
            auth: vec![ProviderAuthMethod {
                id: "api-key".to_string(),
                label: "Kimi Code API key".to_string(),
                hint: Some("Kimi K2.5 + Kimi coding models".to_string()),
                kind: ProviderAuthKind::ApiKey,
                wizard: Some(ProviderPluginWizardSetup {
                    choice_id: Some("kimi-code-api-key".to_string()),
                    choice_label: Some("Kimi Code API key".to_string()),
                    choice_hint: Some("Kimi K2.5 coding endpoint".to_string()),
                    assistant_priority: Some(0),
                    assistant_visibility: None,
                    group_id: Some("moonshot".to_string()),
                    group_label: Some("Moonshot AI (Kimi K2.5)".to_string()),
                    group_hint: Some("Kimi K2.5 models".to_string()),
                    method_id: Some("api-key".to_string()),
                    onboarding_scopes: Some(vec!["text-inference".to_string()]),
                    model_allowlist: None,
                    model_selection: None,
                }),
            }],
        },
        ProviderPlugin {
            id: "zai".to_string(),
            label: "Z.AI (GLM)".to_string(),
            docs_path: Some("/providers/models".to_string()),
            icon: "🧬",
            hook_aliases: Some(vec!["z-ai".to_string(), "z.ai".to_string()]),
            env_vars: Some(vec!["ZAI_API_KEY".to_string(), "Z_AI_API_KEY".to_string()]),
            default_model: Some("zai/glm-4.7".to_string()),
            auth: vec![
                ProviderAuthMethod {
                    id: "api-key".to_string(),
                    label: "Z.AI API key".to_string(),
                    hint: Some("Z.AI GLM models".to_string()),
                    kind: ProviderAuthKind::ApiKey,
                    wizard: Some(ProviderPluginWizardSetup {
                        choice_id: Some("zai-api-key".to_string()),
                        choice_label: Some("Z.AI API key".to_string()),
                        choice_hint: Some("GLM models via Z.AI".to_string()),
                        assistant_priority: Some(0),
                        assistant_visibility: None,
                        group_id: Some("zai".to_string()),
                        group_label: Some("Z.AI".to_string()),
                        group_hint: Some("GLM Coding Plan / Global / CN".to_string()),
                        method_id: Some("api-key".to_string()),
                        onboarding_scopes: Some(vec!["text-inference".to_string()]),
                        model_allowlist: None,
                        model_selection: None,
                    }),
                },
                ProviderAuthMethod {
                    id: "coding-global".to_string(),
                    label: "Coding-Plan-Global".to_string(),
                    hint: Some("GLM Coding Plan Global (api.z.ai)".to_string()),
                    kind: ProviderAuthKind::ApiKey,
                    wizard: Some(ProviderPluginWizardSetup {
                        choice_id: Some("zai-coding-global".to_string()),
                        choice_label: Some("Coding-Plan-Global".to_string()),
                        choice_hint: Some("GLM Coding Plan Global (api.z.ai)".to_string()),
                        assistant_priority: Some(0),
                        assistant_visibility: None,
                        group_id: Some("zai".to_string()),
                        group_label: Some("Z.AI".to_string()),
                        group_hint: Some("GLM Coding Plan / Global / CN".to_string()),
                        method_id: Some("coding-global".to_string()),
                        onboarding_scopes: Some(vec!["text-inference".to_string()]),
                        model_allowlist: None,
                        model_selection: None,
                    }),
                },
                ProviderAuthMethod {
                    id: "coding-cn".to_string(),
                    label: "Coding-Plan-CN".to_string(),
                    hint: Some("GLM Coding Plan CN (open.bigmodel.cn)".to_string()),
                    kind: ProviderAuthKind::ApiKey,
                    wizard: Some(ProviderPluginWizardSetup {
                        choice_id: Some("zai-coding-cn".to_string()),
                        choice_label: Some("Coding-Plan-CN".to_string()),
                        choice_hint: Some("GLM Coding Plan CN (open.bigmodel.cn)".to_string()),
                        assistant_priority: Some(0),
                        assistant_visibility: None,
                        group_id: Some("zai".to_string()),
                        group_label: Some("Z.AI".to_string()),
                        group_hint: Some("GLM Coding Plan / Global / CN".to_string()),
                        method_id: Some("coding-cn".to_string()),
                        onboarding_scopes: Some(vec!["text-inference".to_string()]),
                        model_allowlist: None,
                        model_selection: None,
                    }),
                },
                ProviderAuthMethod {
                    id: "global".to_string(),
                    label: "Global".to_string(),
                    hint: Some("Z.AI Global (api.z.ai)".to_string()),
                    kind: ProviderAuthKind::ApiKey,
                    wizard: Some(ProviderPluginWizardSetup {
                        choice_id: Some("zai-global".to_string()),
                        choice_label: Some("Global".to_string()),
                        choice_hint: Some("Z.AI Global (api.z.ai)".to_string()),
                        assistant_priority: Some(0),
                        assistant_visibility: None,
                        group_id: Some("zai".to_string()),
                        group_label: Some("Z.AI".to_string()),
                        group_hint: Some("GLM Coding Plan / Global / CN".to_string()),
                        method_id: Some("global".to_string()),
                        onboarding_scopes: Some(vec!["text-inference".to_string()]),
                        model_allowlist: None,
                        model_selection: None,
                    }),
                },
                ProviderAuthMethod {
                    id: "cn".to_string(),
                    label: "CN".to_string(),
                    hint: Some("Z.AI CN (open.bigmodel.cn)".to_string()),
                    kind: ProviderAuthKind::ApiKey,
                    wizard: Some(ProviderPluginWizardSetup {
                        choice_id: Some("zai-cn".to_string()),
                        choice_label: Some("CN".to_string()),
                        choice_hint: Some("Z.AI CN (open.bigmodel.cn)".to_string()),
                        assistant_priority: Some(0),
                        assistant_visibility: None,
                        group_id: Some("zai".to_string()),
                        group_label: Some("Z.AI".to_string()),
                        group_hint: Some("GLM Coding Plan / Global / CN".to_string()),
                        method_id: Some("cn".to_string()),
                        onboarding_scopes: Some(vec!["text-inference".to_string()]),
                        model_allowlist: None,
                        model_selection: None,
                    }),
                },
            ],
        },
    ]
});

/// Generate auth.json content for pi
/// Format: https://github.com/pi/pi-coding-agent/blob/main/docs/auth.md
#[derive(Debug, Serialize)]
pub struct PiAuthJson {
    #[serde(rename = "anthropic")]
    anthropic: Option<ProviderAuth>,
    #[serde(rename = "openai")]
    openai: Option<ProviderAuth>,
    #[serde(rename = "google")]
    google: Option<ProviderAuth>,
    #[serde(rename = "deepseek")]
    deepseek: Option<ProviderAuth>,
    #[serde(rename = "openrouter")]
    openrouter: Option<ProviderAuth>,
    #[serde(rename = "azure")]
    azure: Option<ProviderAuth>,
    #[serde(rename = "groq")]
    groq: Option<ProviderAuth>,
    #[serde(rename = "together")]
    together: Option<ProviderAuth>,
    #[serde(rename = "minimax")]
    minimax: Option<ProviderAuth>,
    #[serde(rename = "kimi")]
    kimi: Option<ProviderAuth>,
    #[serde(rename = "zai")]
    zai: Option<ProviderAuth>,
}

#[derive(Debug, Serialize)]
pub struct ProviderAuth {
    #[serde(rename = "type")]
    pub auth_type: String,
    pub key: String,
}

impl PiAuthJson {
    /// Create a new auth config with the given provider keys
    pub fn new(provider_keys: &[(String, String)]) -> Self {
        let mut auth = PiAuthJson {
            anthropic: None,
            openai: None,
            google: None,
            deepseek: None,
            openrouter: None,
            azure: None,
            groq: None,
            together: None,
            minimax: None,
            kimi: None,
            zai: None,
        };

        for (provider, key) in provider_keys {
            let provider_auth = ProviderAuth {
                auth_type: "api_key".to_string(),
                key: key.clone(),
            };

            match provider.as_str() {
                "anthropic" => auth.anthropic = Some(provider_auth),
                "openai" => auth.openai = Some(provider_auth),
                "google" => auth.google = Some(provider_auth),
                "deepseek" => auth.deepseek = Some(provider_auth),
                "openrouter" => auth.openrouter = Some(provider_auth),
                "azure" => auth.azure = Some(provider_auth),
                "groq" => auth.groq = Some(provider_auth),
                "together" => auth.together = Some(provider_auth),
                "minimax" => auth.minimax = Some(provider_auth),
                "kimi" => auth.kimi = Some(provider_auth),
                "zai" => auth.zai = Some(provider_auth),
                _ => {}
            }
        }

        auth
    }

    /// Serialize to JSON string
    pub fn to_json_string(&self) -> Result<String, serde_json::Error> {
        serde_json::to_string_pretty(self)
    }
}