Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/boltrunner/gcli2api
/ functions
Functions
96 in github.com/boltrunner/gcli2api
⨍
Functions
96
◇
Types & classes
37
↓ 14 callers
Function
NewCaClient
(httpClient *http.Client, transportRetries int, baseDelay time.Duration)
internal/codeassist/client.go:48
↓ 12 callers
Function
mkClient
(rt http.RoundTripper)
internal/codeassist/client_test.go:18
↓ 10 callers
Function
resp
(status int, body string, ct string)
internal/codeassist/client_test.go:22
↓ 8 callers
Function
NewMultiClient
NewMultiClient constructs a MultiClient. It does not perform network calls. projectMap maps expanded credential paths to ordered project IDs to use.
internal/codeassist/multiclient.go:60
↓ 8 callers
Function
run_command
Run a command and return the result.
scripts/release.py:22
↓ 5 callers
Method
Close
Close closes the underlying DB if present.
internal/state/state.go:79
↓ 4 callers
Function
ExpandUser
(path string)
internal/utils/utils.go:49
↓ 3 callers
Method
Close
()
internal/codeassist/multiclient_test.go:210
↓ 3 callers
Method
GenerateContent
(ctx context.Context, model, project string, req gemini.GeminiRequest)
internal/codeassist/multiclient.go:145
↓ 3 callers
Function
NormalizeGeminiRequest
NormalizeGeminiRequest ensures roles are present.
internal/gemini/normalize.go:8
↓ 3 callers
Method
Validate
(cfgPath string)
internal/config/config.go:130
↓ 3 callers
Method
displayName
()
internal/codeassist/multiclient.go:296
↓ 2 callers
Method
Flush
()
internal/server/server_test.go:54
↓ 2 callers
Method
GenerateContent
(ctx context.Context, model, project string, req gemini.GeminiRequest)
internal/server/server.go:30
↓ 2 callers
Method
GenerateContentStream
(ctx context.Context, model, project string, req gemini.GeminiRequest)
internal/codeassist/multiclient.go:185
↓ 2 callers
Method
GenerateContentStream
(ctx context.Context, model, project string, req gemini.GeminiRequest)
internal/server/server.go:31
↓ 2 callers
Function
LoadConfig
(path string)
internal/config/config.go:47
↓ 2 callers
Function
LoadRawTokenFromFile
Single-file helper retained for callers to load per-path tokens. LoadRawTokenFromFile loads a RawToken from a single JSON file path (with ~ expansion)
internal/auth/auth.go:55
↓ 2 callers
Function
NewPersistingTokenSource
(base oauth2.TokenSource, initial RawToken, path string, persist bool)
internal/auth/auth.go:80
↓ 2 callers
Function
NewWithCAClient
NewWithCAClient allows injecting a custom CodeAssist client (for tests).
internal/server/server.go:65
↓ 2 callers
Method
ToOAuth2Token
()
internal/auth/auth.go:25
↓ 2 callers
Method
Token
()
internal/auth/auth_test.go:50
↓ 2 callers
Function
WithRetries
WithRetries runs fn with exponential backoff w/ jitter.
internal/httpx/httpx.go:53
↓ 2 callers
Method
authorize
(r *http.Request)
internal/server/server.go:97
↓ 2 callers
Function
computeDelay
computeBackoffDelay helper for tests by wrapping WithRetries timing via injection isn't trivial. Instead, check deterministic bounds with a fake RNG v
internal/httpx/httpx_test.go:12
↓ 2 callers
Function
countRequestTokens
countRequestTokens approximates the total token count for the request by summing tokens of all text parts in systemInstruction and contents using tikt
internal/server/server.go:293
↓ 2 callers
Method
decodeGeminiRequest
(r *http.Request)
internal/server/server.go:159
↓ 2 callers
Method
doJSON
doJSON posts JSON to ":<method>" and decodes the JSON response into out.
internal/codeassist/client.go:333
↓ 2 callers
Method
getOrDiscoverProjectID
(ctx context.Context, e *entry)
internal/codeassist/multiclient.go:311
↓ 2 callers
Function
isRetryable
isRetryable determines if an error should trigger rotation/retry. It treats HTTP 401, 403, 429, and all 5xx as retryable, as well as common transport
internal/codeassist/multiclient.go:344
↓ 2 callers
Function
listModels
()
internal/server/server.go:331
↓ 2 callers
Method
pickStart
()
internal/codeassist/multiclient.go:131
↓ 2 callers
Method
validateModel
(model string)
internal/server/server.go:155
↓ 1 callers
Function
ComputeTokenKey
ComputeTokenKey returns a stable digest for a credential identity.
internal/state/state.go:126
↓ 1 callers
Method
DiscoverProjectID
DiscoverProjectID attempts to derive the Google Cloud project ID to use with Code Assist when none is provided. It mirrors the Node implementation: 1)
internal/codeassist/client.go:248
↓ 1 callers
Method
GenerateContent
(ctx context.Context, model, project string, req gemini.GeminiRequest)
internal/codeassist/client.go:52
↓ 1 callers
Method
GenerateContentStream
StreamClient returns a channel of responses and an error channel.
internal/codeassist/client.go:90
↓ 1 callers
Method
GetProjectID
GetProjectID returns the project id for tokenKey, and whether it was found.
internal/state/state.go:90
↓ 1 callers
Method
GetRRCounter
GetRRCounter returns the persisted round-robin counter for a (provider, clientID). ok == false indicates not found.
internal/state/state.go:133
↓ 1 callers
Function
IsSupportedModel
IsSupportedModel reports whether the given model name is supported.
internal/gemini/models.go:18
↓ 1 callers
Function
NewOAuthHTTPClient
NewOAuthHTTPClient creates an *http.Client with OAuth2 transport. If proxyURL is non-nil, it is used as the upstream proxy. Supported schemes: http, s
internal/httpx/httpx.go:17
↓ 1 callers
Function
Open
Open opens a SQLite database at path and ensures schema. If opening fails, a memory-only store is returned with db == nil.
internal/state/state.go:28
↓ 1 callers
Method
Router
()
internal/server/server.go:82
↓ 1 callers
Function
SaveRawTokenAtomic
(path string, rt RawToken)
internal/auth/auth.go:104
↓ 1 callers
Method
SetRRCounter
SetRRCounter upserts the round-robin counter for (provider, clientID).
internal/state/state.go:153
↓ 1 callers
Method
Token
()
internal/auth/auth.go:84
↓ 1 callers
Method
UpsertProjectID
UpsertProjectID stores or updates the mapping for tokenKey.
internal/state/state.go:111
↓ 1 callers
Method
WriteHeader
(code int)
internal/server/middleware.go:16
↓ 1 callers
Function
calculate_sha256
Calculate SHA256 hash of a file.
scripts/release.py:41
↓ 1 callers
Function
cli
Release automation for gcli2api project.
scripts/release.py:51
↓ 1 callers
Function
fromOAuth2Token
(tok *oauth2.Token, prev RawToken)
internal/auth/auth.go:34
↓ 1 callers
Method
handleGenerateContent
(model string, w http.ResponseWriter, r *http.Request)
internal/server/server.go:169
↓ 1 callers
Method
handleModel
(w http.ResponseWriter, r *http.Request)
internal/server/server.go:132
↓ 1 callers
Method
handleStreamGenerateContent
(model string, w http.ResponseWriter, r *http.Request)
internal/server/server.go:203
↓ 1 callers
Function
httpStatusFromError
(err error)
internal/server/server.go:313
↓ 1 callers
Method
init
(db *sql.DB)
internal/state/state.go:53
↓ 1 callers
Function
parseSSEStream
parseSSEStream is a local minimal SSE parser to avoid extra imports.
internal/codeassist/client.go:149
↓ 1 callers
Function
truncateLongStringInImpl
TruncateLongStringInObject recursively truncates long strings in a JSON-like object. It mimics the Python function truncate_long_strings_in_object.
internal/utils/utils.go:12
↓ 1 callers
Method
withConcurrencyLimit
withConcurrencyLimit adds simple server-wide concurrency limiting.
internal/server/middleware.go:57
↓ 1 callers
Method
withLogging
(next http.Handler)
internal/server/middleware.go:28
↓ 1 callers
Method
withRecover
withRecover adds a panic recovery layer to prevent leaking stack traces and to ensure a clean 500 response is sent to the client.
internal/server/middleware.go:43
Method
Close
()
internal/codeassist/multiclient_test.go:227
Function
EnsureFresh
Helper to force-refresh a token if it's near expiry in the next N minutes.
internal/auth/auth.go:137
Method
Flush
Flush implements http.Flusher by forwarding to the underlying ResponseWriter
internal/server/middleware.go:22
Method
GenerateContent
(ctx context.Context, model, project string, req gemini.GeminiRequest)
internal/server/server_test.go:20
Method
GenerateContentStream
(ctx context.Context, model, project string, req gemini.GeminiRequest)
internal/server/server_test.go:27
Method
MarshalJSON
MarshalJSON implements custom JSON marshaling for GeminiRequest to include unknown fields in the output
internal/gemini/types.go:140
Function
New
(cfg config.Config, httpCli *http.Client)
internal/server/server.go:42
Method
Read
(p []byte)
internal/codeassist/multiclient_test.go:209
Method
Read
(p []byte)
internal/codeassist/multiclient_test.go:218
Method
RoundTrip
(r *http.Request)
internal/codeassist/client_test.go:16
Function
TestBackoff_JitterBounds
(t *testing.T)
internal/httpx/httpx_test.go:18
Function
TestClient_Unary_NoInternalRetry
(t *testing.T)
internal/codeassist/client_test.go:29
Function
TestConfig_ProjectIds_UnknownKey_Fails
(t *testing.T)
internal/config/config_test.go:5
Function
TestGeminiRequest_UnknownFields
(t *testing.T)
internal/gemini/normalize_test.go:31
Function
TestGenerationConfig_passthrough
System prompt from file feature removed; no tests required.
internal/gemini/normalize_test.go:23
Function
TestHandler_FlushBehavior
(t *testing.T)
internal/server/server_test.go:56
Function
TestListModels_shape
(t *testing.T)
internal/server/server_test.go:41
Function
TestMultiClient_EmptyProjectList_FallsBackToDiscovery
(t *testing.T)
internal/codeassist/multiclient_test.go:189
Function
TestMultiClient_ProjectUnits_AutoOnly
When projectIds is ["_auto"] only, we include just one discovery-based unit.
internal/codeassist/multiclient_test.go:167
Function
TestMultiClient_ProjectUnits_RoundRobin
New behavior: per-credential project units and rotation across them.
internal/codeassist/multiclient_test.go:83
Function
TestMultiClient_ProjectUnits_WithAuto_DiscoveryIncluded
When projectIds includes the special token "_auto", include a discovery-based unit in addition to any explicit project ids.
internal/codeassist/multiclient_test.go:134
Function
TestMultiClient_RotationPolicy_Unary
Focused test: rotation behavior on 401 vs 500.
internal/codeassist/multiclient_test.go:19
Function
TestMultiClient_StreamRotation_BeforeFirstEvent
(t *testing.T)
internal/codeassist/multiclient_test.go:229
Function
TestMultiClient_Stream_NoRotation_AfterFirstEvent
(t *testing.T)
internal/codeassist/multiclient_test.go:265
Function
TestNormalizeRoles_DefaultsOnly
(t *testing.T)
internal/gemini/normalize_test.go:8
Function
TestStream_SSEParse_Success
(t *testing.T)
internal/codeassist/client_test.go:45
Function
TestTokenLoadAndRefreshShape
(t *testing.T)
internal/auth/auth_test.go:13
Function
TestWithRetries_StopsAfterMax
(t *testing.T)
internal/httpx/httpx_test.go:32
Function
TruncateLongStringInObject
(v any, n int)
internal/utils/utils.go:36
Method
UnmarshalJSON
UnmarshalJSON implements custom JSON unmarshaling for GeminiRequest to capture unknown fields while preserving known ones
internal/gemini/types.go:88
Function
build_release
Build cross-platform binaries for release.
scripts/release.py:59
Method
handleHealth
(w http.ResponseWriter, r *http.Request)
internal/server/server.go:91
Method
handleListModels
(w http.ResponseWriter, r *http.Request)
internal/server/server.go:119
Function
main
()
main.go:32
Function
upload_release
Create or update GitHub release and upload assets.
scripts/release.py:134