antigravity-auth 1.6.0 → 1.7.0

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.
Files changed (258) hide show
  1. package/README.md +79 -41
  2. package/dist/cli.js +2868 -0
  3. package/dist/handler.js +25119 -0
  4. package/dist/index.js +25110 -5
  5. package/package.json +66 -54
  6. package/dist/antigravity/oauth.d.ts +0 -30
  7. package/dist/antigravity/oauth.js +0 -170
  8. package/dist/claude/login.d.ts +0 -7
  9. package/dist/claude/login.js +0 -480
  10. package/dist/claude/menu-helpers.d.ts +0 -22
  11. package/dist/claude/menu-helpers.js +0 -281
  12. package/dist/claude/proxy-manager.d.ts +0 -11
  13. package/dist/claude/proxy-manager.js +0 -129
  14. package/dist/claude/proxy.d.ts +0 -1
  15. package/dist/claude/proxy.js +0 -733
  16. package/dist/constants.d.ts +0 -138
  17. package/dist/constants.js +0 -216
  18. package/dist/hooks/auto-update-checker/cache.d.ts +0 -2
  19. package/dist/hooks/auto-update-checker/cache.js +0 -70
  20. package/dist/hooks/auto-update-checker/checker.d.ts +0 -15
  21. package/dist/hooks/auto-update-checker/checker.js +0 -233
  22. package/dist/hooks/auto-update-checker/constants.d.ts +0 -8
  23. package/dist/hooks/auto-update-checker/constants.js +0 -22
  24. package/dist/hooks/auto-update-checker/index.d.ts +0 -33
  25. package/dist/hooks/auto-update-checker/index.js +0 -121
  26. package/dist/hooks/auto-update-checker/logging.d.ts +0 -2
  27. package/dist/hooks/auto-update-checker/logging.js +0 -8
  28. package/dist/hooks/auto-update-checker/types.d.ts +0 -24
  29. package/dist/hooks/auto-update-checker/types.js +0 -1
  30. package/dist/index.d.ts +0 -6
  31. package/dist/opencode/hooks/auto-update-checker/cache.d.ts +0 -2
  32. package/dist/opencode/hooks/auto-update-checker/cache.js +0 -70
  33. package/dist/opencode/hooks/auto-update-checker/checker.d.ts +0 -15
  34. package/dist/opencode/hooks/auto-update-checker/checker.js +0 -233
  35. package/dist/opencode/hooks/auto-update-checker/constants.d.ts +0 -8
  36. package/dist/opencode/hooks/auto-update-checker/constants.js +0 -22
  37. package/dist/opencode/hooks/auto-update-checker/index.d.ts +0 -33
  38. package/dist/opencode/hooks/auto-update-checker/index.js +0 -121
  39. package/dist/opencode/hooks/auto-update-checker/logging.d.ts +0 -2
  40. package/dist/opencode/hooks/auto-update-checker/logging.js +0 -8
  41. package/dist/opencode/hooks/auto-update-checker/types.d.ts +0 -24
  42. package/dist/opencode/hooks/auto-update-checker/types.js +0 -1
  43. package/dist/opencode/plugin.d.ts +0 -29
  44. package/dist/opencode/plugin.js +0 -2954
  45. package/dist/plugin/accounts.d.ts +0 -173
  46. package/dist/plugin/accounts.js +0 -966
  47. package/dist/plugin/auth.d.ts +0 -20
  48. package/dist/plugin/auth.js +0 -44
  49. package/dist/plugin/cache/index.d.ts +0 -4
  50. package/dist/plugin/cache/index.js +0 -4
  51. package/dist/plugin/cache/signature-cache.d.ts +0 -110
  52. package/dist/plugin/cache/signature-cache.js +0 -347
  53. package/dist/plugin/cache.d.ts +0 -43
  54. package/dist/plugin/cache.js +0 -180
  55. package/dist/plugin/cli.d.ts +0 -26
  56. package/dist/plugin/cli.js +0 -126
  57. package/dist/plugin/config/index.d.ts +0 -15
  58. package/dist/plugin/config/index.js +0 -15
  59. package/dist/plugin/config/loader.d.ts +0 -38
  60. package/dist/plugin/config/loader.js +0 -150
  61. package/dist/plugin/config/models.d.ts +0 -26
  62. package/dist/plugin/config/models.js +0 -95
  63. package/dist/plugin/config/schema.d.ts +0 -144
  64. package/dist/plugin/config/schema.js +0 -458
  65. package/dist/plugin/config/updater.d.ts +0 -76
  66. package/dist/plugin/config/updater.js +0 -205
  67. package/dist/plugin/core/streaming/index.d.ts +0 -2
  68. package/dist/plugin/core/streaming/index.js +0 -2
  69. package/dist/plugin/core/streaming/transformer.d.ts +0 -9
  70. package/dist/plugin/core/streaming/transformer.js +0 -301
  71. package/dist/plugin/core/streaming/types.d.ts +0 -28
  72. package/dist/plugin/core/streaming/types.js +0 -1
  73. package/dist/plugin/debug.d.ts +0 -93
  74. package/dist/plugin/debug.js +0 -375
  75. package/dist/plugin/errors.d.ts +0 -27
  76. package/dist/plugin/errors.js +0 -41
  77. package/dist/plugin/fingerprint.d.ts +0 -69
  78. package/dist/plugin/fingerprint.js +0 -137
  79. package/dist/plugin/image-saver.d.ts +0 -24
  80. package/dist/plugin/image-saver.js +0 -78
  81. package/dist/plugin/logger.d.ts +0 -35
  82. package/dist/plugin/logger.js +0 -67
  83. package/dist/plugin/logging-utils.d.ts +0 -22
  84. package/dist/plugin/logging-utils.js +0 -91
  85. package/dist/plugin/project.d.ts +0 -32
  86. package/dist/plugin/project.js +0 -229
  87. package/dist/plugin/quota.d.ts +0 -34
  88. package/dist/plugin/quota.js +0 -261
  89. package/dist/plugin/recovery/constants.d.ts +0 -21
  90. package/dist/plugin/recovery/constants.js +0 -42
  91. package/dist/plugin/recovery/index.d.ts +0 -11
  92. package/dist/plugin/recovery/index.js +0 -11
  93. package/dist/plugin/recovery/storage.d.ts +0 -23
  94. package/dist/plugin/recovery/storage.js +0 -340
  95. package/dist/plugin/recovery/types.d.ts +0 -115
  96. package/dist/plugin/recovery/types.js +0 -6
  97. package/dist/plugin/recovery.d.ts +0 -60
  98. package/dist/plugin/recovery.js +0 -360
  99. package/dist/plugin/refresh-queue.d.ts +0 -99
  100. package/dist/plugin/refresh-queue.js +0 -235
  101. package/dist/plugin/request-helpers.d.ts +0 -281
  102. package/dist/plugin/request-helpers.js +0 -2200
  103. package/dist/plugin/request.d.ts +0 -110
  104. package/dist/plugin/request.js +0 -1489
  105. package/dist/plugin/rotation.d.ts +0 -182
  106. package/dist/plugin/rotation.js +0 -364
  107. package/dist/plugin/search.d.ts +0 -31
  108. package/dist/plugin/search.js +0 -185
  109. package/dist/plugin/server.d.ts +0 -22
  110. package/dist/plugin/server.js +0 -306
  111. package/dist/plugin/storage.d.ts +0 -136
  112. package/dist/plugin/storage.js +0 -599
  113. package/dist/plugin/stores/signature-store.d.ts +0 -4
  114. package/dist/plugin/stores/signature-store.js +0 -24
  115. package/dist/plugin/thinking-recovery.d.ts +0 -89
  116. package/dist/plugin/thinking-recovery.js +0 -289
  117. package/dist/plugin/token.d.ts +0 -18
  118. package/dist/plugin/token.js +0 -127
  119. package/dist/plugin/transform/claude.d.ts +0 -79
  120. package/dist/plugin/transform/claude.js +0 -256
  121. package/dist/plugin/transform/cross-model-sanitizer.d.ts +0 -34
  122. package/dist/plugin/transform/cross-model-sanitizer.js +0 -224
  123. package/dist/plugin/transform/gemini.d.ts +0 -132
  124. package/dist/plugin/transform/gemini.js +0 -659
  125. package/dist/plugin/transform/index.d.ts +0 -14
  126. package/dist/plugin/transform/index.js +0 -9
  127. package/dist/plugin/transform/model-resolver.d.ts +0 -98
  128. package/dist/plugin/transform/model-resolver.js +0 -320
  129. package/dist/plugin/transform/types.d.ts +0 -110
  130. package/dist/plugin/transform/types.js +0 -1
  131. package/dist/plugin/types.d.ts +0 -95
  132. package/dist/plugin/types.js +0 -1
  133. package/dist/plugin/ui/ansi.d.ts +0 -31
  134. package/dist/plugin/ui/ansi.js +0 -45
  135. package/dist/plugin/ui/auth-menu.d.ts +0 -47
  136. package/dist/plugin/ui/auth-menu.js +0 -199
  137. package/dist/plugin/ui/confirm.d.ts +0 -1
  138. package/dist/plugin/ui/confirm.js +0 -14
  139. package/dist/plugin/ui/select.d.ts +0 -22
  140. package/dist/plugin/ui/select.js +0 -243
  141. package/dist/plugin/version.d.ts +0 -18
  142. package/dist/plugin/version.js +0 -79
  143. package/dist/src/antigravity/oauth.d.ts +0 -30
  144. package/dist/src/antigravity/oauth.js +0 -170
  145. package/dist/src/constants.d.ts +0 -138
  146. package/dist/src/constants.js +0 -216
  147. package/dist/src/hooks/auto-update-checker/cache.d.ts +0 -2
  148. package/dist/src/hooks/auto-update-checker/cache.js +0 -70
  149. package/dist/src/hooks/auto-update-checker/checker.d.ts +0 -15
  150. package/dist/src/hooks/auto-update-checker/checker.js +0 -233
  151. package/dist/src/hooks/auto-update-checker/constants.d.ts +0 -8
  152. package/dist/src/hooks/auto-update-checker/constants.js +0 -22
  153. package/dist/src/hooks/auto-update-checker/index.d.ts +0 -33
  154. package/dist/src/hooks/auto-update-checker/index.js +0 -121
  155. package/dist/src/hooks/auto-update-checker/logging.d.ts +0 -2
  156. package/dist/src/hooks/auto-update-checker/logging.js +0 -8
  157. package/dist/src/hooks/auto-update-checker/types.d.ts +0 -24
  158. package/dist/src/hooks/auto-update-checker/types.js +0 -1
  159. package/dist/src/index.d.ts +0 -6
  160. package/dist/src/index.js +0 -5
  161. package/dist/src/plugin/accounts.d.ts +0 -173
  162. package/dist/src/plugin/accounts.js +0 -966
  163. package/dist/src/plugin/auth.d.ts +0 -20
  164. package/dist/src/plugin/auth.js +0 -44
  165. package/dist/src/plugin/cache/index.d.ts +0 -4
  166. package/dist/src/plugin/cache/index.js +0 -4
  167. package/dist/src/plugin/cache/signature-cache.d.ts +0 -110
  168. package/dist/src/plugin/cache/signature-cache.js +0 -347
  169. package/dist/src/plugin/cache.d.ts +0 -43
  170. package/dist/src/plugin/cache.js +0 -180
  171. package/dist/src/plugin/cli.d.ts +0 -26
  172. package/dist/src/plugin/cli.js +0 -126
  173. package/dist/src/plugin/config/index.d.ts +0 -15
  174. package/dist/src/plugin/config/index.js +0 -15
  175. package/dist/src/plugin/config/loader.d.ts +0 -38
  176. package/dist/src/plugin/config/loader.js +0 -150
  177. package/dist/src/plugin/config/models.d.ts +0 -26
  178. package/dist/src/plugin/config/models.js +0 -95
  179. package/dist/src/plugin/config/schema.d.ts +0 -144
  180. package/dist/src/plugin/config/schema.js +0 -458
  181. package/dist/src/plugin/config/updater.d.ts +0 -76
  182. package/dist/src/plugin/config/updater.js +0 -205
  183. package/dist/src/plugin/core/streaming/index.d.ts +0 -2
  184. package/dist/src/plugin/core/streaming/index.js +0 -2
  185. package/dist/src/plugin/core/streaming/transformer.d.ts +0 -9
  186. package/dist/src/plugin/core/streaming/transformer.js +0 -301
  187. package/dist/src/plugin/core/streaming/types.d.ts +0 -28
  188. package/dist/src/plugin/core/streaming/types.js +0 -1
  189. package/dist/src/plugin/debug.d.ts +0 -93
  190. package/dist/src/plugin/debug.js +0 -375
  191. package/dist/src/plugin/errors.d.ts +0 -27
  192. package/dist/src/plugin/errors.js +0 -41
  193. package/dist/src/plugin/fingerprint.d.ts +0 -69
  194. package/dist/src/plugin/fingerprint.js +0 -137
  195. package/dist/src/plugin/image-saver.d.ts +0 -24
  196. package/dist/src/plugin/image-saver.js +0 -78
  197. package/dist/src/plugin/logger.d.ts +0 -35
  198. package/dist/src/plugin/logger.js +0 -67
  199. package/dist/src/plugin/logging-utils.d.ts +0 -22
  200. package/dist/src/plugin/logging-utils.js +0 -91
  201. package/dist/src/plugin/project.d.ts +0 -32
  202. package/dist/src/plugin/project.js +0 -229
  203. package/dist/src/plugin/quota.d.ts +0 -34
  204. package/dist/src/plugin/quota.js +0 -261
  205. package/dist/src/plugin/recovery/constants.d.ts +0 -21
  206. package/dist/src/plugin/recovery/constants.js +0 -42
  207. package/dist/src/plugin/recovery/index.d.ts +0 -11
  208. package/dist/src/plugin/recovery/index.js +0 -11
  209. package/dist/src/plugin/recovery/storage.d.ts +0 -23
  210. package/dist/src/plugin/recovery/storage.js +0 -340
  211. package/dist/src/plugin/recovery/types.d.ts +0 -115
  212. package/dist/src/plugin/recovery/types.js +0 -6
  213. package/dist/src/plugin/recovery.d.ts +0 -60
  214. package/dist/src/plugin/recovery.js +0 -360
  215. package/dist/src/plugin/refresh-queue.d.ts +0 -99
  216. package/dist/src/plugin/refresh-queue.js +0 -235
  217. package/dist/src/plugin/request-helpers.d.ts +0 -281
  218. package/dist/src/plugin/request-helpers.js +0 -2200
  219. package/dist/src/plugin/request.d.ts +0 -110
  220. package/dist/src/plugin/request.js +0 -1489
  221. package/dist/src/plugin/rotation.d.ts +0 -182
  222. package/dist/src/plugin/rotation.js +0 -364
  223. package/dist/src/plugin/search.d.ts +0 -31
  224. package/dist/src/plugin/search.js +0 -185
  225. package/dist/src/plugin/server.d.ts +0 -22
  226. package/dist/src/plugin/server.js +0 -306
  227. package/dist/src/plugin/storage.d.ts +0 -136
  228. package/dist/src/plugin/storage.js +0 -599
  229. package/dist/src/plugin/stores/signature-store.d.ts +0 -4
  230. package/dist/src/plugin/stores/signature-store.js +0 -24
  231. package/dist/src/plugin/thinking-recovery.d.ts +0 -89
  232. package/dist/src/plugin/thinking-recovery.js +0 -289
  233. package/dist/src/plugin/token.d.ts +0 -18
  234. package/dist/src/plugin/token.js +0 -127
  235. package/dist/src/plugin/transform/claude.d.ts +0 -79
  236. package/dist/src/plugin/transform/claude.js +0 -256
  237. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +0 -34
  238. package/dist/src/plugin/transform/cross-model-sanitizer.js +0 -224
  239. package/dist/src/plugin/transform/gemini.d.ts +0 -132
  240. package/dist/src/plugin/transform/gemini.js +0 -659
  241. package/dist/src/plugin/transform/index.d.ts +0 -14
  242. package/dist/src/plugin/transform/index.js +0 -9
  243. package/dist/src/plugin/transform/model-resolver.d.ts +0 -98
  244. package/dist/src/plugin/transform/model-resolver.js +0 -320
  245. package/dist/src/plugin/transform/types.d.ts +0 -110
  246. package/dist/src/plugin/transform/types.js +0 -1
  247. package/dist/src/plugin/types.d.ts +0 -95
  248. package/dist/src/plugin/types.js +0 -1
  249. package/dist/src/plugin/ui/ansi.d.ts +0 -31
  250. package/dist/src/plugin/ui/ansi.js +0 -45
  251. package/dist/src/plugin/ui/auth-menu.d.ts +0 -47
  252. package/dist/src/plugin/ui/auth-menu.js +0 -199
  253. package/dist/src/plugin/ui/confirm.d.ts +0 -1
  254. package/dist/src/plugin/ui/confirm.js +0 -14
  255. package/dist/src/plugin/ui/select.d.ts +0 -22
  256. package/dist/src/plugin/ui/select.js +0 -243
  257. package/dist/src/plugin/version.d.ts +0 -18
  258. package/dist/src/plugin/version.js +0 -79
@@ -1,144 +0,0 @@
1
- /**
2
- * Configuration schema for opencode-antigravity-auth plugin.
3
- *
4
- * Config file locations (in priority order, highest wins):
5
- * - Project: .opencode/antigravity.json
6
- * - User: ~/.config/opencode/antigravity.json (Linux/Mac)
7
- * %APPDATA%\opencode\antigravity.json (Windows)
8
- *
9
- * Environment variables always override config file values.
10
- */
11
- import { z } from "zod";
12
- /**
13
- * Account selection strategy for distributing requests across accounts.
14
- *
15
- * - `sticky`: Use same account until rate-limited. Preserves prompt cache.
16
- * - `round-robin`: Rotate to next account on every request. Maximum throughput.
17
- * - `hybrid` (default): Deterministic selection based on health score + token bucket + LRU freshness.
18
- */
19
- export declare const AccountSelectionStrategySchema: z.ZodEnum<{
20
- sticky: "sticky";
21
- "round-robin": "round-robin";
22
- hybrid: "hybrid";
23
- }>;
24
- export type AccountSelectionStrategy = z.infer<typeof AccountSelectionStrategySchema>;
25
- /**
26
- * Toast notification scope for controlling which sessions show toasts.
27
- *
28
- * - `root_only` (default): Only show toasts for root sessions (no parentID).
29
- * Subagents and background tasks won't show toast notifications.
30
- * - `all`: Show toasts for all sessions including subagents and background tasks.
31
- */
32
- export declare const ToastScopeSchema: z.ZodEnum<{
33
- root_only: "root_only";
34
- all: "all";
35
- }>;
36
- export type ToastScope = z.infer<typeof ToastScopeSchema>;
37
- /**
38
- * Scheduling mode for rate limit behavior.
39
- *
40
- * - `cache_first`: Wait for same account to recover (preserves prompt cache). Default.
41
- * - `balance`: Switch account immediately on rate limit. Maximum availability.
42
- * - `performance_first`: Round-robin distribution for maximum throughput.
43
- */
44
- export declare const SchedulingModeSchema: z.ZodEnum<{
45
- cache_first: "cache_first";
46
- balance: "balance";
47
- performance_first: "performance_first";
48
- }>;
49
- export type SchedulingMode = z.infer<typeof SchedulingModeSchema>;
50
- /**
51
- * Signature cache configuration for persisting thinking block signatures to disk.
52
- */
53
- export declare const SignatureCacheConfigSchema: z.ZodObject<{
54
- enabled: z.ZodDefault<z.ZodBoolean>;
55
- memory_ttl_seconds: z.ZodDefault<z.ZodNumber>;
56
- disk_ttl_seconds: z.ZodDefault<z.ZodNumber>;
57
- write_interval_seconds: z.ZodDefault<z.ZodNumber>;
58
- }, z.core.$strip>;
59
- /**
60
- * Main configuration schema for the Antigravity OAuth plugin.
61
- */
62
- export declare const AntigravityConfigSchema: z.ZodObject<{
63
- $schema: z.ZodOptional<z.ZodString>;
64
- quiet_mode: z.ZodDefault<z.ZodBoolean>;
65
- toast_scope: z.ZodDefault<z.ZodEnum<{
66
- root_only: "root_only";
67
- all: "all";
68
- }>>;
69
- debug: z.ZodDefault<z.ZodBoolean>;
70
- debug_tui: z.ZodDefault<z.ZodBoolean>;
71
- debug_gemini_payloads: z.ZodDefault<z.ZodBoolean>;
72
- log_dir: z.ZodOptional<z.ZodString>;
73
- keep_thinking: z.ZodDefault<z.ZodBoolean>;
74
- session_recovery: z.ZodDefault<z.ZodBoolean>;
75
- auto_resume: z.ZodDefault<z.ZodBoolean>;
76
- resume_text: z.ZodDefault<z.ZodString>;
77
- signature_cache: z.ZodOptional<z.ZodObject<{
78
- enabled: z.ZodDefault<z.ZodBoolean>;
79
- memory_ttl_seconds: z.ZodDefault<z.ZodNumber>;
80
- disk_ttl_seconds: z.ZodDefault<z.ZodNumber>;
81
- write_interval_seconds: z.ZodDefault<z.ZodNumber>;
82
- }, z.core.$strip>>;
83
- empty_response_max_attempts: z.ZodDefault<z.ZodNumber>;
84
- empty_response_retry_delay_ms: z.ZodDefault<z.ZodNumber>;
85
- tool_id_recovery: z.ZodDefault<z.ZodBoolean>;
86
- claude_tool_hardening: z.ZodDefault<z.ZodBoolean>;
87
- claude_prompt_auto_caching: z.ZodDefault<z.ZodBoolean>;
88
- proactive_token_refresh: z.ZodDefault<z.ZodBoolean>;
89
- proactive_refresh_buffer_seconds: z.ZodDefault<z.ZodNumber>;
90
- proactive_refresh_check_interval_seconds: z.ZodDefault<z.ZodNumber>;
91
- max_rate_limit_wait_seconds: z.ZodDefault<z.ZodNumber>;
92
- quota_fallback: z.ZodDefault<z.ZodBoolean>;
93
- cli_first: z.ZodDefault<z.ZodBoolean>;
94
- model_ranking: z.ZodOptional<z.ZodArray<z.ZodString>>;
95
- fallback_enabled: z.ZodDefault<z.ZodBoolean>;
96
- auto_mode: z.ZodDefault<z.ZodBoolean>;
97
- auto_mode_stage: z.ZodOptional<z.ZodEnum<{
98
- best: "best";
99
- high: "high";
100
- balanced: "balanced";
101
- fastest: "fastest";
102
- }>>;
103
- account_selection_strategy: z.ZodDefault<z.ZodEnum<{
104
- sticky: "sticky";
105
- "round-robin": "round-robin";
106
- hybrid: "hybrid";
107
- }>>;
108
- pid_offset_enabled: z.ZodDefault<z.ZodBoolean>;
109
- switch_on_first_rate_limit: z.ZodDefault<z.ZodBoolean>;
110
- scheduling_mode: z.ZodDefault<z.ZodEnum<{
111
- cache_first: "cache_first";
112
- balance: "balance";
113
- performance_first: "performance_first";
114
- }>>;
115
- max_cache_first_wait_seconds: z.ZodDefault<z.ZodNumber>;
116
- failure_ttl_seconds: z.ZodDefault<z.ZodNumber>;
117
- default_retry_after_seconds: z.ZodDefault<z.ZodNumber>;
118
- max_backoff_seconds: z.ZodDefault<z.ZodNumber>;
119
- request_jitter_max_ms: z.ZodDefault<z.ZodNumber>;
120
- soft_quota_threshold_percent: z.ZodDefault<z.ZodNumber>;
121
- quota_refresh_interval_minutes: z.ZodDefault<z.ZodNumber>;
122
- soft_quota_cache_ttl_minutes: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodNumber]>>;
123
- health_score: z.ZodOptional<z.ZodObject<{
124
- initial: z.ZodDefault<z.ZodNumber>;
125
- success_reward: z.ZodDefault<z.ZodNumber>;
126
- rate_limit_penalty: z.ZodDefault<z.ZodNumber>;
127
- failure_penalty: z.ZodDefault<z.ZodNumber>;
128
- recovery_rate_per_hour: z.ZodDefault<z.ZodNumber>;
129
- min_usable: z.ZodDefault<z.ZodNumber>;
130
- max_score: z.ZodDefault<z.ZodNumber>;
131
- }, z.core.$strip>>;
132
- token_bucket: z.ZodOptional<z.ZodObject<{
133
- max_tokens: z.ZodDefault<z.ZodNumber>;
134
- regeneration_rate_per_minute: z.ZodDefault<z.ZodNumber>;
135
- initial_tokens: z.ZodDefault<z.ZodNumber>;
136
- }, z.core.$strip>>;
137
- auto_update: z.ZodDefault<z.ZodBoolean>;
138
- }, z.core.$strip>;
139
- export type AntigravityConfig = z.infer<typeof AntigravityConfigSchema>;
140
- export type SignatureCacheConfig = z.infer<typeof SignatureCacheConfigSchema>;
141
- /**
142
- * Default configuration values.
143
- */
144
- export declare const DEFAULT_CONFIG: AntigravityConfig;
@@ -1,458 +0,0 @@
1
- /**
2
- * Configuration schema for opencode-antigravity-auth plugin.
3
- *
4
- * Config file locations (in priority order, highest wins):
5
- * - Project: .opencode/antigravity.json
6
- * - User: ~/.config/opencode/antigravity.json (Linux/Mac)
7
- * %APPDATA%\opencode\antigravity.json (Windows)
8
- *
9
- * Environment variables always override config file values.
10
- */
11
- import { z } from "zod";
12
- /**
13
- * Account selection strategy for distributing requests across accounts.
14
- *
15
- * - `sticky`: Use same account until rate-limited. Preserves prompt cache.
16
- * - `round-robin`: Rotate to next account on every request. Maximum throughput.
17
- * - `hybrid` (default): Deterministic selection based on health score + token bucket + LRU freshness.
18
- */
19
- export const AccountSelectionStrategySchema = z.enum(['sticky', 'round-robin', 'hybrid']);
20
- /**
21
- * Toast notification scope for controlling which sessions show toasts.
22
- *
23
- * - `root_only` (default): Only show toasts for root sessions (no parentID).
24
- * Subagents and background tasks won't show toast notifications.
25
- * - `all`: Show toasts for all sessions including subagents and background tasks.
26
- */
27
- export const ToastScopeSchema = z.enum(['root_only', 'all']);
28
- /**
29
- * Scheduling mode for rate limit behavior.
30
- *
31
- * - `cache_first`: Wait for same account to recover (preserves prompt cache). Default.
32
- * - `balance`: Switch account immediately on rate limit. Maximum availability.
33
- * - `performance_first`: Round-robin distribution for maximum throughput.
34
- */
35
- export const SchedulingModeSchema = z.enum(['cache_first', 'balance', 'performance_first']);
36
- /**
37
- * Signature cache configuration for persisting thinking block signatures to disk.
38
- */
39
- export const SignatureCacheConfigSchema = z.object({
40
- /** Enable disk caching of signatures (default: true) */
41
- enabled: z.boolean().default(true),
42
- /** In-memory TTL in seconds (default: 3600 = 1 hour) */
43
- memory_ttl_seconds: z.number().min(60).max(86400).default(3600),
44
- /** Disk TTL in seconds (default: 172800 = 48 hours) */
45
- disk_ttl_seconds: z.number().min(3600).max(604800).default(172800),
46
- /** Background write interval in seconds (default: 60) */
47
- write_interval_seconds: z.number().min(10).max(600).default(60),
48
- });
49
- /**
50
- * Main configuration schema for the Antigravity OAuth plugin.
51
- */
52
- export const AntigravityConfigSchema = z.object({
53
- /** JSON Schema reference for IDE support */
54
- $schema: z.string().optional(),
55
- // =========================================================================
56
- // =========================================================================
57
- /**
58
- * Suppress most toast notifications (rate limit, account switching, etc.)
59
- * Recovery toasts are always shown regardless of this setting.
60
- * Env override: OPENCODE_ANTIGRAVITY_QUIET=1
61
- * @default false
62
- */
63
- quiet_mode: z.boolean().default(false),
64
- /**
65
- * Control which sessions show toast notifications.
66
- *
67
- * - `root_only` (default): Only root sessions show toasts.
68
- * Subagents and background tasks will be silent (less spam).
69
- * - `all`: All sessions show toasts including subagents and background tasks.
70
- *
71
- * Debug logging captures all toasts regardless of this setting.
72
- * Env override: OPENCODE_ANTIGRAVITY_TOAST_SCOPE=all
73
- * @default "root_only"
74
- */
75
- toast_scope: ToastScopeSchema.default('root_only'),
76
- /**
77
- * Enable debug logging to file.
78
- * Env override: OPENCODE_ANTIGRAVITY_DEBUG=1
79
- * @default false
80
- */
81
- debug: z.boolean().default(false),
82
- /**
83
- * Show debug logs in the TUI log panel.
84
- * Works independently from `debug` file logging.
85
- * Env override: OPENCODE_ANTIGRAVITY_DEBUG_TUI=1
86
- * @default false
87
- */
88
- debug_tui: z.boolean().default(false),
89
- /**
90
- * If true, enables writing the raw payload sent to Gemini models
91
- * to a debug log file (gemini-payload-debug.log).
92
- * Env override: OPENCODE_ANTIGRAVITY_DEBUG_GEMINI_PAYLOADS=1
93
- * @default false
94
- */
95
- debug_gemini_payloads: z.boolean().default(false),
96
- /**
97
- * Custom directory for debug logs.
98
- * Env override: OPENCODE_ANTIGRAVITY_LOG_DIR=/path/to/logs
99
- * @default OS-specific config dir + "/antigravity-logs"
100
- */
101
- log_dir: z.string().optional(),
102
- // =========================================================================
103
- // =========================================================================
104
- /**
105
- * Preserve thinking blocks for Claude models using signature caching.
106
- *
107
- * When false (default): Thinking blocks are stripped for reliability.
108
- * When true: Full context preserved, but may encounter signature errors.
109
- *
110
- * Env override: OPENCODE_ANTIGRAVITY_KEEP_THINKING=1
111
- * @default false
112
- */
113
- keep_thinking: z.boolean().default(false),
114
- // =========================================================================
115
- // =========================================================================
116
- /**
117
- * Enable automatic session recovery from tool_result_missing errors.
118
- * When enabled, shows a toast notification when recoverable errors occur.
119
- *
120
- * @default true
121
- */
122
- session_recovery: z.boolean().default(true),
123
- /**
124
- * Automatically send a "continue" prompt after successful recovery.
125
- * Only applies when session_recovery is enabled.
126
- *
127
- * When false: Only shows toast notification, user must manually continue.
128
- * When true: Automatically sends "continue" to resume the session.
129
- *
130
- * @default false
131
- */
132
- auto_resume: z.boolean().default(false),
133
- /**
134
- * Custom text to send when auto-resuming after recovery.
135
- * Only used when auto_resume is enabled.
136
- *
137
- * @default "continue"
138
- */
139
- resume_text: z.string().default("continue"),
140
- // =========================================================================
141
- // =========================================================================
142
- /**
143
- * Signature cache configuration for persisting thinking block signatures.
144
- * Only used when keep_thinking is enabled.
145
- */
146
- signature_cache: SignatureCacheConfigSchema.optional(),
147
- // =========================================================================
148
- // =========================================================================
149
- /**
150
- * Maximum retry attempts when Antigravity returns an empty response.
151
- * Empty responses occur when no candidates/choices are returned.
152
- *
153
- * @default 4
154
- */
155
- empty_response_max_attempts: z.number().min(1).max(10).default(4),
156
- /**
157
- * Delay in milliseconds between empty response retries.
158
- *
159
- * @default 2000
160
- */
161
- empty_response_retry_delay_ms: z.number().min(500).max(10000).default(2000),
162
- // =========================================================================
163
- // =========================================================================
164
- /**
165
- * Enable tool ID orphan recovery.
166
- * When tool responses have mismatched IDs (due to context compaction),
167
- * attempt to match them by function name or create placeholders.
168
- *
169
- * @default true
170
- */
171
- tool_id_recovery: z.boolean().default(true),
172
- // =========================================================================
173
- // =========================================================================
174
- /**
175
- * Enable tool hallucination prevention for Claude models.
176
- * When enabled, injects:
177
- * - Parameter signatures into tool descriptions
178
- * - System instruction with strict tool usage rules
179
- *
180
- * This helps prevent Claude from using parameter names from its training
181
- * data instead of the actual schema.
182
- *
183
- * @default true
184
- */
185
- claude_tool_hardening: z.boolean().default(true),
186
- /**
187
- * Enable Claude prompt auto-caching by adding top-level cache_control when absent.
188
- *
189
- * @default false
190
- */
191
- claude_prompt_auto_caching: z.boolean().default(false),
192
- // =========================================================================
193
- // =========================================================================
194
- /**
195
- * Enable proactive background token refresh.
196
- * When enabled, tokens are refreshed in the background before they expire,
197
- * ensuring requests never block on token refresh.
198
- *
199
- * @default true
200
- */
201
- proactive_token_refresh: z.boolean().default(true),
202
- /**
203
- * Seconds before token expiry to trigger proactive refresh.
204
- * Default is 30 minutes (1800 seconds).
205
- *
206
- * @default 1800
207
- */
208
- proactive_refresh_buffer_seconds: z.number().min(60).max(7200).default(1800),
209
- /**
210
- * Interval between proactive refresh checks in seconds.
211
- * Default is 5 minutes (300 seconds).
212
- *
213
- * @default 300
214
- */
215
- proactive_refresh_check_interval_seconds: z.number().min(30).max(1800).default(300),
216
- // =========================================================================
217
- // =========================================================================
218
- /**
219
- * Maximum time in seconds to wait when all accounts are rate-limited.
220
- * If the minimum wait time across all accounts exceeds this threshold,
221
- * the plugin fails fast with an error instead of hanging.
222
- *
223
- * Set to 0 to disable (wait indefinitely).
224
- *
225
- * @default 300 (5 minutes)
226
- */
227
- max_rate_limit_wait_seconds: z.number().min(0).max(3600).default(300),
228
- /**
229
- * @deprecated Kept only for backward compatibility.
230
- * This flag is ignored at runtime.
231
- * Gemini requests always fall back between Antigravity and Gemini CLI quotas.
232
- *
233
- * @default false
234
- */
235
- quota_fallback: z.boolean().default(false),
236
- /**
237
- * Prefer gemini-cli routing before Antigravity for Gemini models.
238
- *
239
- * When false (default): Antigravity is tried first, then gemini-cli.
240
- * When true: gemini-cli is tried first, then Antigravity.
241
- *
242
- * @default false
243
- */
244
- cli_first: z.boolean().default(false),
245
- /**
246
- * Ordered list of all models from best to worst (defines the stages).
247
- * Default: The 5 ranked models in order.
248
- */
249
- model_ranking: z.array(z.string()).optional(),
250
- /**
251
- * Whether fallback is enabled at all.
252
- * When true: if current model is rate-limited, fall back to next stage.
253
- * When false: no fallback, just wait or fail.
254
- * @default false
255
- */
256
- fallback_enabled: z.boolean().default(false),
257
- /**
258
- * Enable "auto" model mode. When a request targets "antigravity-auto",
259
- * the plugin dynamically selects the best available model.
260
- * @default true
261
- */
262
- auto_mode: z.boolean().default(true),
263
- /**
264
- * Auto mode: which "stage" to target.
265
- * "stage1" = try stage 1, fall back down if rate-limited
266
- */
267
- auto_mode_stage: z.enum(["best", "high", "balanced", "fastest"]).optional(),
268
- /**
269
- * Strategy for selecting accounts when making requests.
270
- * Env override: OPENCODE_ANTIGRAVITY_ACCOUNT_SELECTION_STRATEGY
271
- * @default "hybrid"
272
- */
273
- account_selection_strategy: AccountSelectionStrategySchema.default('hybrid'),
274
- /**
275
- * Enable PID-based account offset for multi-session distribution.
276
- *
277
- * When enabled, different sessions (PIDs) will prefer different starting
278
- * accounts, which helps distribute load when running multiple parallel agents.
279
- *
280
- * When disabled (default), accounts start from the same index, which preserves
281
- * Anthropic's prompt cache across restarts (recommended for single-session use).
282
- *
283
- * Env override: OPENCODE_ANTIGRAVITY_PID_OFFSET_ENABLED=1
284
- * @default false
285
- */
286
- pid_offset_enabled: z.boolean().default(false),
287
- /**
288
- * Switch to another account immediately on first rate limit (after 1s delay).
289
- * When disabled, retries same account first, then switches on second rate limit.
290
- *
291
- * @default true
292
- */
293
- switch_on_first_rate_limit: z.boolean().default(true),
294
- /**
295
- * Scheduling mode for rate limit behavior.
296
- *
297
- * - `cache_first`: Wait for same account to recover (preserves prompt cache). Default.
298
- * - `balance`: Switch account immediately on rate limit. Maximum availability.
299
- * - `performance_first`: Round-robin distribution for maximum throughput.
300
- *
301
- * Env override: OPENCODE_ANTIGRAVITY_SCHEDULING_MODE
302
- * @default "cache_first"
303
- */
304
- scheduling_mode: SchedulingModeSchema.default('cache_first'),
305
- /**
306
- * Maximum seconds to wait for same account in cache_first mode.
307
- * If the account's rate limit reset time exceeds this, switch accounts.
308
- *
309
- * @default 60
310
- */
311
- max_cache_first_wait_seconds: z.number().min(5).max(300).default(60),
312
- /**
313
- * TTL in seconds for failure count expiration.
314
- * After this period of no failures, consecutiveFailures resets to 0.
315
- * This prevents old failures from permanently penalizing an account.
316
- *
317
- * @default 3600 (1 hour)
318
- */
319
- failure_ttl_seconds: z.number().min(60).max(7200).default(3600),
320
- /**
321
- * Default retry delay in seconds when API doesn't return a retry-after header.
322
- * Lower values allow faster retries but may trigger more 429 errors.
323
- *
324
- * @default 60
325
- */
326
- default_retry_after_seconds: z.number().min(1).max(300).default(60),
327
- /**
328
- * Maximum backoff delay in seconds for exponential retry.
329
- * This caps how long the exponential backoff can grow.
330
- *
331
- * @default 60
332
- */
333
- max_backoff_seconds: z.number().min(5).max(300).default(60),
334
- /**
335
- * Maximum random delay in milliseconds before each API request.
336
- * Adds timing jitter to break predictable request cadence patterns.
337
- * Set to 0 to disable request jitter.
338
- *
339
- * @default 0
340
- */
341
- request_jitter_max_ms: z.number().min(0).max(5000).default(0),
342
- /**
343
- * Soft quota threshold percentage (1-100).
344
- * When an account's quota usage reaches this percentage, skip it during
345
- * account selection (same as if it were rate-limited).
346
- *
347
- * Example: 90 means skip account when 90% of quota is used (10% remaining).
348
- * Set to 100 to disable soft quota protection.
349
- *
350
- * @default 90
351
- */
352
- soft_quota_threshold_percent: z.number().min(1).max(100).default(90),
353
- /**
354
- * How often to refresh quota data in the background (in minutes).
355
- * Quota is refreshed opportunistically after successful API requests.
356
- * Set to 0 to disable automatic refresh (manual only via Check quotas).
357
- *
358
- * @default 15
359
- */
360
- quota_refresh_interval_minutes: z.number().min(0).max(60).default(15),
361
- /**
362
- * How long quota cache is considered fresh for threshold checks (in minutes).
363
- * After this time, cache is stale and account is allowed (fail-open).
364
- *
365
- * "auto" = derive from refresh interval: max(2 * refresh_interval, 10)
366
- *
367
- * @default "auto"
368
- */
369
- soft_quota_cache_ttl_minutes: z.union([
370
- z.literal("auto"),
371
- z.number().min(1).max(120)
372
- ]).default("auto"),
373
- // =========================================================================
374
- // =========================================================================
375
- health_score: z.object({
376
- initial: z.number().min(0).max(100).default(70),
377
- success_reward: z.number().min(0).max(10).default(1),
378
- rate_limit_penalty: z.number().min(-50).max(0).default(-10),
379
- failure_penalty: z.number().min(-100).max(0).default(-20),
380
- recovery_rate_per_hour: z.number().min(0).max(20).default(2),
381
- min_usable: z.number().min(0).max(100).default(50),
382
- max_score: z.number().min(50).max(100).default(100),
383
- }).optional(),
384
- // =========================================================================
385
- // =========================================================================
386
- token_bucket: z.object({
387
- max_tokens: z.number().min(1).max(1000).default(50),
388
- regeneration_rate_per_minute: z.number().min(0.1).max(60).default(6),
389
- initial_tokens: z.number().min(1).max(1000).default(50),
390
- }).optional(),
391
- // =========================================================================
392
- // =========================================================================
393
- /**
394
- * Enable automatic plugin updates.
395
- * @default true
396
- */
397
- auto_update: z.boolean().default(true),
398
- });
399
- /**
400
- * Default configuration values.
401
- */
402
- export const DEFAULT_CONFIG = {
403
- quiet_mode: false,
404
- toast_scope: 'root_only',
405
- debug: false,
406
- debug_tui: false,
407
- debug_gemini_payloads: false,
408
- keep_thinking: false,
409
- session_recovery: true,
410
- auto_resume: true,
411
- resume_text: "continue",
412
- empty_response_max_attempts: 4,
413
- empty_response_retry_delay_ms: 2000,
414
- tool_id_recovery: true,
415
- claude_tool_hardening: true,
416
- claude_prompt_auto_caching: false,
417
- proactive_token_refresh: true,
418
- proactive_refresh_buffer_seconds: 1800,
419
- proactive_refresh_check_interval_seconds: 300,
420
- max_rate_limit_wait_seconds: 300,
421
- quota_fallback: false,
422
- cli_first: false,
423
- fallback_enabled: false,
424
- auto_mode: true,
425
- account_selection_strategy: 'hybrid',
426
- pid_offset_enabled: false,
427
- switch_on_first_rate_limit: true,
428
- scheduling_mode: 'cache_first',
429
- max_cache_first_wait_seconds: 60,
430
- failure_ttl_seconds: 3600,
431
- default_retry_after_seconds: 60,
432
- max_backoff_seconds: 60,
433
- request_jitter_max_ms: 0,
434
- soft_quota_threshold_percent: 90,
435
- quota_refresh_interval_minutes: 15,
436
- soft_quota_cache_ttl_minutes: "auto",
437
- auto_update: true,
438
- signature_cache: {
439
- enabled: true,
440
- memory_ttl_seconds: 3600,
441
- disk_ttl_seconds: 172800,
442
- write_interval_seconds: 60,
443
- },
444
- health_score: {
445
- initial: 70,
446
- success_reward: 1,
447
- rate_limit_penalty: -10,
448
- failure_penalty: -20,
449
- recovery_rate_per_hour: 2,
450
- min_usable: 50,
451
- max_score: 100,
452
- },
453
- token_bucket: {
454
- max_tokens: 50,
455
- regeneration_rate_per_minute: 6,
456
- initial_tokens: 50,
457
- },
458
- };
@@ -1,76 +0,0 @@
1
- /**
2
- * OpenCode configuration file updater.
3
- *
4
- * Updates ~/.config/opencode/opencode.json(c) with plugin models.
5
- */
6
- export interface UpdateConfigResult {
7
- success: boolean;
8
- configPath: string;
9
- error?: string;
10
- }
11
- export interface OpencodeConfig {
12
- $schema?: string;
13
- plugin?: string[];
14
- provider?: {
15
- google?: {
16
- models?: Record<string, unknown>;
17
- [key: string]: unknown;
18
- };
19
- [key: string]: unknown;
20
- };
21
- [key: string]: unknown;
22
- }
23
- export interface UpdateConfigOptions {
24
- /** Override the config file path (for testing) */
25
- configPath?: string;
26
- /**
27
- * Environment used to read `OPENCODE_CONFIG` (defaults to `process.env`).
28
- * When set and `configPath` is omitted, the resolved path matches OpenCode / opencode-cursor.
29
- */
30
- env?: NodeJS.ProcessEnv;
31
- }
32
- export declare function stripJsonCommentsAndTrailingCommas(json: string): string;
33
- /**
34
- * Get the opencode config directory path.
35
- */
36
- export declare function getOpencodeConfigDir(): string;
37
- /**
38
- * Get the opencode config file path.
39
- *
40
- * Prefers opencode.jsonc when present so we update the active config file
41
- * instead of creating a new opencode.json.
42
- */
43
- export declare function getOpencodeConfigPath(): string;
44
- /**
45
- * Resolves the active OpenCode config file: explicit `configPath`, then `OPENCODE_CONFIG`,
46
- * then default XDG layout (jsonc preferred).
47
- */
48
- export declare function resolveActiveOpencodeConfigPath(options?: UpdateConfigOptions): string;
49
- /**
50
- * Updates the opencode configuration file with plugin models.
51
- *
52
- * This function:
53
- * 1. Reads existing opencode.json/opencode.jsonc (or creates default structure)
54
- * 2. Replaces `provider.google.models` with plugin models
55
- * 3. Writes back to disk with proper formatting
56
- *
57
- * Preserves:
58
- * - $schema and other top-level config keys
59
- * - Non-google provider sections
60
- * - Other settings within google provider (except models)
61
- *
62
- * @param options - Optional configuration (e.g., custom configPath for testing)
63
- * @returns UpdateConfigResult with success status and path
64
- */
65
- export declare function updateOpencodeConfig(options?: UpdateConfigOptions): Promise<UpdateConfigResult>;
66
- /**
67
- * Merges built-in Antigravity/Google model definitions into `provider.google.models`
68
- * without removing user-defined model ids.
69
- *
70
- * For each model id in {@link OPENCODE_MODEL_DEFINITIONS}, plugin fields overwrite
71
- * the same keys on the existing entry so names/limits/variants stay current.
72
- * Custom models (ids not in the plugin map) are left unchanged.
73
- *
74
- * Use on plugin startup; use {@link updateOpencodeConfig} when a full replace is intended.
75
- */
76
- export declare function mergeAntigravityGoogleModelsIntoOpencodeConfig(options?: UpdateConfigOptions): Promise<UpdateConfigResult>;