@benjamolina/opencode-antigravity-guard 1.0.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 (243) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +773 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +3 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/antigravity/oauth.d.ts +31 -0
  8. package/dist/src/antigravity/oauth.d.ts.map +1 -0
  9. package/dist/src/antigravity/oauth.js +171 -0
  10. package/dist/src/antigravity/oauth.js.map +1 -0
  11. package/dist/src/constants.d.ts +139 -0
  12. package/dist/src/constants.d.ts.map +1 -0
  13. package/dist/src/constants.js +220 -0
  14. package/dist/src/constants.js.map +1 -0
  15. package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
  16. package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
  17. package/dist/src/hooks/auto-update-checker/cache.js +71 -0
  18. package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
  19. package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
  20. package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
  21. package/dist/src/hooks/auto-update-checker/checker.js +234 -0
  22. package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
  23. package/dist/src/hooks/auto-update-checker/constants.d.ts +9 -0
  24. package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
  25. package/dist/src/hooks/auto-update-checker/constants.js +23 -0
  26. package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
  27. package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
  28. package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
  29. package/dist/src/hooks/auto-update-checker/index.js +122 -0
  30. package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
  31. package/dist/src/hooks/auto-update-checker/logging.d.ts +3 -0
  32. package/dist/src/hooks/auto-update-checker/logging.d.ts.map +1 -0
  33. package/dist/src/hooks/auto-update-checker/logging.js +9 -0
  34. package/dist/src/hooks/auto-update-checker/logging.js.map +1 -0
  35. package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
  36. package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
  37. package/dist/src/hooks/auto-update-checker/types.js +1 -0
  38. package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
  39. package/dist/src/plugin/accounts.d.ts +180 -0
  40. package/dist/src/plugin/accounts.d.ts.map +1 -0
  41. package/dist/src/plugin/accounts.js +1045 -0
  42. package/dist/src/plugin/accounts.js.map +1 -0
  43. package/dist/src/plugin/api-key.d.ts +90 -0
  44. package/dist/src/plugin/api-key.d.ts.map +1 -0
  45. package/dist/src/plugin/api-key.js +544 -0
  46. package/dist/src/plugin/api-key.js.map +1 -0
  47. package/dist/src/plugin/auth.d.ts +21 -0
  48. package/dist/src/plugin/auth.d.ts.map +1 -0
  49. package/dist/src/plugin/auth.js +46 -0
  50. package/dist/src/plugin/auth.js.map +1 -0
  51. package/dist/src/plugin/cache/index.d.ts +5 -0
  52. package/dist/src/plugin/cache/index.d.ts.map +1 -0
  53. package/dist/src/plugin/cache/index.js +5 -0
  54. package/dist/src/plugin/cache/index.js.map +1 -0
  55. package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
  56. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
  57. package/dist/src/plugin/cache/signature-cache.js +375 -0
  58. package/dist/src/plugin/cache/signature-cache.js.map +1 -0
  59. package/dist/src/plugin/cache.d.ts +44 -0
  60. package/dist/src/plugin/cache.d.ts.map +1 -0
  61. package/dist/src/plugin/cache.js +200 -0
  62. package/dist/src/plugin/cache.js.map +1 -0
  63. package/dist/src/plugin/cli.d.ts +31 -0
  64. package/dist/src/plugin/cli.d.ts.map +1 -0
  65. package/dist/src/plugin/cli.js +135 -0
  66. package/dist/src/plugin/cli.js.map +1 -0
  67. package/dist/src/plugin/config/index.d.ts +16 -0
  68. package/dist/src/plugin/config/index.d.ts.map +1 -0
  69. package/dist/src/plugin/config/index.js +16 -0
  70. package/dist/src/plugin/config/index.js.map +1 -0
  71. package/dist/src/plugin/config/loader.d.ts +36 -0
  72. package/dist/src/plugin/config/loader.d.ts.map +1 -0
  73. package/dist/src/plugin/config/loader.js +140 -0
  74. package/dist/src/plugin/config/loader.js.map +1 -0
  75. package/dist/src/plugin/config/models.d.ts +43 -0
  76. package/dist/src/plugin/config/models.d.ts.map +1 -0
  77. package/dist/src/plugin/config/models.js +176 -0
  78. package/dist/src/plugin/config/models.js.map +1 -0
  79. package/dist/src/plugin/config/schema.d.ts +177 -0
  80. package/dist/src/plugin/config/schema.d.ts.map +1 -0
  81. package/dist/src/plugin/config/schema.js +507 -0
  82. package/dist/src/plugin/config/schema.js.map +1 -0
  83. package/dist/src/plugin/config/updater.d.ts +55 -0
  84. package/dist/src/plugin/config/updater.d.ts.map +1 -0
  85. package/dist/src/plugin/config/updater.js +125 -0
  86. package/dist/src/plugin/config/updater.js.map +1 -0
  87. package/dist/src/plugin/core/streaming/index.d.ts +3 -0
  88. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
  89. package/dist/src/plugin/core/streaming/index.js +3 -0
  90. package/dist/src/plugin/core/streaming/index.js.map +1 -0
  91. package/dist/src/plugin/core/streaming/transformer.d.ts +10 -0
  92. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
  93. package/dist/src/plugin/core/streaming/transformer.js +271 -0
  94. package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
  95. package/dist/src/plugin/core/streaming/types.d.ts +27 -0
  96. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
  97. package/dist/src/plugin/core/streaming/types.js +1 -0
  98. package/dist/src/plugin/core/streaming/types.js.map +1 -0
  99. package/dist/src/plugin/debug.d.ts +99 -0
  100. package/dist/src/plugin/debug.d.ts.map +1 -0
  101. package/dist/src/plugin/debug.js +400 -0
  102. package/dist/src/plugin/debug.js.map +1 -0
  103. package/dist/src/plugin/errors.d.ts +28 -0
  104. package/dist/src/plugin/errors.d.ts.map +1 -0
  105. package/dist/src/plugin/errors.js +42 -0
  106. package/dist/src/plugin/errors.js.map +1 -0
  107. package/dist/src/plugin/fingerprint.d.ts +70 -0
  108. package/dist/src/plugin/fingerprint.d.ts.map +1 -0
  109. package/dist/src/plugin/fingerprint.js +138 -0
  110. package/dist/src/plugin/fingerprint.js.map +1 -0
  111. package/dist/src/plugin/image-saver.d.ts +25 -0
  112. package/dist/src/plugin/image-saver.d.ts.map +1 -0
  113. package/dist/src/plugin/image-saver.js +86 -0
  114. package/dist/src/plugin/image-saver.js.map +1 -0
  115. package/dist/src/plugin/logger.d.ts +36 -0
  116. package/dist/src/plugin/logger.d.ts.map +1 -0
  117. package/dist/src/plugin/logger.js +71 -0
  118. package/dist/src/plugin/logger.js.map +1 -0
  119. package/dist/src/plugin/logging-utils.d.ts +23 -0
  120. package/dist/src/plugin/logging-utils.d.ts.map +1 -0
  121. package/dist/src/plugin/logging-utils.js +92 -0
  122. package/dist/src/plugin/logging-utils.js.map +1 -0
  123. package/dist/src/plugin/project.d.ts +33 -0
  124. package/dist/src/plugin/project.d.ts.map +1 -0
  125. package/dist/src/plugin/project.js +234 -0
  126. package/dist/src/plugin/project.js.map +1 -0
  127. package/dist/src/plugin/quota.d.ts +59 -0
  128. package/dist/src/plugin/quota.d.ts.map +1 -0
  129. package/dist/src/plugin/quota.js +295 -0
  130. package/dist/src/plugin/quota.js.map +1 -0
  131. package/dist/src/plugin/recovery/constants.d.ts +22 -0
  132. package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
  133. package/dist/src/plugin/recovery/constants.js +43 -0
  134. package/dist/src/plugin/recovery/constants.js.map +1 -0
  135. package/dist/src/plugin/recovery/index.d.ts +12 -0
  136. package/dist/src/plugin/recovery/index.d.ts.map +1 -0
  137. package/dist/src/plugin/recovery/index.js +12 -0
  138. package/dist/src/plugin/recovery/index.js.map +1 -0
  139. package/dist/src/plugin/recovery/storage.d.ts +24 -0
  140. package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
  141. package/dist/src/plugin/recovery/storage.js +354 -0
  142. package/dist/src/plugin/recovery/storage.js.map +1 -0
  143. package/dist/src/plugin/recovery/types.d.ts +116 -0
  144. package/dist/src/plugin/recovery/types.d.ts.map +1 -0
  145. package/dist/src/plugin/recovery/types.js +6 -0
  146. package/dist/src/plugin/recovery/types.js.map +1 -0
  147. package/dist/src/plugin/recovery.d.ts +61 -0
  148. package/dist/src/plugin/recovery.d.ts.map +1 -0
  149. package/dist/src/plugin/recovery.js +381 -0
  150. package/dist/src/plugin/recovery.js.map +1 -0
  151. package/dist/src/plugin/refresh-queue.d.ts +100 -0
  152. package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
  153. package/dist/src/plugin/refresh-queue.js +247 -0
  154. package/dist/src/plugin/refresh-queue.js.map +1 -0
  155. package/dist/src/plugin/request-helpers.d.ts +270 -0
  156. package/dist/src/plugin/request-helpers.d.ts.map +1 -0
  157. package/dist/src/plugin/request-helpers.js +2384 -0
  158. package/dist/src/plugin/request-helpers.js.map +1 -0
  159. package/dist/src/plugin/request.d.ts +116 -0
  160. package/dist/src/plugin/request.d.ts.map +1 -0
  161. package/dist/src/plugin/request.js +1626 -0
  162. package/dist/src/plugin/request.js.map +1 -0
  163. package/dist/src/plugin/rotation.d.ts +169 -0
  164. package/dist/src/plugin/rotation.d.ts.map +1 -0
  165. package/dist/src/plugin/rotation.js +328 -0
  166. package/dist/src/plugin/rotation.js.map +1 -0
  167. package/dist/src/plugin/search.d.ts +32 -0
  168. package/dist/src/plugin/search.d.ts.map +1 -0
  169. package/dist/src/plugin/search.js +195 -0
  170. package/dist/src/plugin/search.js.map +1 -0
  171. package/dist/src/plugin/server.d.ts +23 -0
  172. package/dist/src/plugin/server.d.ts.map +1 -0
  173. package/dist/src/plugin/server.js +324 -0
  174. package/dist/src/plugin/server.js.map +1 -0
  175. package/dist/src/plugin/storage.d.ts +137 -0
  176. package/dist/src/plugin/storage.d.ts.map +1 -0
  177. package/dist/src/plugin/storage.js +637 -0
  178. package/dist/src/plugin/storage.js.map +1 -0
  179. package/dist/src/plugin/stores/signature-store.d.ts +5 -0
  180. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
  181. package/dist/src/plugin/stores/signature-store.js +25 -0
  182. package/dist/src/plugin/stores/signature-store.js.map +1 -0
  183. package/dist/src/plugin/thinking-recovery.d.ts +90 -0
  184. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
  185. package/dist/src/plugin/thinking-recovery.js +316 -0
  186. package/dist/src/plugin/thinking-recovery.js.map +1 -0
  187. package/dist/src/plugin/token.d.ts +19 -0
  188. package/dist/src/plugin/token.d.ts.map +1 -0
  189. package/dist/src/plugin/token.js +128 -0
  190. package/dist/src/plugin/token.js.map +1 -0
  191. package/dist/src/plugin/transform/claude.d.ts +80 -0
  192. package/dist/src/plugin/transform/claude.d.ts.map +1 -0
  193. package/dist/src/plugin/transform/claude.js +265 -0
  194. package/dist/src/plugin/transform/claude.js.map +1 -0
  195. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
  196. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
  197. package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
  198. package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
  199. package/dist/src/plugin/transform/gemini.d.ts +100 -0
  200. package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
  201. package/dist/src/plugin/transform/gemini.js +482 -0
  202. package/dist/src/plugin/transform/gemini.js.map +1 -0
  203. package/dist/src/plugin/transform/index.d.ts +15 -0
  204. package/dist/src/plugin/transform/index.d.ts.map +1 -0
  205. package/dist/src/plugin/transform/index.js +14 -0
  206. package/dist/src/plugin/transform/index.js.map +1 -0
  207. package/dist/src/plugin/transform/model-resolver.d.ts +96 -0
  208. package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
  209. package/dist/src/plugin/transform/model-resolver.js +444 -0
  210. package/dist/src/plugin/transform/model-resolver.js.map +1 -0
  211. package/dist/src/plugin/transform/types.d.ts +111 -0
  212. package/dist/src/plugin/transform/types.d.ts.map +1 -0
  213. package/dist/src/plugin/transform/types.js +1 -0
  214. package/dist/src/plugin/transform/types.js.map +1 -0
  215. package/dist/src/plugin/types.d.ts +105 -0
  216. package/dist/src/plugin/types.d.ts.map +1 -0
  217. package/dist/src/plugin/types.js +1 -0
  218. package/dist/src/plugin/types.js.map +1 -0
  219. package/dist/src/plugin/ui/ansi.d.ts +32 -0
  220. package/dist/src/plugin/ui/ansi.d.ts.map +1 -0
  221. package/dist/src/plugin/ui/ansi.js +52 -0
  222. package/dist/src/plugin/ui/ansi.js.map +1 -0
  223. package/dist/src/plugin/ui/auth-menu.d.ts +33 -0
  224. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -0
  225. package/dist/src/plugin/ui/auth-menu.js +110 -0
  226. package/dist/src/plugin/ui/auth-menu.js.map +1 -0
  227. package/dist/src/plugin/ui/confirm.d.ts +2 -0
  228. package/dist/src/plugin/ui/confirm.d.ts.map +1 -0
  229. package/dist/src/plugin/ui/confirm.js +15 -0
  230. package/dist/src/plugin/ui/confirm.js.map +1 -0
  231. package/dist/src/plugin/ui/select.d.ts +23 -0
  232. package/dist/src/plugin/ui/select.d.ts.map +1 -0
  233. package/dist/src/plugin/ui/select.js +254 -0
  234. package/dist/src/plugin/ui/select.js.map +1 -0
  235. package/dist/src/plugin/version.d.ts +19 -0
  236. package/dist/src/plugin/version.d.ts.map +1 -0
  237. package/dist/src/plugin/version.js +80 -0
  238. package/dist/src/plugin/version.js.map +1 -0
  239. package/dist/src/plugin.d.ts +50 -0
  240. package/dist/src/plugin.d.ts.map +1 -0
  241. package/dist/src/plugin.js +3378 -0
  242. package/dist/src/plugin.js.map +1 -0
  243. package/package.json +70 -0
@@ -0,0 +1,507 @@
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
+ export const AgySdkCloudProjectSchema = z.object({
37
+ label: z.string().optional(),
38
+ api_key: z.string().trim().min(1, "api_key must not be empty"),
39
+ project_id: z.string().optional(),
40
+ enabled: z.boolean().default(true),
41
+ });
42
+ export const AgySdkConfigSchema = z.object({
43
+ /** Enable the newer Antigravity SDK/Gemini API path for API-key credentials. */
44
+ enabled: z.boolean().default(true),
45
+ /** Prefer API-key projects for Gemini requests when OAuth credentials are also present. */
46
+ prefer_for_gemini: z.boolean().default(false),
47
+ /** Use API-key projects as fallback when OAuth Antigravity/Gemini CLI quotas are unavailable. */
48
+ api_key_fallback: z.boolean().default(true),
49
+ /** Optional pool of Google AI API keys / Cloud projects for Gemini API fallback. */
50
+ cloud_projects: z.array(AgySdkCloudProjectSchema).default([]),
51
+ });
52
+ export const ModelDiscoveryConfigSchema = z.object({
53
+ /** Enable runtime model discovery through OpenCode's provider.models hook. */
54
+ enabled: z.boolean().default(true),
55
+ /** Include public Gemini API models discovered from API keys. */
56
+ gemini_api: z.boolean().default(true),
57
+ /** Include OAuth-backed Antigravity models discovered from the internal available-models API. */
58
+ antigravity: z.boolean().default(true),
59
+ });
60
+ /**
61
+ * Signature cache configuration for persisting thinking block signatures to disk.
62
+ */
63
+ export const SignatureCacheConfigSchema = z.object({
64
+ /** Enable disk caching of signatures (default: true) */
65
+ enabled: z.boolean().default(true),
66
+ /** In-memory TTL in seconds (default: 3600 = 1 hour) */
67
+ memory_ttl_seconds: z.number().min(60).max(86400).default(3600),
68
+ /** Disk TTL in seconds (default: 172800 = 48 hours) */
69
+ disk_ttl_seconds: z.number().min(3600).max(604800).default(172800),
70
+ /** Background write interval in seconds (default: 60) */
71
+ write_interval_seconds: z.number().min(10).max(600).default(60),
72
+ });
73
+ /**
74
+ * Main configuration schema for the Antigravity OAuth plugin.
75
+ */
76
+ export const AntigravityConfigSchema = z.object({
77
+ /** JSON Schema reference for IDE support */
78
+ $schema: z.string().optional(),
79
+ // =========================================================================
80
+ // General Settings
81
+ // =========================================================================
82
+ /**
83
+ * Suppress most toast notifications (rate limit, account switching, etc.)
84
+ * Recovery toasts are always shown regardless of this setting.
85
+ * Env override: OPENCODE_ANTIGRAVITY_QUIET=1
86
+ * @default false
87
+ */
88
+ quiet_mode: z.boolean().default(false),
89
+ /**
90
+ * Control which sessions show toast notifications.
91
+ *
92
+ * - `root_only` (default): Only root sessions show toasts.
93
+ * Subagents and background tasks will be silent (less spam).
94
+ * - `all`: All sessions show toasts including subagents and background tasks.
95
+ *
96
+ * Debug logging captures all toasts regardless of this setting.
97
+ * Env override: OPENCODE_ANTIGRAVITY_TOAST_SCOPE=all
98
+ * @default "root_only"
99
+ */
100
+ toast_scope: ToastScopeSchema.default('root_only'),
101
+ /**
102
+ * Enable debug logging to file.
103
+ * Env override: OPENCODE_ANTIGRAVITY_DEBUG=1
104
+ * @default false
105
+ */
106
+ debug: z.boolean().default(false),
107
+ /**
108
+ * Show debug logs in the TUI log panel.
109
+ * Works independently from `debug` file logging.
110
+ * Env override: OPENCODE_ANTIGRAVITY_DEBUG_TUI=1
111
+ * @default false
112
+ */
113
+ debug_tui: z.boolean().default(false),
114
+ /**
115
+ * Custom directory for debug logs.
116
+ * Env override: OPENCODE_ANTIGRAVITY_LOG_DIR=/path/to/logs
117
+ * @default OS-specific config dir + "/antigravity-logs"
118
+ */
119
+ log_dir: z.string().optional(),
120
+ // =========================================================================
121
+ // Thinking Blocks
122
+ // =========================================================================
123
+ /**
124
+ * Preserve thinking blocks for Claude models using signature caching.
125
+ *
126
+ * When false (default): Thinking blocks are stripped for reliability.
127
+ * When true: Full context preserved, but may encounter signature errors.
128
+ *
129
+ * Env override: OPENCODE_ANTIGRAVITY_KEEP_THINKING=1
130
+ * @default false
131
+ */
132
+ keep_thinking: z.boolean().default(false),
133
+ // =========================================================================
134
+ // Session Recovery
135
+ // =========================================================================
136
+ /**
137
+ * Enable automatic session recovery from tool_result_missing errors.
138
+ * When enabled, shows a toast notification when recoverable errors occur.
139
+ *
140
+ * @default true
141
+ */
142
+ session_recovery: z.boolean().default(true),
143
+ /**
144
+ * Automatically send a "continue" prompt after successful recovery.
145
+ * Only applies when session_recovery is enabled.
146
+ *
147
+ * When false: Only shows toast notification, user must manually continue.
148
+ * When true: Automatically sends "continue" to resume the session.
149
+ *
150
+ * @default false
151
+ */
152
+ auto_resume: z.boolean().default(false),
153
+ /**
154
+ * Custom text to send when auto-resuming after recovery.
155
+ * Only used when auto_resume is enabled.
156
+ *
157
+ * @default "continue"
158
+ */
159
+ resume_text: z.string().default("continue"),
160
+ // =========================================================================
161
+ // Signature Caching
162
+ // =========================================================================
163
+ /**
164
+ * Signature cache configuration for persisting thinking block signatures.
165
+ * Only used when keep_thinking is enabled.
166
+ */
167
+ signature_cache: SignatureCacheConfigSchema.optional(),
168
+ // =========================================================================
169
+ // Empty Response Retry (ported from LLM-API-Key-Proxy)
170
+ // =========================================================================
171
+ /**
172
+ * Maximum retry attempts when Antigravity returns an empty response.
173
+ * Empty responses occur when no candidates/choices are returned.
174
+ *
175
+ * @default 4
176
+ */
177
+ empty_response_max_attempts: z.number().min(1).max(10).default(4),
178
+ /**
179
+ * Delay in milliseconds between empty response retries.
180
+ *
181
+ * @default 2000
182
+ */
183
+ empty_response_retry_delay_ms: z.number().min(500).max(10000).default(2000),
184
+ // =========================================================================
185
+ // Tool ID Recovery (ported from LLM-API-Key-Proxy)
186
+ // =========================================================================
187
+ /**
188
+ * Enable tool ID orphan recovery.
189
+ * When tool responses have mismatched IDs (due to context compaction),
190
+ * attempt to match them by function name or create placeholders.
191
+ *
192
+ * @default true
193
+ */
194
+ tool_id_recovery: z.boolean().default(true),
195
+ // =========================================================================
196
+ // Tool Hallucination Prevention (ported from LLM-API-Key-Proxy)
197
+ // =========================================================================
198
+ /**
199
+ * Enable tool hallucination prevention for Claude models.
200
+ * When enabled, injects:
201
+ * - Parameter signatures into tool descriptions
202
+ * - System instruction with strict tool usage rules
203
+ *
204
+ * This helps prevent Claude from using parameter names from its training
205
+ * data instead of the actual schema.
206
+ *
207
+ * @default true
208
+ */
209
+ claude_tool_hardening: z.boolean().default(true),
210
+ /**
211
+ * Enable Claude prompt auto-caching by adding top-level cache_control when absent.
212
+ *
213
+ * @default false
214
+ */
215
+ claude_prompt_auto_caching: z.boolean().default(false),
216
+ // =========================================================================
217
+ // Proactive Token Refresh (ported from LLM-API-Key-Proxy)
218
+ // =========================================================================
219
+ /**
220
+ * Enable proactive background token refresh.
221
+ * When enabled, tokens are refreshed in the background before they expire,
222
+ * ensuring requests never block on token refresh.
223
+ *
224
+ * @default true
225
+ */
226
+ proactive_token_refresh: z.boolean().default(true),
227
+ /**
228
+ * Seconds before token expiry to trigger proactive refresh.
229
+ * Default is 30 minutes (1800 seconds).
230
+ *
231
+ * @default 1800
232
+ */
233
+ proactive_refresh_buffer_seconds: z.number().min(60).max(7200).default(1800),
234
+ /**
235
+ * Interval between proactive refresh checks in seconds.
236
+ * Default is 5 minutes (300 seconds).
237
+ *
238
+ * @default 300
239
+ */
240
+ proactive_refresh_check_interval_seconds: z.number().min(30).max(1800).default(300),
241
+ // =========================================================================
242
+ // Rate Limiting
243
+ // =========================================================================
244
+ /**
245
+ * Maximum time in seconds to wait when all accounts are rate-limited.
246
+ * If the minimum wait time across all accounts exceeds this threshold,
247
+ * the plugin fails fast with an error instead of hanging.
248
+ *
249
+ * Set to 0 to disable (wait indefinitely).
250
+ *
251
+ * @default 300 (5 minutes)
252
+ */
253
+ max_rate_limit_wait_seconds: z.number().min(0).max(3600).default(300),
254
+ /**
255
+ * Maximum time in seconds for a single API request before timing out.
256
+ * When a request times out, the account is marked unhealthy and the
257
+ * plugin automatically rotates to the next available account.
258
+ *
259
+ * @default 600 (10 minutes)
260
+ */
261
+ request_timeout_seconds: z.number().min(30).max(3600).default(600),
262
+ /**
263
+ * @deprecated Kept only for backward compatibility.
264
+ * This flag is ignored at runtime.
265
+ * Gemini requests always fall back between Antigravity and Gemini CLI quotas.
266
+ *
267
+ * @default false
268
+ */
269
+ quota_fallback: z.boolean().default(false),
270
+ /**
271
+ * Prefer gemini-cli routing before Antigravity for Gemini models.
272
+ *
273
+ * When false (default): Antigravity is tried first, then gemini-cli.
274
+ * When true: gemini-cli is tried first, then Antigravity.
275
+ *
276
+ * @default false
277
+ */
278
+ cli_first: z.boolean().default(false),
279
+ /**
280
+ * Antigravity SDK / Gemini API support.
281
+ *
282
+ * Official Antigravity SDK examples use Gemini API keys (`GEMINI_API_KEY`).
283
+ * These projects are independent from OAuth accounts and can be used as the
284
+ * new Gemini API path or as fallback capacity when OAuth-backed quotas are exhausted.
285
+ */
286
+ agy_sdk: AgySdkConfigSchema.default({
287
+ enabled: true,
288
+ prefer_for_gemini: false,
289
+ api_key_fallback: true,
290
+ cloud_projects: [],
291
+ }),
292
+ /**
293
+ * Runtime model discovery.
294
+ *
295
+ * When enabled, OpenCode can populate provider models from available Gemini API
296
+ * and Antigravity model-list APIs instead of relying only on static config maps.
297
+ * Static bundled definitions remain the fallback when discovery is unavailable.
298
+ */
299
+ model_discovery: ModelDiscoveryConfigSchema.default({
300
+ enabled: true,
301
+ gemini_api: true,
302
+ antigravity: true,
303
+ }),
304
+ /**
305
+ * Strategy for selecting accounts when making requests.
306
+ * Env override: OPENCODE_ANTIGRAVITY_ACCOUNT_SELECTION_STRATEGY
307
+ * @default "hybrid"
308
+ */
309
+ account_selection_strategy: AccountSelectionStrategySchema.default('hybrid'),
310
+ /**
311
+ * Enable PID-based account offset for multi-session distribution.
312
+ *
313
+ * When enabled, different sessions (PIDs) will prefer different starting
314
+ * accounts, which helps distribute load when running multiple parallel agents.
315
+ *
316
+ * When disabled (default), accounts start from the same index, which preserves
317
+ * Anthropic's prompt cache across restarts (recommended for single-session use).
318
+ *
319
+ * Env override: OPENCODE_ANTIGRAVITY_PID_OFFSET_ENABLED=1
320
+ * @default false
321
+ */
322
+ pid_offset_enabled: z.boolean().default(false),
323
+ /**
324
+ * Switch to another account immediately on first rate limit (after 1s delay).
325
+ * When disabled, retries same account first, then switches on second rate limit.
326
+ *
327
+ * @default true
328
+ */
329
+ switch_on_first_rate_limit: z.boolean().default(true),
330
+ /**
331
+ * Scheduling mode for rate limit behavior.
332
+ *
333
+ * - `cache_first`: Wait for same account to recover (preserves prompt cache). Default.
334
+ * - `balance`: Switch account immediately on rate limit. Maximum availability.
335
+ * - `performance_first`: Round-robin distribution for maximum throughput.
336
+ *
337
+ * Env override: OPENCODE_ANTIGRAVITY_SCHEDULING_MODE
338
+ * @default "cache_first"
339
+ */
340
+ scheduling_mode: SchedulingModeSchema.default('cache_first'),
341
+ /**
342
+ * Maximum seconds to wait for same account in cache_first mode.
343
+ * If the account's rate limit reset time exceeds this, switch accounts.
344
+ *
345
+ * @default 60
346
+ */
347
+ max_cache_first_wait_seconds: z.number().min(5).max(300).default(60),
348
+ /**
349
+ * TTL in seconds for failure count expiration.
350
+ * After this period of no failures, consecutiveFailures resets to 0.
351
+ * This prevents old failures from permanently penalizing an account.
352
+ *
353
+ * @default 3600 (1 hour)
354
+ */
355
+ failure_ttl_seconds: z.number().min(60).max(7200).default(3600),
356
+ /**
357
+ * Default retry delay in seconds when API doesn't return a retry-after header.
358
+ * Lower values allow faster retries but may trigger more 429 errors.
359
+ *
360
+ * @default 60
361
+ */
362
+ default_retry_after_seconds: z.number().min(1).max(300).default(60),
363
+ /**
364
+ * Maximum backoff delay in seconds for exponential retry.
365
+ * This caps how long the exponential backoff can grow.
366
+ *
367
+ * @default 60
368
+ */
369
+ max_backoff_seconds: z.number().min(5).max(300).default(60),
370
+ /**
371
+ * Maximum random delay in milliseconds before each API request.
372
+ * Adds timing jitter to break predictable request cadence patterns.
373
+ * Set to 0 to disable request jitter.
374
+ *
375
+ * @default 0
376
+ */
377
+ request_jitter_max_ms: z.number().min(0).max(5000).default(0),
378
+ /**
379
+ * Soft quota threshold percentage (1-100).
380
+ * When an account's quota usage reaches this percentage, skip it during
381
+ * account selection (same as if it were rate-limited).
382
+ *
383
+ * Example: 70 means skip account when 70% of quota is used (30% remaining).
384
+ * Set to 100 to disable soft quota protection.
385
+ *
386
+ * @default 70
387
+ */
388
+ soft_quota_threshold_percent: z.number().min(1).max(100).default(70),
389
+ /**
390
+ * How often to refresh quota data in the background (in minutes).
391
+ * Quota is refreshed opportunistically after successful API requests.
392
+ * Set to 0 to disable automatic refresh (manual only via Check quotas).
393
+ *
394
+ * @default 15
395
+ */
396
+ quota_refresh_interval_minutes: z.number().min(0).max(60).default(15),
397
+ /**
398
+ * How long quota cache is considered fresh for threshold checks (in minutes).
399
+ * After this time, cache is stale and account is allowed (fail-open).
400
+ *
401
+ * "auto" = derive from refresh interval: max(2 * refresh_interval, 10)
402
+ *
403
+ * @default "auto"
404
+ */
405
+ soft_quota_cache_ttl_minutes: z.union([
406
+ z.literal("auto"),
407
+ z.number().min(1).max(120)
408
+ ]).default("auto"),
409
+ // =========================================================================
410
+ // Health Score (used by hybrid strategy)
411
+ // =========================================================================
412
+ health_score: z.object({
413
+ initial: z.number().min(0).max(100).default(70),
414
+ success_reward: z.number().min(0).max(10).default(1),
415
+ rate_limit_penalty: z.number().min(-50).max(0).default(-10),
416
+ failure_penalty: z.number().min(-100).max(0).default(-20),
417
+ recovery_rate_per_hour: z.number().min(0).max(20).default(2),
418
+ min_usable: z.number().min(0).max(100).default(50),
419
+ max_score: z.number().min(50).max(100).default(100),
420
+ }).optional(),
421
+ // =========================================================================
422
+ // Token Bucket (for hybrid strategy)
423
+ // =========================================================================
424
+ token_bucket: z.object({
425
+ max_tokens: z.number().min(1).max(1000).default(50),
426
+ regeneration_rate_per_minute: z.number().min(0.1).max(60).default(6),
427
+ initial_tokens: z.number().min(1).max(1000).default(50),
428
+ }).optional(),
429
+ // =========================================================================
430
+ // Auto-Update
431
+ // =========================================================================
432
+ /**
433
+ * Enable automatic plugin updates.
434
+ * @default true
435
+ */
436
+ auto_update: z.boolean().default(true),
437
+ });
438
+ /**
439
+ * Default configuration values.
440
+ */
441
+ export const DEFAULT_CONFIG = {
442
+ quiet_mode: false,
443
+ toast_scope: 'root_only',
444
+ debug: false,
445
+ debug_tui: false,
446
+ keep_thinking: false,
447
+ session_recovery: true,
448
+ auto_resume: true,
449
+ resume_text: "continue",
450
+ empty_response_max_attempts: 4,
451
+ empty_response_retry_delay_ms: 2000,
452
+ tool_id_recovery: true,
453
+ claude_tool_hardening: true,
454
+ claude_prompt_auto_caching: false,
455
+ proactive_token_refresh: true,
456
+ proactive_refresh_buffer_seconds: 1800,
457
+ proactive_refresh_check_interval_seconds: 300,
458
+ max_rate_limit_wait_seconds: 300,
459
+ request_timeout_seconds: 600,
460
+ quota_fallback: false,
461
+ cli_first: false,
462
+ agy_sdk: {
463
+ enabled: true,
464
+ prefer_for_gemini: false,
465
+ api_key_fallback: true,
466
+ cloud_projects: [],
467
+ },
468
+ model_discovery: {
469
+ enabled: true,
470
+ gemini_api: true,
471
+ antigravity: true,
472
+ },
473
+ account_selection_strategy: 'hybrid',
474
+ pid_offset_enabled: false,
475
+ switch_on_first_rate_limit: true,
476
+ scheduling_mode: 'cache_first',
477
+ max_cache_first_wait_seconds: 60,
478
+ failure_ttl_seconds: 3600,
479
+ default_retry_after_seconds: 60,
480
+ max_backoff_seconds: 60,
481
+ request_jitter_max_ms: 0,
482
+ soft_quota_threshold_percent: 70,
483
+ quota_refresh_interval_minutes: 15,
484
+ soft_quota_cache_ttl_minutes: "auto",
485
+ auto_update: true,
486
+ signature_cache: {
487
+ enabled: true,
488
+ memory_ttl_seconds: 3600,
489
+ disk_ttl_seconds: 172800,
490
+ write_interval_seconds: 60,
491
+ },
492
+ health_score: {
493
+ initial: 70,
494
+ success_reward: 1,
495
+ rate_limit_penalty: -10,
496
+ failure_penalty: -20,
497
+ recovery_rate_per_hour: 2,
498
+ min_usable: 50,
499
+ max_score: 100,
500
+ },
501
+ token_bucket: {
502
+ max_tokens: 50,
503
+ regeneration_rate_per_minute: 6,
504
+ initial_tokens: 50,
505
+ },
506
+ };
507
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/plugin/config/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;AAG1F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;AAG7D;;;;;;GAMG;AACH,MAAM,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AAE,CAAC,EAAE;QACpB,sBAAsB,EAAE,CAAC;QACzB,UAAU,EAAE,EAAE;QACd,SAAS,EAAE,GAAG;KACf;IACD,YAAY,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,4BAA4B,EAAE,CAAC;QAC/B,cAAc,EAAE,EAAE;KACnB;CACF,CAAC"}
@@ -0,0 +1,55 @@
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
+ /**
28
+ * Get the opencode config directory path.
29
+ */
30
+ export declare function getOpencodeConfigDir(): string;
31
+ /**
32
+ * Get the opencode config file path.
33
+ *
34
+ * Prefers opencode.jsonc when present so we update the active config file
35
+ * instead of creating a new opencode.json.
36
+ */
37
+ export declare function getOpencodeConfigPath(): string;
38
+ /**
39
+ * Updates the opencode configuration file with plugin models.
40
+ *
41
+ * This function:
42
+ * 1. Reads existing opencode.json/opencode.jsonc (or creates default structure)
43
+ * 2. Replaces `provider.google.models` with plugin models
44
+ * 3. Writes back to disk with proper formatting
45
+ *
46
+ * Preserves:
47
+ * - $schema and other top-level config keys
48
+ * - Non-google provider sections
49
+ * - Other settings within google provider (except models)
50
+ *
51
+ * @param options - Optional configuration (e.g., custom configPath for testing)
52
+ * @returns UpdateConfigResult with success status and path
53
+ */
54
+ export declare function updateOpencodeConfig(options?: UpdateConfigOptions): Promise<UpdateConfigResult>;
55
+ //# sourceMappingURL=updater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../../../../src/plugin/config/updater.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE;QACT,MAAM,CAAC,EAAE;YACP,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;QACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAoBD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAG7C;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAa9C;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAoE7B"}