Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Showing 1 changed file with 19 additions and 1 deletion.
| @@ -21,6 +21,7 @@ import ( | ||
| 21 | 21 | |
| 22 | 22 | "github.com/johannSo/codey/internal/agent" |
| 23 | 23 | "github.com/johannSo/codey/internal/approval" |
| 24 | + "github.com/johannSo/codey/internal/claudecode" | |
| 24 | 25 | "github.com/johannSo/codey/internal/llm" |
| 25 | 26 | "github.com/johannSo/codey/internal/metrics" |
| 26 | 27 | "github.com/johannSo/codey/internal/tools" |
| @@ -78,6 +79,7 @@ func run() error { | ||
| 78 | 79 | tasksDir := flag.String("dir", "evals/tasks", "directory of task definitions") |
| 79 | 80 | outDir := flag.String("out", "evals/runs", "where to persist transcripts") |
| 80 | 81 | keep := flag.Bool("keep", false, "keep the temporary work directories") |
| 82 | + claudeCodeAuth := flag.Bool("claude-code-auth", false, "with no API key set, borrow the OAuth login in ~/"+claudecode.Filename+" — your own machine only; it is issued to Claude Code") | |
| 81 | 83 | flag.Parse() |
| 82 | 84 | |
| 83 | 85 | tasks, err := loadTasks(*tasksDir, *only) |
| @@ -88,8 +90,23 @@ func run() error { | ||
| 88 | 90 | return fmt.Errorf("no tasks found in %s", *tasksDir) |
| 89 | 91 | } |
| 90 | 92 | client := llm.New(llm.WithModel(*model)) |
| 93 | + // The identity block an OAuth request from Claude Code's login must carry, | |
| 94 | + // set only when that is the credential in use; see cmd/codey. | |
| 95 | + var systemPrefix string | |
| 96 | + if *claudeCodeAuth && !client.HasCredentials() && client.IsDefaultEndpoint() { | |
| 97 | + home, err := os.UserHomeDir() | |
| 98 | + if err != nil { | |
| 99 | + return err | |
| 100 | + } | |
| 101 | + creds, err := claudecode.Load(home) | |
| 102 | + if err != nil { | |
| 103 | + return fmt.Errorf("-claude-code-auth: %w", err) | |
| 104 | + } | |
| 105 | + client = llm.New(llm.WithModel(*model), llm.WithTokenSource(claudecode.NewSource(creds, nil, home).Token)) | |
| 106 | + systemPrefix = agent.ClaudeCodeIdentity | |
| 107 | + } | |
| 91 | 108 | if !client.HasCredentials() { |
| 92 | - return fmt.Errorf("no credentials: set ANTHROPIC_API_KEY") | |
| 109 | + return fmt.Errorf("no credentials: set ANTHROPIC_API_KEY, or pass -claude-code-auth") | |
| 93 | 110 | } |
| 94 | 111 | |
| 95 | 112 | stamp := time.Now().UTC().Format("20060102T150405Z") |
| @@ -129,6 +146,7 @@ func run() error { | ||
| 129 | 146 | ContextWindow: *contextWindow, |
| 130 | 147 | NoCache: *noCache, |
| 131 | 148 | Stream: !*noStream, |
| 149 | + SystemPrefix: systemPrefix, | |
| 132 | 150 | }, *timeout, *keep) |
| 133 | 151 | mu.Lock() |
| 134 | 152 | results = append(results, res) |