-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGemini-cli-api.lua.cfg
More file actions
73 lines (65 loc) · 2.53 KB
/
Gemini-cli-api.lua.cfg
File metadata and controls
73 lines (65 loc) · 2.53 KB
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
name = "Gemini CLI API"
local U = ...
if not U.restapi then return end
local GeminiCLI = U.restapi.GoogleInternal:class("GeminiCLI", {
client_id="681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com",
client_secret="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",
--https://github.com/google-gemini/gemini-cli/pull/14865
--https://geminicli.com/docs/changelogs/
headers={ ["User-Agent"]="GeminiCLI/0.24.0/gemini-pro (windows; amd64)" }, --npm view @google/gemini-cli version
models=function(self)
local response, meta = self:request("POST", ":retrieveUserQuota", {project=self.project})
if response then
if type(response)=="table" then
return response.buckets
end
meta.data = response
end
return nil, meta
end
})
local applyParams = _import("Gemini.lua.cfg", GeminiCLI)
if not applyParams then return end
url = "https://github.com/google-gemini/gemini-cli#option-1-login-with-google-oauth-login-using-your-google-account"
--https://geminicli.com/docs/quota-and-pricing/#free-usage
--https://developers.google.com/gemini-code-assist/resources/quotas#quotas-for-agent-mode-gemini-cli
--https://github.com/google-gemini/gemini-cli/blob/main/docs/quota-and-pricing.md#log-in-with-google-gemini-code-assist-for-individuals
predefined.api_base = {
"",
"https://daily-cloudcode-pa.sandbox.googleapis.com/v1internal",
"https://autopush-cloudcode-pa.sandbox.googleapis.com/v1internal",
"https://cloudcode-pa.googleapis.com/v1internal",
}
predefined.api_key = nil
local HOME = win.GetEnv(_isWindows and "USERPROFILE" or "HOME")
local oauth_creds = _pathjoin(HOME, ".gemini", "oauth_creds.json")
if win.GetFileInfo(oauth_creds) then
pcall(function()
for line in io.lines(oauth_creds) do
local refresh_token = line:match'"refresh_token": "(.-)"'
if refresh_token then
predefined.api_key = refresh_token
break
end
end
end)
end
--https://github.com/google-gemini/gemini-cli/blob/main/packages/core/src/config/models.ts
predefined.model = "gemini-2.5-flash"
return applyParams,
function (data) -- getModels
local client = GeminiCLI(data.apikey, nil)
local models = assert(client:models())
models.keyId = "modelId"
return models
end,
function () --authFn
local _export = {json=U.json, openUrl=U.utils.openUrl}
local oauth = U.utils.loadMoon("oauth_google.moon.1", _export) "oauth_google"
local title,msg = "Authorization",nil
return oauth("gemini_cli", function(line)
msg = msg and msg.."\n" or ""
msg = msg..line
far.Message(msg,title,"","l")
end)
end