@cortexkit/opencode-antigravity-auth 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 (271) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +714 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +15175 -0
  6. package/dist/index.js.map +7 -0
  7. package/dist/src/antigravity/oauth.d.ts +2 -0
  8. package/dist/src/antigravity/oauth.d.ts.map +1 -0
  9. package/dist/src/antigravity/oauth.js +3 -0
  10. package/dist/src/antigravity/oauth.js.map +1 -0
  11. package/dist/src/constants.d.ts +2 -0
  12. package/dist/src/constants.d.ts.map +1 -0
  13. package/dist/src/constants.js +3 -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 +232 -0
  40. package/dist/src/plugin/accounts.d.ts.map +1 -0
  41. package/dist/src/plugin/accounts.js +1163 -0
  42. package/dist/src/plugin/accounts.js.map +1 -0
  43. package/dist/src/plugin/agy-transport.d.ts +2 -0
  44. package/dist/src/plugin/agy-transport.d.ts.map +1 -0
  45. package/dist/src/plugin/agy-transport.js +3 -0
  46. package/dist/src/plugin/agy-transport.js.map +1 -0
  47. package/dist/src/plugin/auth-doctor.d.ts +30 -0
  48. package/dist/src/plugin/auth-doctor.d.ts.map +1 -0
  49. package/dist/src/plugin/auth-doctor.js +144 -0
  50. package/dist/src/plugin/auth-doctor.js.map +1 -0
  51. package/dist/src/plugin/auth-drift.d.ts +13 -0
  52. package/dist/src/plugin/auth-drift.d.ts.map +1 -0
  53. package/dist/src/plugin/auth-drift.js +70 -0
  54. package/dist/src/plugin/auth-drift.js.map +1 -0
  55. package/dist/src/plugin/auth.d.ts +2 -0
  56. package/dist/src/plugin/auth.d.ts.map +1 -0
  57. package/dist/src/plugin/auth.js +3 -0
  58. package/dist/src/plugin/auth.js.map +1 -0
  59. package/dist/src/plugin/cache/index.d.ts +5 -0
  60. package/dist/src/plugin/cache/index.d.ts.map +1 -0
  61. package/dist/src/plugin/cache/index.js +5 -0
  62. package/dist/src/plugin/cache/index.js.map +1 -0
  63. package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
  64. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
  65. package/dist/src/plugin/cache/signature-cache.js +375 -0
  66. package/dist/src/plugin/cache/signature-cache.js.map +1 -0
  67. package/dist/src/plugin/cache.d.ts +44 -0
  68. package/dist/src/plugin/cache.d.ts.map +1 -0
  69. package/dist/src/plugin/cache.js +247 -0
  70. package/dist/src/plugin/cache.js.map +1 -0
  71. package/dist/src/plugin/cli.d.ts +44 -0
  72. package/dist/src/plugin/cli.d.ts.map +1 -0
  73. package/dist/src/plugin/cli.js +153 -0
  74. package/dist/src/plugin/cli.js.map +1 -0
  75. package/dist/src/plugin/config/index.d.ts +16 -0
  76. package/dist/src/plugin/config/index.d.ts.map +1 -0
  77. package/dist/src/plugin/config/index.js +16 -0
  78. package/dist/src/plugin/config/index.js.map +1 -0
  79. package/dist/src/plugin/config/loader.d.ts +36 -0
  80. package/dist/src/plugin/config/loader.d.ts.map +1 -0
  81. package/dist/src/plugin/config/loader.js +140 -0
  82. package/dist/src/plugin/config/loader.js.map +1 -0
  83. package/dist/src/plugin/config/models.d.ts +3 -0
  84. package/dist/src/plugin/config/models.d.ts.map +1 -0
  85. package/dist/src/plugin/config/models.js +2 -0
  86. package/dist/src/plugin/config/models.js.map +1 -0
  87. package/dist/src/plugin/config/schema.d.ts +141 -0
  88. package/dist/src/plugin/config/schema.d.ts.map +1 -0
  89. package/dist/src/plugin/config/schema.js +504 -0
  90. package/dist/src/plugin/config/schema.js.map +1 -0
  91. package/dist/src/plugin/config/updater.d.ts +55 -0
  92. package/dist/src/plugin/config/updater.d.ts.map +1 -0
  93. package/dist/src/plugin/config/updater.js +127 -0
  94. package/dist/src/plugin/config/updater.js.map +1 -0
  95. package/dist/src/plugin/core/streaming/index.d.ts +3 -0
  96. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
  97. package/dist/src/plugin/core/streaming/index.js +3 -0
  98. package/dist/src/plugin/core/streaming/index.js.map +1 -0
  99. package/dist/src/plugin/core/streaming/transformer.d.ts +12 -0
  100. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
  101. package/dist/src/plugin/core/streaming/transformer.js +447 -0
  102. package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
  103. package/dist/src/plugin/core/streaming/types.d.ts +34 -0
  104. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
  105. package/dist/src/plugin/core/streaming/types.js +1 -0
  106. package/dist/src/plugin/core/streaming/types.js.map +1 -0
  107. package/dist/src/plugin/debug.d.ts +94 -0
  108. package/dist/src/plugin/debug.d.ts.map +1 -0
  109. package/dist/src/plugin/debug.js +383 -0
  110. package/dist/src/plugin/debug.js.map +1 -0
  111. package/dist/src/plugin/errors.d.ts +28 -0
  112. package/dist/src/plugin/errors.d.ts.map +1 -0
  113. package/dist/src/plugin/errors.js +42 -0
  114. package/dist/src/plugin/errors.js.map +1 -0
  115. package/dist/src/plugin/fingerprint.d.ts +2 -0
  116. package/dist/src/plugin/fingerprint.d.ts.map +1 -0
  117. package/dist/src/plugin/fingerprint.js +3 -0
  118. package/dist/src/plugin/fingerprint.js.map +1 -0
  119. package/dist/src/plugin/gemini-dump.d.ts +47 -0
  120. package/dist/src/plugin/gemini-dump.d.ts.map +1 -0
  121. package/dist/src/plugin/gemini-dump.js +238 -0
  122. package/dist/src/plugin/gemini-dump.js.map +1 -0
  123. package/dist/src/plugin/image-saver.d.ts +25 -0
  124. package/dist/src/plugin/image-saver.d.ts.map +1 -0
  125. package/dist/src/plugin/image-saver.js +86 -0
  126. package/dist/src/plugin/image-saver.js.map +1 -0
  127. package/dist/src/plugin/logger.d.ts +23 -0
  128. package/dist/src/plugin/logger.d.ts.map +1 -0
  129. package/dist/src/plugin/logger.js +80 -0
  130. package/dist/src/plugin/logger.js.map +1 -0
  131. package/dist/src/plugin/logging-utils.d.ts +23 -0
  132. package/dist/src/plugin/logging-utils.d.ts.map +1 -0
  133. package/dist/src/plugin/logging-utils.js +92 -0
  134. package/dist/src/plugin/logging-utils.js.map +1 -0
  135. package/dist/src/plugin/model-registry.d.ts +2 -0
  136. package/dist/src/plugin/model-registry.d.ts.map +1 -0
  137. package/dist/src/plugin/model-registry.js +3 -0
  138. package/dist/src/plugin/model-registry.js.map +1 -0
  139. package/dist/src/plugin/project.d.ts +2 -0
  140. package/dist/src/plugin/project.d.ts.map +1 -0
  141. package/dist/src/plugin/project.js +3 -0
  142. package/dist/src/plugin/project.js.map +1 -0
  143. package/dist/src/plugin/prompt-context.d.ts +18 -0
  144. package/dist/src/plugin/prompt-context.d.ts.map +1 -0
  145. package/dist/src/plugin/prompt-context.js +99 -0
  146. package/dist/src/plugin/prompt-context.js.map +1 -0
  147. package/dist/src/plugin/quota.d.ts +44 -0
  148. package/dist/src/plugin/quota.d.ts.map +1 -0
  149. package/dist/src/plugin/quota.js +336 -0
  150. package/dist/src/plugin/quota.js.map +1 -0
  151. package/dist/src/plugin/recovery/constants.d.ts +22 -0
  152. package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
  153. package/dist/src/plugin/recovery/constants.js +43 -0
  154. package/dist/src/plugin/recovery/constants.js.map +1 -0
  155. package/dist/src/plugin/recovery/index.d.ts +12 -0
  156. package/dist/src/plugin/recovery/index.d.ts.map +1 -0
  157. package/dist/src/plugin/recovery/index.js +12 -0
  158. package/dist/src/plugin/recovery/index.js.map +1 -0
  159. package/dist/src/plugin/recovery/storage.d.ts +24 -0
  160. package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
  161. package/dist/src/plugin/recovery/storage.js +354 -0
  162. package/dist/src/plugin/recovery/storage.js.map +1 -0
  163. package/dist/src/plugin/recovery/types.d.ts +116 -0
  164. package/dist/src/plugin/recovery/types.d.ts.map +1 -0
  165. package/dist/src/plugin/recovery/types.js +6 -0
  166. package/dist/src/plugin/recovery/types.js.map +1 -0
  167. package/dist/src/plugin/recovery.d.ts +61 -0
  168. package/dist/src/plugin/recovery.d.ts.map +1 -0
  169. package/dist/src/plugin/recovery.js +381 -0
  170. package/dist/src/plugin/recovery.js.map +1 -0
  171. package/dist/src/plugin/refresh-queue.d.ts +100 -0
  172. package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
  173. package/dist/src/plugin/refresh-queue.js +247 -0
  174. package/dist/src/plugin/refresh-queue.js.map +1 -0
  175. package/dist/src/plugin/request-helpers.d.ts +278 -0
  176. package/dist/src/plugin/request-helpers.d.ts.map +1 -0
  177. package/dist/src/plugin/request-helpers.js +2323 -0
  178. package/dist/src/plugin/request-helpers.js.map +1 -0
  179. package/dist/src/plugin/request.d.ts +102 -0
  180. package/dist/src/plugin/request.d.ts.map +1 -0
  181. package/dist/src/plugin/request.js +1658 -0
  182. package/dist/src/plugin/request.js.map +1 -0
  183. package/dist/src/plugin/rotation.d.ts +169 -0
  184. package/dist/src/plugin/rotation.d.ts.map +1 -0
  185. package/dist/src/plugin/rotation.js +328 -0
  186. package/dist/src/plugin/rotation.js.map +1 -0
  187. package/dist/src/plugin/search.d.ts +25 -0
  188. package/dist/src/plugin/search.d.ts.map +1 -0
  189. package/dist/src/plugin/search.js +200 -0
  190. package/dist/src/plugin/search.js.map +1 -0
  191. package/dist/src/plugin/server.d.ts +23 -0
  192. package/dist/src/plugin/server.d.ts.map +1 -0
  193. package/dist/src/plugin/server.js +324 -0
  194. package/dist/src/plugin/server.js.map +1 -0
  195. package/dist/src/plugin/storage.d.ts +150 -0
  196. package/dist/src/plugin/storage.d.ts.map +1 -0
  197. package/dist/src/plugin/storage.js +628 -0
  198. package/dist/src/plugin/storage.js.map +1 -0
  199. package/dist/src/plugin/stores/signature-store.d.ts +5 -0
  200. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
  201. package/dist/src/plugin/stores/signature-store.js +25 -0
  202. package/dist/src/plugin/stores/signature-store.js.map +1 -0
  203. package/dist/src/plugin/thinking-recovery.d.ts +90 -0
  204. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
  205. package/dist/src/plugin/thinking-recovery.js +330 -0
  206. package/dist/src/plugin/thinking-recovery.js.map +1 -0
  207. package/dist/src/plugin/token.d.ts +19 -0
  208. package/dist/src/plugin/token.d.ts.map +1 -0
  209. package/dist/src/plugin/token.js +130 -0
  210. package/dist/src/plugin/token.js.map +1 -0
  211. package/dist/src/plugin/transform/claude.d.ts +92 -0
  212. package/dist/src/plugin/transform/claude.d.ts.map +1 -0
  213. package/dist/src/plugin/transform/claude.js +280 -0
  214. package/dist/src/plugin/transform/claude.js.map +1 -0
  215. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +2 -0
  216. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
  217. package/dist/src/plugin/transform/cross-model-sanitizer.js +3 -0
  218. package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
  219. package/dist/src/plugin/transform/gemini.d.ts +100 -0
  220. package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
  221. package/dist/src/plugin/transform/gemini.js +446 -0
  222. package/dist/src/plugin/transform/gemini.js.map +1 -0
  223. package/dist/src/plugin/transform/index.d.ts +2 -0
  224. package/dist/src/plugin/transform/index.d.ts.map +1 -0
  225. package/dist/src/plugin/transform/index.js +3 -0
  226. package/dist/src/plugin/transform/index.js.map +1 -0
  227. package/dist/src/plugin/transform/model-resolver.d.ts +2 -0
  228. package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
  229. package/dist/src/plugin/transform/model-resolver.js +3 -0
  230. package/dist/src/plugin/transform/model-resolver.js.map +1 -0
  231. package/dist/src/plugin/transform/types.d.ts +2 -0
  232. package/dist/src/plugin/transform/types.d.ts.map +1 -0
  233. package/dist/src/plugin/transform/types.js +3 -0
  234. package/dist/src/plugin/transform/types.js.map +1 -0
  235. package/dist/src/plugin/types.d.ts +80 -0
  236. package/dist/src/plugin/types.d.ts.map +1 -0
  237. package/dist/src/plugin/types.js +1 -0
  238. package/dist/src/plugin/types.js.map +1 -0
  239. package/dist/src/plugin/ui/ansi.d.ts +32 -0
  240. package/dist/src/plugin/ui/ansi.d.ts.map +1 -0
  241. package/dist/src/plugin/ui/ansi.js +52 -0
  242. package/dist/src/plugin/ui/ansi.js.map +1 -0
  243. package/dist/src/plugin/ui/auth-menu.d.ts +59 -0
  244. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -0
  245. package/dist/src/plugin/ui/auth-menu.js +362 -0
  246. package/dist/src/plugin/ui/auth-menu.js.map +1 -0
  247. package/dist/src/plugin/ui/confirm.d.ts +2 -0
  248. package/dist/src/plugin/ui/confirm.d.ts.map +1 -0
  249. package/dist/src/plugin/ui/confirm.js +15 -0
  250. package/dist/src/plugin/ui/confirm.js.map +1 -0
  251. package/dist/src/plugin/ui/model-status.d.ts +28 -0
  252. package/dist/src/plugin/ui/model-status.d.ts.map +1 -0
  253. package/dist/src/plugin/ui/model-status.js +80 -0
  254. package/dist/src/plugin/ui/model-status.js.map +1 -0
  255. package/dist/src/plugin/ui/quota-status.d.ts +82 -0
  256. package/dist/src/plugin/ui/quota-status.d.ts.map +1 -0
  257. package/dist/src/plugin/ui/quota-status.js +251 -0
  258. package/dist/src/plugin/ui/quota-status.js.map +1 -0
  259. package/dist/src/plugin/ui/select.d.ts +23 -0
  260. package/dist/src/plugin/ui/select.d.ts.map +1 -0
  261. package/dist/src/plugin/ui/select.js +254 -0
  262. package/dist/src/plugin/ui/select.js.map +1 -0
  263. package/dist/src/plugin/version.d.ts +2 -0
  264. package/dist/src/plugin/version.d.ts.map +1 -0
  265. package/dist/src/plugin/version.js +3 -0
  266. package/dist/src/plugin/version.js.map +1 -0
  267. package/dist/src/plugin.d.ts +32 -0
  268. package/dist/src/plugin.d.ts.map +1 -0
  269. package/dist/src/plugin.js +3125 -0
  270. package/dist/src/plugin.js.map +1 -0
  271. package/package.json +70 -0
@@ -0,0 +1,504 @@
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
+ // General Settings
57
+ // =========================================================================
58
+ /**
59
+ * Suppress most toast notifications (rate limit, account switching, etc.)
60
+ * Recovery toasts are always shown regardless of this setting.
61
+ * Env override: OPENCODE_ANTIGRAVITY_QUIET=1
62
+ * @default false
63
+ */
64
+ quiet_mode: z.boolean().default(false),
65
+ /**
66
+ * Control which sessions show toast notifications.
67
+ *
68
+ * - `root_only` (default): Only root sessions show toasts.
69
+ * Subagents and background tasks will be silent (less spam).
70
+ * - `all`: All sessions show toasts including subagents and background tasks.
71
+ *
72
+ * Debug logging captures all toasts regardless of this setting.
73
+ * Env override: OPENCODE_ANTIGRAVITY_TOAST_SCOPE=all
74
+ * @default "root_only"
75
+ */
76
+ toast_scope: ToastScopeSchema.default('root_only'),
77
+ /**
78
+ * Enable debug logging to file.
79
+ * Env override: OPENCODE_ANTIGRAVITY_DEBUG=1
80
+ * @default false
81
+ */
82
+ debug: z.boolean().default(false),
83
+ /**
84
+ * Show debug logs in the TUI log panel.
85
+ * Works independently from `debug` file logging.
86
+ * Env override: OPENCODE_ANTIGRAVITY_DEBUG_TUI=1
87
+ * @default false
88
+ */
89
+ debug_tui: z.boolean().default(false),
90
+ /**
91
+ * Custom directory for debug logs.
92
+ * Env override: OPENCODE_ANTIGRAVITY_LOG_DIR=/path/to/logs
93
+ * @default OS-specific config dir + "/antigravity-logs"
94
+ */
95
+ log_dir: z.string().optional(),
96
+ // =========================================================================
97
+ // Thinking Blocks
98
+ // =========================================================================
99
+ /**
100
+ * Preserve thinking blocks for Claude models using signature caching.
101
+ *
102
+ * When false (default): Thinking blocks are stripped for reliability.
103
+ * When true: Full context preserved, but may encounter signature errors.
104
+ *
105
+ * Env override: OPENCODE_ANTIGRAVITY_KEEP_THINKING=1
106
+ * @default false
107
+ */
108
+ keep_thinking: z.boolean().default(false),
109
+ /**
110
+ * Enable thinking warmup requests for Claude thinking models.
111
+ * When enabled, sends a separate API call at session start to warm up
112
+ * thinking signature validation. Costs 1 full API call per session.
113
+ *
114
+ * Disable to save quota — most users don't need this unless using
115
+ * keep_thinking with signature caching.
116
+ *
117
+ * Env override: OPENCODE_ANTIGRAVITY_THINKING_WARMUP=1
118
+ * @default false
119
+ */
120
+ thinking_warmup: z.boolean().default(false),
121
+ /**
122
+ * Send a lightweight cache-seeding probe when switching to a different account.
123
+ * The probe reuses the same request prefix with maxOutputTokens=1 so the
124
+ * server-side implicit cache warms up before the real request fires.
125
+ * Costs ~1 quota unit per account switch but eliminates the 0% cold-cache
126
+ * MISS that otherwise occurs on every rotation.
127
+ *
128
+ * Env override: OPENCODE_ANTIGRAVITY_CACHE_WARMUP_ON_SWITCH=1
129
+ * @default true
130
+ */
131
+ cache_warmup_on_switch: z.boolean().default(true),
132
+ // =========================================================================
133
+ // Session Recovery
134
+ // =========================================================================
135
+ /**
136
+ * Enable automatic session recovery from tool_result_missing errors.
137
+ * When enabled, shows a toast notification when recoverable errors occur.
138
+ *
139
+ * @default true
140
+ */
141
+ session_recovery: z.boolean().default(true),
142
+ /**
143
+ * Automatically send a "continue" prompt after successful recovery.
144
+ * Only applies when session_recovery is enabled.
145
+ *
146
+ * When false: Only shows toast notification, user must manually continue.
147
+ * When true: Automatically sends "continue" to resume the session.
148
+ *
149
+ * @default true
150
+ */
151
+ auto_resume: z.boolean().default(true),
152
+ /**
153
+ * Custom text to send when auto-resuming after recovery.
154
+ * Only used when auto_resume is enabled.
155
+ *
156
+ * @default "continue"
157
+ */
158
+ resume_text: z.string().default("continue"),
159
+ // =========================================================================
160
+ // Signature Caching
161
+ // =========================================================================
162
+ /**
163
+ * Signature cache configuration for persisting thinking block signatures.
164
+ * Only used when keep_thinking is enabled.
165
+ */
166
+ signature_cache: SignatureCacheConfigSchema.optional(),
167
+ // =========================================================================
168
+ // Empty Response Retry (ported from LLM-API-Key-Proxy)
169
+ // =========================================================================
170
+ /**
171
+ * Maximum retry attempts when Antigravity returns an empty response.
172
+ * Empty responses occur when no candidates/choices are returned.
173
+ *
174
+ * @default 2
175
+ */
176
+ empty_response_max_attempts: z.number().min(1).max(10).default(2),
177
+ /**
178
+ * Delay in milliseconds between empty response retries.
179
+ *
180
+ * @default 2000
181
+ */
182
+ empty_response_retry_delay_ms: z.number().min(500).max(10000).default(2000),
183
+ // =========================================================================
184
+ // Tool ID Recovery (ported from LLM-API-Key-Proxy)
185
+ // =========================================================================
186
+ /**
187
+ * Enable tool ID orphan recovery.
188
+ * When tool responses have mismatched IDs (due to context compaction),
189
+ * attempt to match them by function name or create placeholders.
190
+ *
191
+ * @default true
192
+ */
193
+ tool_id_recovery: z.boolean().default(true),
194
+ // =========================================================================
195
+ // Tool Hallucination Prevention (ported from LLM-API-Key-Proxy)
196
+ // =========================================================================
197
+ /**
198
+ * Enable tool hallucination prevention for Claude models.
199
+ * When enabled, injects:
200
+ * - Parameter signatures into tool descriptions
201
+ * - System instruction with strict tool usage rules
202
+ *
203
+ * This helps prevent Claude from using parameter names from its training
204
+ * data instead of the actual schema.
205
+ *
206
+ * @default true
207
+ */
208
+ claude_tool_hardening: z.boolean().default(true),
209
+ /**
210
+ * Enable Claude prompt auto-caching by adding top-level cache_control when absent.
211
+ *
212
+ * @default false
213
+ */
214
+ claude_prompt_auto_caching: z.boolean().default(false),
215
+ // =========================================================================
216
+ // Proactive Token Refresh (ported from LLM-API-Key-Proxy)
217
+ // =========================================================================
218
+ /**
219
+ * Enable proactive background token refresh.
220
+ * When enabled, tokens are refreshed in the background before they expire,
221
+ * ensuring requests never block on token refresh.
222
+ *
223
+ * @default true
224
+ */
225
+ proactive_token_refresh: z.boolean().default(true),
226
+ /**
227
+ * Seconds before token expiry to trigger proactive refresh.
228
+ * Default is 30 minutes (1800 seconds).
229
+ *
230
+ * @default 1800
231
+ */
232
+ proactive_refresh_buffer_seconds: z.number().min(60).max(7200).default(1800),
233
+ /**
234
+ * Interval between proactive refresh checks in seconds.
235
+ * Default is 5 minutes (300 seconds).
236
+ *
237
+ * @default 300
238
+ */
239
+ proactive_refresh_check_interval_seconds: z.number().min(30).max(1800).default(300),
240
+ // =========================================================================
241
+ // Rate Limiting
242
+ // =========================================================================
243
+ /**
244
+ * Maximum time in seconds to wait when all accounts are rate-limited.
245
+ * If the minimum wait time across all accounts exceeds this threshold,
246
+ * the plugin fails fast with an error instead of hanging.
247
+ *
248
+ * Set to 0 to disable (wait indefinitely).
249
+ *
250
+ * @default 300 (5 minutes)
251
+ */
252
+ max_rate_limit_wait_seconds: z.number().min(0).max(3600).default(300),
253
+ /**
254
+ * @deprecated Kept only for backward compatibility.
255
+ * This flag is ignored at runtime.
256
+ * Gemini requests always fall back between Antigravity and Gemini CLI quotas.
257
+ *
258
+ * @default false
259
+ */
260
+ quota_fallback: z.boolean().default(false),
261
+ /**
262
+ * Prefer gemini-cli routing before Antigravity for Gemini models.
263
+ *
264
+ * When false (default): Antigravity is tried first, then gemini-cli.
265
+ * When true: gemini-cli is tried first, then Antigravity.
266
+ *
267
+ * @default false
268
+ */
269
+ cli_first: z.boolean().default(false),
270
+ /**
271
+ * Strategy for selecting accounts when making requests.
272
+ * Env override: OPENCODE_ANTIGRAVITY_ACCOUNT_SELECTION_STRATEGY
273
+ * @default "hybrid"
274
+ */
275
+ account_selection_strategy: AccountSelectionStrategySchema.default('hybrid'),
276
+ /**
277
+ * Enable PID-based account offset for multi-session distribution.
278
+ *
279
+ * When enabled, different sessions (PIDs) will prefer different starting
280
+ * accounts, which helps distribute load when running multiple parallel agents.
281
+ *
282
+ * When disabled (default), accounts start from the same index, which preserves
283
+ * Anthropic's prompt cache across restarts (recommended for single-session use).
284
+ *
285
+ * Env override: OPENCODE_ANTIGRAVITY_PID_OFFSET_ENABLED=1
286
+ * @default false
287
+ */
288
+ pid_offset_enabled: z.boolean().default(false),
289
+ /**
290
+ * Switch to another account immediately on first rate limit (after 1s delay).
291
+ * When disabled, retries same account first, then switches on second rate limit.
292
+ *
293
+ * @default true
294
+ */
295
+ switch_on_first_rate_limit: z.boolean().default(true),
296
+ /**
297
+ * Maximum number of account switches per request before giving up.
298
+ * Each switch re-sends the full request payload, consuming quota on the new account.
299
+ * Lower values reduce quota waste from cascading rate limits across accounts.
300
+ *
301
+ * Env override: OPENCODE_ANTIGRAVITY_MAX_ACCOUNT_SWITCHES
302
+ * @default 10
303
+ */
304
+ max_account_switches: z.number().min(0).max(500).default(10),
305
+ /**
306
+ * Allow falling back between quota pools (antigravity ↔ gemini-cli) when rate-limited.
307
+ * When enabled, if one quota pool is exhausted the plugin re-sends the SAME request
308
+ * using the alternate header style, consuming tokens from BOTH pools.
309
+ * Disable to prevent double-spending quota across pools — the plugin will only
310
+ * rotate accounts instead.
311
+ * Only applies to Gemini models (Claude always uses antigravity).
312
+ *
313
+ * Env override: OPENCODE_ANTIGRAVITY_QUOTA_STYLE_FALLBACK
314
+ * @default false
315
+ */
316
+ quota_style_fallback: z.boolean().default(false),
317
+ /**
318
+ * Scheduling mode for rate limit behavior. *
319
+ * - `cache_first`: Wait for same account to recover (preserves prompt cache). Default.
320
+ * - `balance`: Switch account immediately on rate limit. Maximum availability.
321
+ * - `performance_first`: Round-robin distribution for maximum throughput.
322
+ *
323
+ * Env override: OPENCODE_ANTIGRAVITY_SCHEDULING_MODE
324
+ * @default "cache_first"
325
+ */
326
+ scheduling_mode: SchedulingModeSchema.default('cache_first'),
327
+ /**
328
+ * Maximum seconds to wait for same account in cache_first mode.
329
+ * If the account's rate limit reset time exceeds this, switch accounts.
330
+ *
331
+ * @default 60
332
+ */
333
+ max_cache_first_wait_seconds: z.number().min(5).max(300).default(60),
334
+ /**
335
+ * TTL in seconds for failure count expiration.
336
+ * After this period of no failures, consecutiveFailures resets to 0.
337
+ * This prevents old failures from permanently penalizing an account.
338
+ *
339
+ * @default 3600 (1 hour)
340
+ */
341
+ failure_ttl_seconds: z.number().min(60).max(7200).default(3600),
342
+ /**
343
+ * Default retry delay in seconds when API doesn't return a retry-after header.
344
+ * Lower values allow faster retries but may trigger more 429 errors.
345
+ *
346
+ * @default 60
347
+ */
348
+ default_retry_after_seconds: z.number().min(1).max(300).default(60),
349
+ /**
350
+ * Maximum backoff delay in seconds for exponential retry.
351
+ * This caps how long the exponential backoff can grow.
352
+ *
353
+ * @default 60
354
+ */
355
+ max_backoff_seconds: z.number().min(5).max(300).default(60),
356
+ /**
357
+ * Maximum random delay in milliseconds before each API request.
358
+ * Adds timing jitter to break predictable request cadence patterns.
359
+ * Set to 0 to disable request jitter.
360
+ *
361
+ * @default 0
362
+ */
363
+ request_jitter_max_ms: z.number().min(0).max(5000).default(0),
364
+ /**
365
+ * Delay in milliseconds before switching to the next account after a rate limit.
366
+ * Lower values reduce total wait time when cycling through accounts.
367
+ * Higher values give the rate-limited account more time to recover.
368
+ *
369
+ * @default 500
370
+ */
371
+ switch_account_delay_ms: z.number().min(0).max(10000).default(500),
372
+ /**
373
+ * Soft quota threshold percentage (1-100).
374
+ * When an account's quota usage reaches this percentage, skip it during
375
+ * account selection (same as if it were rate-limited).
376
+ *
377
+ * Example: 80 means skip account when 80% of quota is used (20% remaining).
378
+ * Set to 100 to disable soft quota protection.
379
+ *
380
+ * @default 80
381
+ */
382
+ soft_quota_threshold_percent: z.number().min(1).max(100).default(80),
383
+ /**
384
+ * How often to refresh quota data in the background (in minutes).
385
+ * Quota is refreshed opportunistically after successful API requests.
386
+ * Set to 0 to disable automatic refresh (manual only via Check quotas).
387
+ *
388
+ * @default 15
389
+ */
390
+ quota_refresh_interval_minutes: z.number().min(0).max(120).default(30),
391
+ /**
392
+ * How long quota cache is considered fresh for threshold checks (in minutes).
393
+ * After this time, cache is stale and account is allowed (fail-open).
394
+ *
395
+ * "auto" = derive from refresh interval: max(2 * refresh_interval, 10)
396
+ *
397
+ * @default "auto"
398
+ */
399
+ soft_quota_cache_ttl_minutes: z.union([
400
+ z.literal("auto"),
401
+ z.number().min(1).max(120)
402
+ ]).default("auto"),
403
+ /**
404
+ * Proactive rotation threshold percentage (0-100).
405
+ * After a successful request, if the current account's remaining quota
406
+ * drops below this percentage, proactively switch to a warm-cache account
407
+ * before the next request — avoiding a forced 429 mid-conversation.
408
+ *
409
+ * Set to 0 to disable proactive rotation.
410
+ *
411
+ * @default 20
412
+ * @env OPENCODE_ANTIGRAVITY_PROACTIVE_ROTATION_THRESHOLD
413
+ */
414
+ proactive_rotation_threshold_percent: z.number().min(0).max(100).default(20),
415
+ // =========================================================================
416
+ // Health Score (used by hybrid strategy)
417
+ // =========================================================================
418
+ health_score: z.object({
419
+ initial: z.number().min(0).max(100).default(70),
420
+ success_reward: z.number().min(0).max(10).default(1),
421
+ rate_limit_penalty: z.number().min(-50).max(0).default(-10),
422
+ failure_penalty: z.number().min(-100).max(0).default(-20),
423
+ recovery_rate_per_hour: z.number().min(0).max(20).default(2),
424
+ min_usable: z.number().min(0).max(100).default(50),
425
+ max_score: z.number().min(50).max(100).default(100),
426
+ }).optional(),
427
+ // =========================================================================
428
+ // Token Bucket (for hybrid strategy)
429
+ // =========================================================================
430
+ token_bucket: z.object({
431
+ max_tokens: z.number().min(1).max(1000).default(50),
432
+ regeneration_rate_per_minute: z.number().min(0.1).max(60).default(6),
433
+ initial_tokens: z.number().min(1).max(1000).default(50),
434
+ }).optional(),
435
+ // =========================================================================
436
+ // Auto-Update
437
+ // =========================================================================
438
+ /**
439
+ * Enable automatic plugin updates.
440
+ * @default true
441
+ */
442
+ auto_update: z.boolean().default(true),
443
+ });
444
+ /**
445
+ * Default configuration values.
446
+ */
447
+ export const DEFAULT_CONFIG = {
448
+ quiet_mode: false,
449
+ toast_scope: 'root_only',
450
+ debug: false,
451
+ debug_tui: false,
452
+ keep_thinking: false,
453
+ thinking_warmup: false,
454
+ cache_warmup_on_switch: true,
455
+ session_recovery: true, auto_resume: true,
456
+ resume_text: "continue",
457
+ empty_response_max_attempts: 2,
458
+ empty_response_retry_delay_ms: 2000,
459
+ tool_id_recovery: true,
460
+ claude_tool_hardening: true,
461
+ claude_prompt_auto_caching: false,
462
+ proactive_token_refresh: true,
463
+ proactive_refresh_buffer_seconds: 1800,
464
+ proactive_refresh_check_interval_seconds: 300,
465
+ max_rate_limit_wait_seconds: 300,
466
+ quota_fallback: false,
467
+ cli_first: false,
468
+ account_selection_strategy: 'hybrid',
469
+ pid_offset_enabled: false,
470
+ switch_on_first_rate_limit: true,
471
+ max_account_switches: 10,
472
+ quota_style_fallback: false,
473
+ scheduling_mode: 'cache_first', max_cache_first_wait_seconds: 60,
474
+ failure_ttl_seconds: 3600,
475
+ default_retry_after_seconds: 60,
476
+ max_backoff_seconds: 60,
477
+ request_jitter_max_ms: 0,
478
+ switch_account_delay_ms: 500,
479
+ soft_quota_threshold_percent: 80,
480
+ quota_refresh_interval_minutes: 30,
481
+ soft_quota_cache_ttl_minutes: "auto",
482
+ proactive_rotation_threshold_percent: 20,
483
+ auto_update: true, signature_cache: {
484
+ enabled: true,
485
+ memory_ttl_seconds: 3600,
486
+ disk_ttl_seconds: 172800,
487
+ write_interval_seconds: 60,
488
+ },
489
+ health_score: {
490
+ initial: 70,
491
+ success_reward: 1,
492
+ rate_limit_penalty: -10,
493
+ failure_penalty: -20,
494
+ recovery_rate_per_hour: 2,
495
+ min_usable: 50,
496
+ max_score: 100,
497
+ },
498
+ token_bucket: {
499
+ max_tokens: 50,
500
+ regeneration_rate_per_minute: 6,
501
+ initial_tokens: 50,
502
+ },
503
+ };
504
+ //# 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,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC;A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M;QACxB,sBAAsB,EAAE,EAAE;KAC3B;IACD,YAAY,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,cAAc,EAAE,CAAC;QACjB,kBAAkB,EAAE,CAAC,EAAE;QACvB,eAAe,EAAE,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,CAsE7B"}