opencode-google-auth 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-google-auth",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "_description_",
5
5
  "keywords": [
6
6
  "opencode-google-auth"
@@ -28,7 +28,7 @@
28
28
  "scripts": {
29
29
  "deploy": "bun build ./src/main.ts --target bun --outfile .opencode/plugin/opencode-google-auth.js",
30
30
  "format": "prettier --write .",
31
- "lint": "oxlint",
31
+ "lint": "oxlint --type-aware",
32
32
  "release": "bumpp && npm publish",
33
33
  "typecheck": "tsgo"
34
34
  },
package/src/main.ts CHANGED
@@ -172,112 +172,112 @@ export const geminiCli: Plugin = async (context) => {
172
172
  }
173
173
  }
174
174
 
175
- // export const antigravity: Plugin = async (context) => {
176
- // const runtime = makeRuntime({
177
- // openCodeCtx: context,
178
- // providerConfig: antigravityConfig(),
179
- // })
180
-
181
- // const config = await runtime.runPromise(
182
- // Effect.gen(function* () {
183
- // const providerConfig = yield* ProviderConfig
184
- // const modelsDev = yield* fetchModelsDev
185
-
186
- // return providerConfig.getConfig(modelsDev)
187
- // }),
188
- // )
189
-
190
- // return {
191
- // config: async (cfg) => {
192
- // cfg.provider ??= {}
193
- // cfg.provider[config.id as string] = config
194
- // },
195
- // auth: {
196
- // provider: config.id as string,
197
- // loader: async (getAuth) => {
198
- // const auth = await getAuth()
199
- // if (auth.type !== "oauth") return {}
200
-
201
- // const credentials: Credentials = {
202
- // access_token: auth.access,
203
- // refresh_token: auth.refresh,
204
- // expiry_date: auth.expires,
205
- // }
206
-
207
- // await runtime.runPromise(
208
- // Effect.gen(function* () {
209
- // const session = yield* Session
210
- // yield* session.setCredentials(credentials)
211
- // }),
212
- // )
213
-
214
- // return {
215
- // apiKey: "",
216
- // fetch: (async (input, init) => {
217
- // const response = await runtime.runPromise(customFetch(input, init))
218
- // return response
219
- // }) as typeof fetch,
220
- // } satisfies GoogleGenerativeAIProviderSettings
221
- // },
222
- // methods: [
223
- // {
224
- // type: "oauth",
225
- // label: "OAuth with Google",
226
- // authorize: async () => {
227
- // const result = await runtime.runPromise(
228
- // Effect.gen(function* () {
229
- // const oauth = yield* OAuth
230
- // return yield* oauth.authenticate
231
- // }),
232
- // )
233
-
234
- // return {
235
- // url: "",
236
- // method: "auto",
237
- // instructions: "You are now authenticated!",
238
- // callback: async () => {
239
- // const accessToken = result.access_token
240
- // const refreshToken = result.refresh_token
241
- // const expiryDate = result.expiry_date
242
-
243
- // if (!accessToken || !refreshToken || !expiryDate) {
244
- // return { type: "failed" }
245
- // }
246
-
247
- // return {
248
- // type: "success",
249
- // provider: config.id as string,
250
- // access: accessToken,
251
- // refresh: refreshToken,
252
- // expires: expiryDate,
253
- // }
254
- // },
255
- // }
256
- // },
257
- // },
258
- // ],
259
- // },
260
- // "experimental.chat.system.transform": async (_input, output) => {
261
- // // THIS IS REQUIRED OTHERWISE YOU'LL GET 429 OR 403 FOR SOME GODDAMN REASON
262
- // output.system.unshift(antigravitySpoof)
263
- // },
264
- // "chat.params": async (input, output) => {
265
- // await runtime.runPromise(
266
- // Effect.log("chat.params event before:", input.model, output.options),
267
- // )
268
-
269
- // if (input.model.providerID === config.id) {
270
- // output.options = {
271
- // ...output.options,
272
- // labels: {
273
- // sessionId: input.sessionID,
274
- // },
275
- // } satisfies GoogleGenerativeAIProviderOptions
276
- // }
277
-
278
- // await runtime.runPromise(
279
- // Effect.log("chat.params event after:", input.model, output.options),
280
- // )
281
- // },
282
- // }
283
- // }
175
+ export const antigravity: Plugin = async (context) => {
176
+ const runtime = makeRuntime({
177
+ openCodeCtx: context,
178
+ providerConfig: antigravityConfig(),
179
+ })
180
+
181
+ const config = await runtime.runPromise(
182
+ Effect.gen(function* () {
183
+ const providerConfig = yield* ProviderConfig
184
+ const modelsDev = yield* fetchModelsDev
185
+
186
+ return providerConfig.getConfig(modelsDev)
187
+ }),
188
+ )
189
+
190
+ return {
191
+ config: async (cfg) => {
192
+ cfg.provider ??= {}
193
+ cfg.provider[config.id as string] = config
194
+ },
195
+ auth: {
196
+ provider: config.id as string,
197
+ loader: async (getAuth) => {
198
+ const auth = await getAuth()
199
+ if (auth.type !== "oauth") return {}
200
+
201
+ const credentials: Credentials = {
202
+ access_token: auth.access,
203
+ refresh_token: auth.refresh,
204
+ expiry_date: auth.expires,
205
+ }
206
+
207
+ await runtime.runPromise(
208
+ Effect.gen(function* () {
209
+ const session = yield* Session
210
+ yield* session.setCredentials(credentials)
211
+ }),
212
+ )
213
+
214
+ return {
215
+ apiKey: "",
216
+ fetch: (async (input, init) => {
217
+ const response = await runtime.runPromise(customFetch(input, init))
218
+ return response
219
+ }) as typeof fetch,
220
+ } satisfies GoogleGenerativeAIProviderSettings
221
+ },
222
+ methods: [
223
+ {
224
+ type: "oauth",
225
+ label: "OAuth with Google",
226
+ authorize: async () => {
227
+ const result = await runtime.runPromise(
228
+ Effect.gen(function* () {
229
+ const oauth = yield* OAuth
230
+ return yield* oauth.authenticate
231
+ }),
232
+ )
233
+
234
+ return {
235
+ url: "",
236
+ method: "auto",
237
+ instructions: "You are now authenticated!",
238
+ callback: async () => {
239
+ const accessToken = result.access_token
240
+ const refreshToken = result.refresh_token
241
+ const expiryDate = result.expiry_date
242
+
243
+ if (!accessToken || !refreshToken || !expiryDate) {
244
+ return { type: "failed" }
245
+ }
246
+
247
+ return {
248
+ type: "success",
249
+ provider: config.id as string,
250
+ access: accessToken,
251
+ refresh: refreshToken,
252
+ expires: expiryDate,
253
+ }
254
+ },
255
+ }
256
+ },
257
+ },
258
+ ],
259
+ },
260
+ "experimental.chat.system.transform": async (_input, output) => {
261
+ // THIS IS REQUIRED OTHERWISE YOU'LL GET 429 OR 403 FOR SOME GODDAMN REASON
262
+ output.system.unshift(antigravitySpoof)
263
+ },
264
+ "chat.params": async (input, output) => {
265
+ await runtime.runPromise(
266
+ Effect.log("chat.params event before:", input.model, output.options),
267
+ )
268
+
269
+ if (input.model.providerID === config.id) {
270
+ output.options = {
271
+ ...output.options,
272
+ labels: {
273
+ sessionId: input.sessionID,
274
+ },
275
+ } satisfies GoogleGenerativeAIProviderOptions
276
+ }
277
+
278
+ await runtime.runPromise(
279
+ Effect.log("chat.params event after:", input.model, output.options),
280
+ )
281
+ },
282
+ }
283
+ }
@@ -181,66 +181,66 @@ export const antigravityConfig = (): ProviderConfigShape => ({
181
181
  },
182
182
  } satisfies GoogleGenerativeAIProviderOptions,
183
183
  },
184
- "claude-sonnet-4-5": {
185
- ...claudeSonnet,
186
- id: "claude-sonnet-4-5",
187
- reasoning: false,
188
- options: {
189
- thinkingConfig: {
190
- includeThoughts: false,
191
- },
192
- } satisfies GoogleGenerativeAIProviderOptions,
193
- },
194
- "claude-sonnet-4-5-thinking": {
195
- ...claudeSonnet,
196
- id: "claude-sonnet-4-5-thinking",
197
- name: "Claude Sonnet 4.5 (Thinking)",
198
- options: {
199
- thinkingConfig: {
200
- includeThoughts: true,
201
- thinkingBudget: 31999,
202
- },
203
- } satisfies GoogleGenerativeAIProviderOptions,
204
- variants: {
205
- high: {
206
- thinkingConfig: {
207
- includeThoughts: true,
208
- thinkingBudget: 16000,
209
- },
210
- } satisfies GoogleGenerativeAIProviderOptions,
211
- max: {
212
- thinkingConfig: {
213
- includeThoughts: true,
214
- thinkingBudget: 31999,
215
- },
216
- } satisfies GoogleGenerativeAIProviderOptions,
217
- },
218
- },
219
- "claude-opus-4-5-thinking": {
220
- ...claudeOpus,
221
- id: "claude-opus-4-5-thinking",
222
- name: "Claude Opus 4.5 (Thinking)",
223
- options: {
224
- thinkingConfig: {
225
- includeThoughts: true,
226
- thinkingBudget: 31999,
227
- },
228
- } satisfies GoogleGenerativeAIProviderOptions,
229
- variants: {
230
- high: {
231
- thinkingConfig: {
232
- includeThoughts: true,
233
- thinkingBudget: 16000,
234
- },
235
- } satisfies GoogleGenerativeAIProviderOptions,
236
- max: {
237
- thinkingConfig: {
238
- includeThoughts: true,
239
- thinkingBudget: 31999,
240
- },
241
- } satisfies GoogleGenerativeAIProviderOptions,
242
- },
243
- },
184
+ // "claude-sonnet-4-5": {
185
+ // ...claudeSonnet,
186
+ // id: "claude-sonnet-4-5",
187
+ // reasoning: false,
188
+ // options: {
189
+ // thinkingConfig: {
190
+ // includeThoughts: false,
191
+ // },
192
+ // } satisfies GoogleGenerativeAIProviderOptions,
193
+ // },
194
+ // "claude-sonnet-4-5-thinking": {
195
+ // ...claudeSonnet,
196
+ // id: "claude-sonnet-4-5-thinking",
197
+ // name: "Claude Sonnet 4.5 (Thinking)",
198
+ // options: {
199
+ // thinkingConfig: {
200
+ // includeThoughts: true,
201
+ // thinkingBudget: 31999,
202
+ // },
203
+ // } satisfies GoogleGenerativeAIProviderOptions,
204
+ // variants: {
205
+ // high: {
206
+ // thinkingConfig: {
207
+ // includeThoughts: true,
208
+ // thinkingBudget: 16000,
209
+ // },
210
+ // } satisfies GoogleGenerativeAIProviderOptions,
211
+ // max: {
212
+ // thinkingConfig: {
213
+ // includeThoughts: true,
214
+ // thinkingBudget: 31999,
215
+ // },
216
+ // } satisfies GoogleGenerativeAIProviderOptions,
217
+ // },
218
+ // },
219
+ // "claude-opus-4-5-thinking": {
220
+ // ...claudeOpus,
221
+ // id: "claude-opus-4-5-thinking",
222
+ // name: "Claude Opus 4.5 (Thinking)",
223
+ // options: {
224
+ // thinkingConfig: {
225
+ // includeThoughts: true,
226
+ // thinkingBudget: 31999,
227
+ // },
228
+ // } satisfies GoogleGenerativeAIProviderOptions,
229
+ // variants: {
230
+ // high: {
231
+ // thinkingConfig: {
232
+ // includeThoughts: true,
233
+ // thinkingBudget: 16000,
234
+ // },
235
+ // } satisfies GoogleGenerativeAIProviderOptions,
236
+ // max: {
237
+ // thinkingConfig: {
238
+ // includeThoughts: true,
239
+ // thinkingBudget: 31999,
240
+ // },
241
+ // } satisfies GoogleGenerativeAIProviderOptions,
242
+ // },
243
+ // },
244
244
  }
245
245
 
246
246
  return {
@@ -280,6 +280,25 @@ export const antigravityConfig = (): ProviderConfigShape => ({
280
280
  const isThinking = body.model.toLowerCase().includes("thinking")
281
281
 
282
282
  if (isClaude && body.request && typeof body.request === "object") {
283
+ const request = body.request as Record<string, unknown>
284
+ const tools = request.tools as
285
+ | Array<{ functionDeclarations?: Array<{ parameters?: unknown }> }>
286
+ | undefined
287
+ if (tools && Array.isArray(tools)) {
288
+ for (const tool of tools) {
289
+ if (
290
+ tool.functionDeclarations
291
+ && Array.isArray(tool.functionDeclarations)
292
+ ) {
293
+ for (const func of tool.functionDeclarations) {
294
+ if (!func.parameters) {
295
+ func.parameters = { type: "object", properties: {} }
296
+ }
297
+ }
298
+ }
299
+ }
300
+ }
301
+
283
302
  innerRequest.toolConfig = {
284
303
  functionCallingConfig: {
285
304
  mode: "VALIDATED",