Aligns module path with canonical Gitea source (infra ADR-0004) and repo name. Binary only, no downstream consumers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Roq1ajWKR5f1hG5Df9wC6A
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
"git.d-ma.be/mathias/hyperguild/internal/tier"
|
|
)
|
|
|
|
const defaultAnthropicProbe = "https://api.anthropic.com"
|
|
|
|
func runTier(ctx context.Context, args []string, _ io.Reader, stdout, stderr io.Writer) error {
|
|
fs := flag.NewFlagSet("tier", flag.ContinueOnError)
|
|
fs.SetOutput(stderr)
|
|
asJSON := fs.Bool("json", false, "output JSON instead of human-readable")
|
|
if err := fs.Parse(args); err != nil {
|
|
return fmt.Errorf("parse flags: %w", err)
|
|
}
|
|
|
|
anthropicURL := os.Getenv("ANTHROPIC_PROBE_URL")
|
|
if anthropicURL == "" {
|
|
anthropicURL = defaultAnthropicProbe
|
|
}
|
|
liteLLMURL := os.Getenv("LITELLM_BASE_URL") // empty → tier falls through to airplane
|
|
|
|
info := tier.Detect(ctx, anthropicURL, liteLLMURL)
|
|
|
|
if *asJSON {
|
|
enc := json.NewEncoder(stdout)
|
|
enc.SetIndent("", " ")
|
|
if err := enc.Encode(info); err != nil {
|
|
return fmt.Errorf("encode json: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
fmt.Fprintf(stdout, "tier %d (%s) managed_agents=%t\n", int(info.Tier), info.Label, info.ManagedAgents) //nolint:errcheck
|
|
return nil
|
|
}
|