Files
OpenCode 68a9071cf1 feat: reconcile local master with origin (exa/hot-platform hunters, leaks ledger, latest results)
Local branch had diverged from origin/master (sibling commits on the same base). Rewrote local history linearly on top of origin/master, folding in all local content: exa/hot-platform discovery hunters, leaks ledger, nightly sweep orchestrator, updated .gitignore and skill docs, plus the latest hunt output and vault state. Remote-only files (vault keys, channel scripts) were restored rather than dropped, so the resulting tree is a full union of both sides.
2026-08-07 12:53:47 +08:00

1 line
33 KiB
JSON

{"repo": "agenvoy/agenvoy", "files": {"internal/agents/keychain/keychain.go": {"f0342502321b0f91c5644f50068c757d51e6cd8a": {"t": 1785745641.0117965, "n": 4911, "h": "5be7c2efbdbb800c", "c": "package keychain\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\tsessionConfig \"github.com/pardnchiu/agenvoy/internal/session/config\"\n\tprovider \"github.com/pardnchiu/go-llm-router/core\"\n\toauthCodex \"github.com/pardnchiu/go-llm-router/core/oauth/codex\"\n\toauthCopilot \"github.com/pardnchiu/go-llm-router/core/oauth/copilot\"\n\toauthGrok \"github.com/pardnchiu/go-llm-router/core/oauth/grok\"\n\tgo_pkg_keychain \"github.com/pardnchiu/go-pkg/filesystem/keychain\"\n)\n\nfunc Config(ctx context.Context, name string) (provider.Config, error) {\n\tproviderFull, _, _ := strings.Cut(name, \"@\")\n\tprov, _, _ := strings.Cut(providerFull, \"[\")\n\n\tswitch prov {\n\tcase \"claude\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLAUDE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLAUDE_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openai\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENAI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENAI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"gemini\":\n\t\tapiKey := go_pkg_keychain.Get(\"GEMINI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GEMINI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"grok\":\n\t\tapiKey := go_pkg_keychain.Get(\"GROK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GROK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"deepseek\":\n\t\tapiKey := go_pkg_keychain.Get(\"DEEPSEEK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: DEEPSEEK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"nvidia\":\n\t\tapiKey := go_pkg_keychain.Get(\"NVIDIA_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: NVIDIA_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openrouter\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENROUTER_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENROUTER_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"cloudflare\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLOUDFLARE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_API_KEY is required\")\n\t\t}\n\t\taccountID := go_pkg_keychain.Get(\"CLOUDFLARE_ACCOUNT_ID\")\n\t\tif accountID == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_ACCOUNT_ID is required\")\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: apiKey,\n\t\t\tAccountID: accountID,\n\t\t\tGatewayID: go_pkg_keychain.Get(\"CLOUDFLARE_GATEWAY_ID\"),\n\t\t}, nil\n\n\tcase \"compat\":\n\t\tinstanceName := \"\"\n\t\tif start := strings.Index(name, \"[\"); start != -1 {\n\t\t\tif end := strings.Index(name, \"]\"); end > start {\n\t\t\t\tinstanceName = strings.ToUpper(name[start+1 : end])\n\t\t\t}\n\t\t}\n\t\tapiKeyEnvKey := \"COMPAT_API_KEY\"\n\t\tif instanceName != \"\" {\n\t\t\tapiKeyEnvKey = \"COMPAT_\" + instanceName + \"_API_KEY\"\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: go_pkg_keychain.Get(apiKeyEnvKey),\n\t\t\tBaseURL: sessionConfig.GetCompatURL(instanceName),\n\t\t}, nil\n\n\tcase \"copilot\":\n\t\ttoken, err := oauthCopilot.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"copilot token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\trefresh, err := oauthCopilot.EnsureFreshSession(ctx, token, nil)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.EnsureFreshSession: %w\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: refresh.Token, Token: token}, nil\n\n\tcase \"codex\":\n\t\ttoken, err := oauthCodex.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCodex.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthCodex.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, AccountID: token.AccountID, Token: token}, nil\n\n\tcase \"grok-oauth\":\n\t\ttoken, err := oauthGrok.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthGrok.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthGrok.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, Token: token}, nil\n\n\tdefault:\n\t\treturn provider.Config{}, fmt.Errorf(\"credential.Resolve: unknown provider %q in %q\", prov, name)\n\t}\n}\n"}, "7d0a5622547044e6587ff7d1a2c5c51a44044593": {"t": 1785755192.8086364, "n": 4911, "h": "5be7c2efbdbb800c", "c": "package keychain\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\tsessionConfig \"github.com/pardnchiu/agenvoy/internal/session/config\"\n\tprovider \"github.com/pardnchiu/go-llm-router/core\"\n\toauthCodex \"github.com/pardnchiu/go-llm-router/core/oauth/codex\"\n\toauthCopilot \"github.com/pardnchiu/go-llm-router/core/oauth/copilot\"\n\toauthGrok \"github.com/pardnchiu/go-llm-router/core/oauth/grok\"\n\tgo_pkg_keychain \"github.com/pardnchiu/go-pkg/filesystem/keychain\"\n)\n\nfunc Config(ctx context.Context, name string) (provider.Config, error) {\n\tproviderFull, _, _ := strings.Cut(name, \"@\")\n\tprov, _, _ := strings.Cut(providerFull, \"[\")\n\n\tswitch prov {\n\tcase \"claude\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLAUDE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLAUDE_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openai\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENAI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENAI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"gemini\":\n\t\tapiKey := go_pkg_keychain.Get(\"GEMINI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GEMINI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"grok\":\n\t\tapiKey := go_pkg_keychain.Get(\"GROK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GROK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"deepseek\":\n\t\tapiKey := go_pkg_keychain.Get(\"DEEPSEEK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: DEEPSEEK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"nvidia\":\n\t\tapiKey := go_pkg_keychain.Get(\"NVIDIA_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: NVIDIA_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openrouter\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENROUTER_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENROUTER_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"cloudflare\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLOUDFLARE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_API_KEY is required\")\n\t\t}\n\t\taccountID := go_pkg_keychain.Get(\"CLOUDFLARE_ACCOUNT_ID\")\n\t\tif accountID == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_ACCOUNT_ID is required\")\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: apiKey,\n\t\t\tAccountID: accountID,\n\t\t\tGatewayID: go_pkg_keychain.Get(\"CLOUDFLARE_GATEWAY_ID\"),\n\t\t}, nil\n\n\tcase \"compat\":\n\t\tinstanceName := \"\"\n\t\tif start := strings.Index(name, \"[\"); start != -1 {\n\t\t\tif end := strings.Index(name, \"]\"); end > start {\n\t\t\t\tinstanceName = strings.ToUpper(name[start+1 : end])\n\t\t\t}\n\t\t}\n\t\tapiKeyEnvKey := \"COMPAT_API_KEY\"\n\t\tif instanceName != \"\" {\n\t\t\tapiKeyEnvKey = \"COMPAT_\" + instanceName + \"_API_KEY\"\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: go_pkg_keychain.Get(apiKeyEnvKey),\n\t\t\tBaseURL: sessionConfig.GetCompatURL(instanceName),\n\t\t}, nil\n\n\tcase \"copilot\":\n\t\ttoken, err := oauthCopilot.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"copilot token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\trefresh, err := oauthCopilot.EnsureFreshSession(ctx, token, nil)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.EnsureFreshSession: %w\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: refresh.Token, Token: token}, nil\n\n\tcase \"codex\":\n\t\ttoken, err := oauthCodex.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCodex.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthCodex.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, AccountID: token.AccountID, Token: token}, nil\n\n\tcase \"grok-oauth\":\n\t\ttoken, err := oauthGrok.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthGrok.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthGrok.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, Token: token}, nil\n\n\tdefault:\n\t\treturn provider.Config{}, fmt.Errorf(\"credential.Resolve: unknown provider %q in %q\", prov, name)\n\t}\n}\n"}, "8a13c7c265d33dd46965a2cf20fabac5206eb0e3": {"t": 1785755194.2368655, "n": 4902, "h": "e08821164871479a", "c": "package keychain\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\toauthCodex \"github.com/pardnchiu/go-llm-router/core/oauth/codex\"\n\toauthCopilot \"github.com/pardnchiu/go-llm-router/core/oauth/copilot\"\n\toauthGrok \"github.com/pardnchiu/go-llm-router/core/oauth/grok\"\n\t\"github.com/pardnchiu/go-llm-router/core\"\n\tsessionConfig \"github.com/pardnchiu/agenvoy/internal/session/config\"\n\tgo_pkg_keychain \"github.com/pardnchiu/go-pkg/filesystem/keychain\"\n)\n\nfunc Config(ctx context.Context, name string) (provider.Config, error) {\n\tproviderFull, _, _ := strings.Cut(name, \"@\")\n\tprov, _, _ := strings.Cut(providerFull, \"[\")\n\n\tswitch prov {\n\tcase \"claude\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLAUDE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLAUDE_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openai\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENAI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENAI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"gemini\":\n\t\tapiKey := go_pkg_keychain.Get(\"GEMINI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GEMINI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"grok\":\n\t\tapiKey := go_pkg_keychain.Get(\"GROK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GROK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"deepseek\":\n\t\tapiKey := go_pkg_keychain.Get(\"DEEPSEEK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: DEEPSEEK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"nvidia\":\n\t\tapiKey := go_pkg_keychain.Get(\"NVIDIA_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: NVIDIA_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openrouter\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENROUTER_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENROUTER_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"cloudflare\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLOUDFLARE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_API_KEY is required\")\n\t\t}\n\t\taccountID := go_pkg_keychain.Get(\"CLOUDFLARE_ACCOUNT_ID\")\n\t\tif accountID == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_ACCOUNT_ID is required\")\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: apiKey,\n\t\t\tAccountID: accountID,\n\t\t\tGatewayID: go_pkg_keychain.Get(\"CLOUDFLARE_GATEWAY_ID\"),\n\t\t}, nil\n\n\tcase \"compat\":\n\t\tinstanceName := \"\"\n\t\tif start := strings.Index(name, \"[\"); start != -1 {\n\t\t\tif end := strings.Index(name, \"]\"); end > start {\n\t\t\t\tinstanceName = strings.ToUpper(name[start+1 : end])\n\t\t\t}\n\t\t}\n\t\tapiKeyEnvKey := \"COMPAT_API_KEY\"\n\t\tif instanceName != \"\" {\n\t\t\tapiKeyEnvKey = \"COMPAT_\" + instanceName + \"_API_KEY\"\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: go_pkg_keychain.Get(apiKeyEnvKey),\n\t\t\tBaseURL: sessionConfig.GetCompatURL(instanceName),\n\t\t}, nil\n\n\tcase \"copilot\":\n\t\ttoken, err := oauthCopilot.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"copilot token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\trefresh, err := oauthCopilot.EnsureFreshSession(ctx, token, nil)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.EnsureFreshSession: %w\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: refresh.Token, Token: token}, nil\n\n\tcase \"codex\":\n\t\ttoken, err := oauthCodex.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCodex.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthCodex.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, AccountID: token.AccountID, Token: token}, nil\n\n\tcase \"grok-oauth\":\n\t\ttoken, err := oauthGrok.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthGrok.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthGrok.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, Token: token}, nil\n\n\tdefault:\n\t\treturn provider.Config{}, fmt.Errorf(\"credential.Resolve: unknown provider %q in %q\", prov, name)\n\t}\n}\n"}, "4175043f7fe49c9d4b31eb55fac6f0cddc3b86cc": {"t": 1785755196.6641746, "n": 4931, "h": "99b8d66a846ff748", "c": "package keychain\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\toauthCodex \"github.com/pardnchiu/agenvoy/internal/agents/oauth/codex\"\n\toauthCopilot \"github.com/pardnchiu/agenvoy/internal/agents/oauth/copilot\"\n\toauthGrok \"github.com/pardnchiu/agenvoy/internal/agents/oauth/grok\"\n\t\"github.com/pardnchiu/agenvoy/internal/agents/provider\"\n\tsessionConfig \"github.com/pardnchiu/agenvoy/internal/session/config\"\n\tgo_pkg_keychain \"github.com/pardnchiu/go-pkg/filesystem/keychain\"\n)\n\nfunc Config(ctx context.Context, name string) (provider.Config, error) {\n\tproviderFull, _, _ := strings.Cut(name, \"@\")\n\tprov, _, _ := strings.Cut(providerFull, \"[\")\n\n\tswitch prov {\n\tcase \"claude\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLAUDE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLAUDE_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openai\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENAI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENAI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"gemini\":\n\t\tapiKey := go_pkg_keychain.Get(\"GEMINI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GEMINI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"grok\":\n\t\tapiKey := go_pkg_keychain.Get(\"GROK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GROK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"deepseek\":\n\t\tapiKey := go_pkg_keychain.Get(\"DEEPSEEK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: DEEPSEEK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"nvidia\":\n\t\tapiKey := go_pkg_keychain.Get(\"NVIDIA_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: NVIDIA_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openrouter\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENROUTER_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENROUTER_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"cloudflare\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLOUDFLARE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_API_KEY is required\")\n\t\t}\n\t\taccountID := go_pkg_keychain.Get(\"CLOUDFLARE_ACCOUNT_ID\")\n\t\tif accountID == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_ACCOUNT_ID is required\")\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: apiKey,\n\t\t\tAccountID: accountID,\n\t\t\tGatewayID: go_pkg_keychain.Get(\"CLOUDFLARE_GATEWAY_ID\"),\n\t\t}, nil\n\n\tcase \"compat\":\n\t\tinstanceName := \"\"\n\t\tif start := strings.Index(name, \"[\"); start != -1 {\n\t\t\tif end := strings.Index(name, \"]\"); end > start {\n\t\t\t\tinstanceName = strings.ToUpper(name[start+1 : end])\n\t\t\t}\n\t\t}\n\t\tapiKeyEnvKey := \"COMPAT_API_KEY\"\n\t\tif instanceName != \"\" {\n\t\t\tapiKeyEnvKey = \"COMPAT_\" + instanceName + \"_API_KEY\"\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: go_pkg_keychain.Get(apiKeyEnvKey),\n\t\t\tBaseURL: sessionConfig.GetCompatURL(instanceName),\n\t\t}, nil\n\n\tcase \"copilot\":\n\t\ttoken, err := oauthCopilot.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"copilot token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\trefresh, err := oauthCopilot.EnsureFreshSession(ctx, token, nil)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.EnsureFreshSession: %w\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: refresh.Token, Token: token}, nil\n\n\tcase \"codex\":\n\t\ttoken, err := oauthCodex.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCodex.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthCodex.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, AccountID: token.AccountID, Token: token}, nil\n\n\tcase \"grok-oauth\":\n\t\ttoken, err := oauthGrok.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthGrok.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthGrok.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, Token: token}, nil\n\n\tdefault:\n\t\treturn provider.Config{}, fmt.Errorf(\"credential.Resolve: unknown provider %q in %q\", prov, name)\n\t}\n}\n"}, "8d97765cd1d420fcb0f8e12cc6373ccaa25a25aa": {"t": 1786067425.2432733, "n": 4911, "h": "5be7c2efbdbb800c", "c": "package keychain\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\tsessionConfig \"github.com/pardnchiu/agenvoy/internal/session/config\"\n\tprovider \"github.com/pardnchiu/go-llm-router/core\"\n\toauthCodex \"github.com/pardnchiu/go-llm-router/core/oauth/codex\"\n\toauthCopilot \"github.com/pardnchiu/go-llm-router/core/oauth/copilot\"\n\toauthGrok \"github.com/pardnchiu/go-llm-router/core/oauth/grok\"\n\tgo_pkg_keychain \"github.com/pardnchiu/go-pkg/filesystem/keychain\"\n)\n\nfunc Config(ctx context.Context, name string) (provider.Config, error) {\n\tproviderFull, _, _ := strings.Cut(name, \"@\")\n\tprov, _, _ := strings.Cut(providerFull, \"[\")\n\n\tswitch prov {\n\tcase \"claude\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLAUDE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLAUDE_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openai\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENAI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENAI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"gemini\":\n\t\tapiKey := go_pkg_keychain.Get(\"GEMINI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GEMINI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"grok\":\n\t\tapiKey := go_pkg_keychain.Get(\"GROK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GROK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"deepseek\":\n\t\tapiKey := go_pkg_keychain.Get(\"DEEPSEEK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: DEEPSEEK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"nvidia\":\n\t\tapiKey := go_pkg_keychain.Get(\"NVIDIA_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: NVIDIA_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openrouter\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENROUTER_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENROUTER_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"cloudflare\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLOUDFLARE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_API_KEY is required\")\n\t\t}\n\t\taccountID := go_pkg_keychain.Get(\"CLOUDFLARE_ACCOUNT_ID\")\n\t\tif accountID == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_ACCOUNT_ID is required\")\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: apiKey,\n\t\t\tAccountID: accountID,\n\t\t\tGatewayID: go_pkg_keychain.Get(\"CLOUDFLARE_GATEWAY_ID\"),\n\t\t}, nil\n\n\tcase \"compat\":\n\t\tinstanceName := \"\"\n\t\tif start := strings.Index(name, \"[\"); start != -1 {\n\t\t\tif end := strings.Index(name, \"]\"); end > start {\n\t\t\t\tinstanceName = strings.ToUpper(name[start+1 : end])\n\t\t\t}\n\t\t}\n\t\tapiKeyEnvKey := \"COMPAT_API_KEY\"\n\t\tif instanceName != \"\" {\n\t\t\tapiKeyEnvKey = \"COMPAT_\" + instanceName + \"_API_KEY\"\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: go_pkg_keychain.Get(apiKeyEnvKey),\n\t\t\tBaseURL: sessionConfig.GetCompatURL(instanceName),\n\t\t}, nil\n\n\tcase \"copilot\":\n\t\ttoken, err := oauthCopilot.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"copilot token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\trefresh, err := oauthCopilot.EnsureFreshSession(ctx, token, nil)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.EnsureFreshSession: %w\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: refresh.Token, Token: token}, nil\n\n\tcase \"codex\":\n\t\ttoken, err := oauthCodex.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCodex.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthCodex.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, AccountID: token.AccountID, Token: token}, nil\n\n\tcase \"grok-oauth\":\n\t\ttoken, err := oauthGrok.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthGrok.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthGrok.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, Token: token}, nil\n\n\tdefault:\n\t\treturn provider.Config{}, fmt.Errorf(\"credential.Resolve: unknown provider %q in %q\", prov, name)\n\t}\n}\n"}, "52ff31876c8760c8820d9412f3c1365e15943c4f": {"t": 1786068287.9938035, "n": 4911, "h": "5be7c2efbdbb800c", "c": "package keychain\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\tsessionConfig \"github.com/pardnchiu/agenvoy/internal/session/config\"\n\tprovider \"github.com/pardnchiu/go-llm-router/core\"\n\toauthCodex \"github.com/pardnchiu/go-llm-router/core/oauth/codex\"\n\toauthCopilot \"github.com/pardnchiu/go-llm-router/core/oauth/copilot\"\n\toauthGrok \"github.com/pardnchiu/go-llm-router/core/oauth/grok\"\n\tgo_pkg_keychain \"github.com/pardnchiu/go-pkg/filesystem/keychain\"\n)\n\nfunc Config(ctx context.Context, name string) (provider.Config, error) {\n\tproviderFull, _, _ := strings.Cut(name, \"@\")\n\tprov, _, _ := strings.Cut(providerFull, \"[\")\n\n\tswitch prov {\n\tcase \"claude\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLAUDE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLAUDE_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openai\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENAI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENAI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"gemini\":\n\t\tapiKey := go_pkg_keychain.Get(\"GEMINI_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GEMINI_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"grok\":\n\t\tapiKey := go_pkg_keychain.Get(\"GROK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: GROK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"deepseek\":\n\t\tapiKey := go_pkg_keychain.Get(\"DEEPSEEK_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: DEEPSEEK_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"nvidia\":\n\t\tapiKey := go_pkg_keychain.Get(\"NVIDIA_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: NVIDIA_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"openrouter\":\n\t\tapiKey := go_pkg_keychain.Get(\"OPENROUTER_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: OPENROUTER_API_KEY is required\")\n\t\t}\n\t\treturn provider.Config{APIKey: apiKey}, nil\n\n\tcase \"cloudflare\":\n\t\tapiKey := go_pkg_keychain.Get(\"CLOUDFLARE_API_KEY\")\n\t\tif apiKey == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_API_KEY is required\")\n\t\t}\n\t\taccountID := go_pkg_keychain.Get(\"CLOUDFLARE_ACCOUNT_ID\")\n\t\tif accountID == \"\" {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"keychain.Get: CLOUDFLARE_ACCOUNT_ID is required\")\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: apiKey,\n\t\t\tAccountID: accountID,\n\t\t\tGatewayID: go_pkg_keychain.Get(\"CLOUDFLARE_GATEWAY_ID\"),\n\t\t}, nil\n\n\tcase \"compat\":\n\t\tinstanceName := \"\"\n\t\tif start := strings.Index(name, \"[\"); start != -1 {\n\t\t\tif end := strings.Index(name, \"]\"); end > start {\n\t\t\t\tinstanceName = strings.ToUpper(name[start+1 : end])\n\t\t\t}\n\t\t}\n\t\tapiKeyEnvKey := \"COMPAT_API_KEY\"\n\t\tif instanceName != \"\" {\n\t\t\tapiKeyEnvKey = \"COMPAT_\" + instanceName + \"_API_KEY\"\n\t\t}\n\t\treturn provider.Config{\n\t\t\tAPIKey: go_pkg_keychain.Get(apiKeyEnvKey),\n\t\t\tBaseURL: sessionConfig.GetCompatURL(instanceName),\n\t\t}, nil\n\n\tcase \"copilot\":\n\t\ttoken, err := oauthCopilot.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"copilot token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\trefresh, err := oauthCopilot.EnsureFreshSession(ctx, token, nil)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCopilot.EnsureFreshSession: %w\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: refresh.Token, Token: token}, nil\n\n\tcase \"codex\":\n\t\ttoken, err := oauthCodex.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthCodex.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthCodex.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"codex token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, AccountID: token.AccountID, Token: token}, nil\n\n\tcase \"grok-oauth\":\n\t\ttoken, err := oauthGrok.Load()\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"oauthGrok.Load: %w\", err)\n\t\t}\n\t\tif token == nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token missing; run `agen model add` to authenticate\")\n\t\t}\n\t\ttoken, err = oauthGrok.EnsureFresh(ctx, token)\n\t\tif err != nil {\n\t\t\treturn provider.Config{}, fmt.Errorf(\"grok-oauth token expired and refresh failed: %w; run `agen model add` to re-authenticate\", err)\n\t\t}\n\t\treturn provider.Config{APIKey: token.AccessToken, Token: token}, nil\n\n\tdefault:\n\t\treturn provider.Config{}, fmt.Errorf(\"credential.Resolve: unknown provider %q in %q\", prov, name)\n\t}\n}\n"}}}}