antigravity-auth 1.6.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 (256) hide show
  1. package/README.md +61 -0
  2. package/dist/antigravity/oauth.d.ts +30 -0
  3. package/dist/antigravity/oauth.js +170 -0
  4. package/dist/claude/login.d.ts +7 -0
  5. package/dist/claude/login.js +480 -0
  6. package/dist/claude/menu-helpers.d.ts +22 -0
  7. package/dist/claude/menu-helpers.js +281 -0
  8. package/dist/claude/proxy-manager.d.ts +11 -0
  9. package/dist/claude/proxy-manager.js +129 -0
  10. package/dist/claude/proxy.d.ts +1 -0
  11. package/dist/claude/proxy.js +733 -0
  12. package/dist/constants.d.ts +138 -0
  13. package/dist/constants.js +216 -0
  14. package/dist/hooks/auto-update-checker/cache.d.ts +2 -0
  15. package/dist/hooks/auto-update-checker/cache.js +70 -0
  16. package/dist/hooks/auto-update-checker/checker.d.ts +15 -0
  17. package/dist/hooks/auto-update-checker/checker.js +233 -0
  18. package/dist/hooks/auto-update-checker/constants.d.ts +8 -0
  19. package/dist/hooks/auto-update-checker/constants.js +22 -0
  20. package/dist/hooks/auto-update-checker/index.d.ts +33 -0
  21. package/dist/hooks/auto-update-checker/index.js +121 -0
  22. package/dist/hooks/auto-update-checker/logging.d.ts +2 -0
  23. package/dist/hooks/auto-update-checker/logging.js +8 -0
  24. package/dist/hooks/auto-update-checker/types.d.ts +24 -0
  25. package/dist/hooks/auto-update-checker/types.js +1 -0
  26. package/dist/index.d.ts +6 -0
  27. package/dist/index.js +5 -0
  28. package/dist/opencode/hooks/auto-update-checker/cache.d.ts +2 -0
  29. package/dist/opencode/hooks/auto-update-checker/cache.js +70 -0
  30. package/dist/opencode/hooks/auto-update-checker/checker.d.ts +15 -0
  31. package/dist/opencode/hooks/auto-update-checker/checker.js +233 -0
  32. package/dist/opencode/hooks/auto-update-checker/constants.d.ts +8 -0
  33. package/dist/opencode/hooks/auto-update-checker/constants.js +22 -0
  34. package/dist/opencode/hooks/auto-update-checker/index.d.ts +33 -0
  35. package/dist/opencode/hooks/auto-update-checker/index.js +121 -0
  36. package/dist/opencode/hooks/auto-update-checker/logging.d.ts +2 -0
  37. package/dist/opencode/hooks/auto-update-checker/logging.js +8 -0
  38. package/dist/opencode/hooks/auto-update-checker/types.d.ts +24 -0
  39. package/dist/opencode/hooks/auto-update-checker/types.js +1 -0
  40. package/dist/opencode/plugin.d.ts +29 -0
  41. package/dist/opencode/plugin.js +2954 -0
  42. package/dist/plugin/accounts.d.ts +173 -0
  43. package/dist/plugin/accounts.js +966 -0
  44. package/dist/plugin/auth.d.ts +20 -0
  45. package/dist/plugin/auth.js +44 -0
  46. package/dist/plugin/cache/index.d.ts +4 -0
  47. package/dist/plugin/cache/index.js +4 -0
  48. package/dist/plugin/cache/signature-cache.d.ts +110 -0
  49. package/dist/plugin/cache/signature-cache.js +347 -0
  50. package/dist/plugin/cache.d.ts +43 -0
  51. package/dist/plugin/cache.js +180 -0
  52. package/dist/plugin/cli.d.ts +26 -0
  53. package/dist/plugin/cli.js +126 -0
  54. package/dist/plugin/config/index.d.ts +15 -0
  55. package/dist/plugin/config/index.js +15 -0
  56. package/dist/plugin/config/loader.d.ts +38 -0
  57. package/dist/plugin/config/loader.js +150 -0
  58. package/dist/plugin/config/models.d.ts +26 -0
  59. package/dist/plugin/config/models.js +95 -0
  60. package/dist/plugin/config/schema.d.ts +144 -0
  61. package/dist/plugin/config/schema.js +458 -0
  62. package/dist/plugin/config/updater.d.ts +76 -0
  63. package/dist/plugin/config/updater.js +205 -0
  64. package/dist/plugin/core/streaming/index.d.ts +2 -0
  65. package/dist/plugin/core/streaming/index.js +2 -0
  66. package/dist/plugin/core/streaming/transformer.d.ts +9 -0
  67. package/dist/plugin/core/streaming/transformer.js +301 -0
  68. package/dist/plugin/core/streaming/types.d.ts +28 -0
  69. package/dist/plugin/core/streaming/types.js +1 -0
  70. package/dist/plugin/debug.d.ts +93 -0
  71. package/dist/plugin/debug.js +375 -0
  72. package/dist/plugin/errors.d.ts +27 -0
  73. package/dist/plugin/errors.js +41 -0
  74. package/dist/plugin/fingerprint.d.ts +69 -0
  75. package/dist/plugin/fingerprint.js +137 -0
  76. package/dist/plugin/image-saver.d.ts +24 -0
  77. package/dist/plugin/image-saver.js +78 -0
  78. package/dist/plugin/logger.d.ts +35 -0
  79. package/dist/plugin/logger.js +67 -0
  80. package/dist/plugin/logging-utils.d.ts +22 -0
  81. package/dist/plugin/logging-utils.js +91 -0
  82. package/dist/plugin/project.d.ts +32 -0
  83. package/dist/plugin/project.js +229 -0
  84. package/dist/plugin/quota.d.ts +34 -0
  85. package/dist/plugin/quota.js +261 -0
  86. package/dist/plugin/recovery/constants.d.ts +21 -0
  87. package/dist/plugin/recovery/constants.js +42 -0
  88. package/dist/plugin/recovery/index.d.ts +11 -0
  89. package/dist/plugin/recovery/index.js +11 -0
  90. package/dist/plugin/recovery/storage.d.ts +23 -0
  91. package/dist/plugin/recovery/storage.js +340 -0
  92. package/dist/plugin/recovery/types.d.ts +115 -0
  93. package/dist/plugin/recovery/types.js +6 -0
  94. package/dist/plugin/recovery.d.ts +60 -0
  95. package/dist/plugin/recovery.js +360 -0
  96. package/dist/plugin/refresh-queue.d.ts +99 -0
  97. package/dist/plugin/refresh-queue.js +235 -0
  98. package/dist/plugin/request-helpers.d.ts +281 -0
  99. package/dist/plugin/request-helpers.js +2200 -0
  100. package/dist/plugin/request.d.ts +110 -0
  101. package/dist/plugin/request.js +1489 -0
  102. package/dist/plugin/rotation.d.ts +182 -0
  103. package/dist/plugin/rotation.js +364 -0
  104. package/dist/plugin/search.d.ts +31 -0
  105. package/dist/plugin/search.js +185 -0
  106. package/dist/plugin/server.d.ts +22 -0
  107. package/dist/plugin/server.js +306 -0
  108. package/dist/plugin/storage.d.ts +136 -0
  109. package/dist/plugin/storage.js +599 -0
  110. package/dist/plugin/stores/signature-store.d.ts +4 -0
  111. package/dist/plugin/stores/signature-store.js +24 -0
  112. package/dist/plugin/thinking-recovery.d.ts +89 -0
  113. package/dist/plugin/thinking-recovery.js +289 -0
  114. package/dist/plugin/token.d.ts +18 -0
  115. package/dist/plugin/token.js +127 -0
  116. package/dist/plugin/transform/claude.d.ts +79 -0
  117. package/dist/plugin/transform/claude.js +256 -0
  118. package/dist/plugin/transform/cross-model-sanitizer.d.ts +34 -0
  119. package/dist/plugin/transform/cross-model-sanitizer.js +224 -0
  120. package/dist/plugin/transform/gemini.d.ts +132 -0
  121. package/dist/plugin/transform/gemini.js +659 -0
  122. package/dist/plugin/transform/index.d.ts +14 -0
  123. package/dist/plugin/transform/index.js +9 -0
  124. package/dist/plugin/transform/model-resolver.d.ts +98 -0
  125. package/dist/plugin/transform/model-resolver.js +320 -0
  126. package/dist/plugin/transform/types.d.ts +110 -0
  127. package/dist/plugin/transform/types.js +1 -0
  128. package/dist/plugin/types.d.ts +95 -0
  129. package/dist/plugin/types.js +1 -0
  130. package/dist/plugin/ui/ansi.d.ts +31 -0
  131. package/dist/plugin/ui/ansi.js +45 -0
  132. package/dist/plugin/ui/auth-menu.d.ts +47 -0
  133. package/dist/plugin/ui/auth-menu.js +199 -0
  134. package/dist/plugin/ui/confirm.d.ts +1 -0
  135. package/dist/plugin/ui/confirm.js +14 -0
  136. package/dist/plugin/ui/select.d.ts +22 -0
  137. package/dist/plugin/ui/select.js +243 -0
  138. package/dist/plugin/version.d.ts +18 -0
  139. package/dist/plugin/version.js +79 -0
  140. package/dist/src/antigravity/oauth.d.ts +30 -0
  141. package/dist/src/antigravity/oauth.js +170 -0
  142. package/dist/src/constants.d.ts +138 -0
  143. package/dist/src/constants.js +216 -0
  144. package/dist/src/hooks/auto-update-checker/cache.d.ts +2 -0
  145. package/dist/src/hooks/auto-update-checker/cache.js +70 -0
  146. package/dist/src/hooks/auto-update-checker/checker.d.ts +15 -0
  147. package/dist/src/hooks/auto-update-checker/checker.js +233 -0
  148. package/dist/src/hooks/auto-update-checker/constants.d.ts +8 -0
  149. package/dist/src/hooks/auto-update-checker/constants.js +22 -0
  150. package/dist/src/hooks/auto-update-checker/index.d.ts +33 -0
  151. package/dist/src/hooks/auto-update-checker/index.js +121 -0
  152. package/dist/src/hooks/auto-update-checker/logging.d.ts +2 -0
  153. package/dist/src/hooks/auto-update-checker/logging.js +8 -0
  154. package/dist/src/hooks/auto-update-checker/types.d.ts +24 -0
  155. package/dist/src/hooks/auto-update-checker/types.js +1 -0
  156. package/dist/src/index.d.ts +6 -0
  157. package/dist/src/index.js +5 -0
  158. package/dist/src/plugin/accounts.d.ts +173 -0
  159. package/dist/src/plugin/accounts.js +966 -0
  160. package/dist/src/plugin/auth.d.ts +20 -0
  161. package/dist/src/plugin/auth.js +44 -0
  162. package/dist/src/plugin/cache/index.d.ts +4 -0
  163. package/dist/src/plugin/cache/index.js +4 -0
  164. package/dist/src/plugin/cache/signature-cache.d.ts +110 -0
  165. package/dist/src/plugin/cache/signature-cache.js +347 -0
  166. package/dist/src/plugin/cache.d.ts +43 -0
  167. package/dist/src/plugin/cache.js +180 -0
  168. package/dist/src/plugin/cli.d.ts +26 -0
  169. package/dist/src/plugin/cli.js +126 -0
  170. package/dist/src/plugin/config/index.d.ts +15 -0
  171. package/dist/src/plugin/config/index.js +15 -0
  172. package/dist/src/plugin/config/loader.d.ts +38 -0
  173. package/dist/src/plugin/config/loader.js +150 -0
  174. package/dist/src/plugin/config/models.d.ts +26 -0
  175. package/dist/src/plugin/config/models.js +95 -0
  176. package/dist/src/plugin/config/schema.d.ts +144 -0
  177. package/dist/src/plugin/config/schema.js +458 -0
  178. package/dist/src/plugin/config/updater.d.ts +76 -0
  179. package/dist/src/plugin/config/updater.js +205 -0
  180. package/dist/src/plugin/core/streaming/index.d.ts +2 -0
  181. package/dist/src/plugin/core/streaming/index.js +2 -0
  182. package/dist/src/plugin/core/streaming/transformer.d.ts +9 -0
  183. package/dist/src/plugin/core/streaming/transformer.js +301 -0
  184. package/dist/src/plugin/core/streaming/types.d.ts +28 -0
  185. package/dist/src/plugin/core/streaming/types.js +1 -0
  186. package/dist/src/plugin/debug.d.ts +93 -0
  187. package/dist/src/plugin/debug.js +375 -0
  188. package/dist/src/plugin/errors.d.ts +27 -0
  189. package/dist/src/plugin/errors.js +41 -0
  190. package/dist/src/plugin/fingerprint.d.ts +69 -0
  191. package/dist/src/plugin/fingerprint.js +137 -0
  192. package/dist/src/plugin/image-saver.d.ts +24 -0
  193. package/dist/src/plugin/image-saver.js +78 -0
  194. package/dist/src/plugin/logger.d.ts +35 -0
  195. package/dist/src/plugin/logger.js +67 -0
  196. package/dist/src/plugin/logging-utils.d.ts +22 -0
  197. package/dist/src/plugin/logging-utils.js +91 -0
  198. package/dist/src/plugin/project.d.ts +32 -0
  199. package/dist/src/plugin/project.js +229 -0
  200. package/dist/src/plugin/quota.d.ts +34 -0
  201. package/dist/src/plugin/quota.js +261 -0
  202. package/dist/src/plugin/recovery/constants.d.ts +21 -0
  203. package/dist/src/plugin/recovery/constants.js +42 -0
  204. package/dist/src/plugin/recovery/index.d.ts +11 -0
  205. package/dist/src/plugin/recovery/index.js +11 -0
  206. package/dist/src/plugin/recovery/storage.d.ts +23 -0
  207. package/dist/src/plugin/recovery/storage.js +340 -0
  208. package/dist/src/plugin/recovery/types.d.ts +115 -0
  209. package/dist/src/plugin/recovery/types.js +6 -0
  210. package/dist/src/plugin/recovery.d.ts +60 -0
  211. package/dist/src/plugin/recovery.js +360 -0
  212. package/dist/src/plugin/refresh-queue.d.ts +99 -0
  213. package/dist/src/plugin/refresh-queue.js +235 -0
  214. package/dist/src/plugin/request-helpers.d.ts +281 -0
  215. package/dist/src/plugin/request-helpers.js +2200 -0
  216. package/dist/src/plugin/request.d.ts +110 -0
  217. package/dist/src/plugin/request.js +1489 -0
  218. package/dist/src/plugin/rotation.d.ts +182 -0
  219. package/dist/src/plugin/rotation.js +364 -0
  220. package/dist/src/plugin/search.d.ts +31 -0
  221. package/dist/src/plugin/search.js +185 -0
  222. package/dist/src/plugin/server.d.ts +22 -0
  223. package/dist/src/plugin/server.js +306 -0
  224. package/dist/src/plugin/storage.d.ts +136 -0
  225. package/dist/src/plugin/storage.js +599 -0
  226. package/dist/src/plugin/stores/signature-store.d.ts +4 -0
  227. package/dist/src/plugin/stores/signature-store.js +24 -0
  228. package/dist/src/plugin/thinking-recovery.d.ts +89 -0
  229. package/dist/src/plugin/thinking-recovery.js +289 -0
  230. package/dist/src/plugin/token.d.ts +18 -0
  231. package/dist/src/plugin/token.js +127 -0
  232. package/dist/src/plugin/transform/claude.d.ts +79 -0
  233. package/dist/src/plugin/transform/claude.js +256 -0
  234. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +34 -0
  235. package/dist/src/plugin/transform/cross-model-sanitizer.js +224 -0
  236. package/dist/src/plugin/transform/gemini.d.ts +132 -0
  237. package/dist/src/plugin/transform/gemini.js +659 -0
  238. package/dist/src/plugin/transform/index.d.ts +14 -0
  239. package/dist/src/plugin/transform/index.js +9 -0
  240. package/dist/src/plugin/transform/model-resolver.d.ts +98 -0
  241. package/dist/src/plugin/transform/model-resolver.js +320 -0
  242. package/dist/src/plugin/transform/types.d.ts +110 -0
  243. package/dist/src/plugin/transform/types.js +1 -0
  244. package/dist/src/plugin/types.d.ts +95 -0
  245. package/dist/src/plugin/types.js +1 -0
  246. package/dist/src/plugin/ui/ansi.d.ts +31 -0
  247. package/dist/src/plugin/ui/ansi.js +45 -0
  248. package/dist/src/plugin/ui/auth-menu.d.ts +47 -0
  249. package/dist/src/plugin/ui/auth-menu.js +199 -0
  250. package/dist/src/plugin/ui/confirm.d.ts +1 -0
  251. package/dist/src/plugin/ui/confirm.js +14 -0
  252. package/dist/src/plugin/ui/select.d.ts +22 -0
  253. package/dist/src/plugin/ui/select.js +243 -0
  254. package/dist/src/plugin/version.d.ts +18 -0
  255. package/dist/src/plugin/version.js +79 -0
  256. package/package.json +54 -0
@@ -0,0 +1,233 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { PACKAGE_NAME, NPM_REGISTRY_URL, NPM_FETCH_TIMEOUT, INSTALLED_PACKAGE_JSON, USER_OPENCODE_CONFIG, USER_OPENCODE_CONFIG_JSONC, } from "./constants";
5
+ import { logAutoUpdate } from "./logging";
6
+ export function isLocalDevMode(directory) {
7
+ return getLocalDevPath(directory) !== null;
8
+ }
9
+ function stripJsonComments(json) {
10
+ return json
11
+ .replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => (g ? "" : m))
12
+ .replace(/,(\s*[}\]])/g, "$1");
13
+ }
14
+ function getConfigPaths(directory) {
15
+ return [
16
+ path.join(directory, ".opencode", "opencode.json"),
17
+ path.join(directory, ".opencode", "opencode.jsonc"),
18
+ path.join(directory, ".opencode.json"),
19
+ USER_OPENCODE_CONFIG,
20
+ USER_OPENCODE_CONFIG_JSONC,
21
+ ];
22
+ }
23
+ export function getLocalDevPath(directory) {
24
+ for (const configPath of getConfigPaths(directory)) {
25
+ try {
26
+ if (!fs.existsSync(configPath))
27
+ continue;
28
+ const content = fs.readFileSync(configPath, "utf-8");
29
+ const config = JSON.parse(stripJsonComments(content));
30
+ const plugins = config.plugin ?? [];
31
+ for (const entry of plugins) {
32
+ if (entry.startsWith("file://") && entry.includes(PACKAGE_NAME)) {
33
+ try {
34
+ return fileURLToPath(entry);
35
+ }
36
+ catch {
37
+ return entry.replace("file://", "");
38
+ }
39
+ }
40
+ }
41
+ }
42
+ catch {
43
+ continue;
44
+ }
45
+ }
46
+ return null;
47
+ }
48
+ function findPackageJsonUp(startPath) {
49
+ try {
50
+ const stat = fs.statSync(startPath);
51
+ let dir = stat.isDirectory() ? startPath : path.dirname(startPath);
52
+ for (let i = 0; i < 10; i++) {
53
+ const pkgPath = path.join(dir, "package.json");
54
+ if (fs.existsSync(pkgPath)) {
55
+ try {
56
+ const content = fs.readFileSync(pkgPath, "utf-8");
57
+ const pkg = JSON.parse(content);
58
+ if (pkg.name === PACKAGE_NAME)
59
+ return pkgPath;
60
+ }
61
+ catch {
62
+ continue;
63
+ }
64
+ }
65
+ const parent = path.dirname(dir);
66
+ if (parent === dir)
67
+ break;
68
+ dir = parent;
69
+ }
70
+ }
71
+ catch {
72
+ return null;
73
+ }
74
+ return null;
75
+ }
76
+ export function getLocalDevVersion(directory) {
77
+ const localPath = getLocalDevPath(directory);
78
+ if (!localPath)
79
+ return null;
80
+ try {
81
+ const pkgPath = findPackageJsonUp(localPath);
82
+ if (!pkgPath)
83
+ return null;
84
+ const content = fs.readFileSync(pkgPath, "utf-8");
85
+ const pkg = JSON.parse(content);
86
+ return pkg.version ?? null;
87
+ }
88
+ catch {
89
+ return null;
90
+ }
91
+ }
92
+ export function findPluginEntry(directory) {
93
+ for (const configPath of getConfigPaths(directory)) {
94
+ try {
95
+ if (!fs.existsSync(configPath))
96
+ continue;
97
+ const content = fs.readFileSync(configPath, "utf-8");
98
+ const config = JSON.parse(stripJsonComments(content));
99
+ const plugins = config.plugin ?? [];
100
+ for (const entry of plugins) {
101
+ if (entry === PACKAGE_NAME) {
102
+ return { entry, isPinned: false, pinnedVersion: null, configPath };
103
+ }
104
+ if (entry.startsWith(`${PACKAGE_NAME}@`)) {
105
+ const pinnedVersion = entry.slice(PACKAGE_NAME.length + 1);
106
+ const isPinned = pinnedVersion !== "latest";
107
+ return { entry, isPinned, pinnedVersion: isPinned ? pinnedVersion : null, configPath };
108
+ }
109
+ if (entry.startsWith("file://") && entry.includes(PACKAGE_NAME)) {
110
+ return { entry, isPinned: false, pinnedVersion: null, configPath };
111
+ }
112
+ }
113
+ }
114
+ catch {
115
+ continue;
116
+ }
117
+ }
118
+ return null;
119
+ }
120
+ export function getCachedVersion() {
121
+ try {
122
+ if (fs.existsSync(INSTALLED_PACKAGE_JSON)) {
123
+ const content = fs.readFileSync(INSTALLED_PACKAGE_JSON, "utf-8");
124
+ const pkg = JSON.parse(content);
125
+ if (pkg.version)
126
+ return pkg.version;
127
+ }
128
+ }
129
+ catch {
130
+ return null;
131
+ }
132
+ try {
133
+ const currentDir = path.dirname(fileURLToPath(import.meta.url));
134
+ const pkgPath = findPackageJsonUp(currentDir);
135
+ if (pkgPath) {
136
+ const content = fs.readFileSync(pkgPath, "utf-8");
137
+ const pkg = JSON.parse(content);
138
+ if (pkg.version)
139
+ return pkg.version;
140
+ }
141
+ }
142
+ catch (err) {
143
+ logAutoUpdate(`Failed to resolve version from current directory: ${err}`);
144
+ }
145
+ return null;
146
+ }
147
+ export function updatePinnedVersion(configPath, oldEntry, newVersion) {
148
+ try {
149
+ const content = fs.readFileSync(configPath, "utf-8");
150
+ const newEntry = `${PACKAGE_NAME}@${newVersion}`;
151
+ const pluginMatch = content.match(/"plugin"\s*:\s*\[/);
152
+ if (!pluginMatch || pluginMatch.index === undefined) {
153
+ logAutoUpdate(`No "plugin" array found in ${configPath}`);
154
+ return false;
155
+ }
156
+ const startIdx = pluginMatch.index + pluginMatch[0].length;
157
+ let bracketCount = 1;
158
+ let endIdx = startIdx;
159
+ for (let i = startIdx; i < content.length && bracketCount > 0; i++) {
160
+ if (content[i] === "[")
161
+ bracketCount++;
162
+ else if (content[i] === "]")
163
+ bracketCount--;
164
+ endIdx = i;
165
+ }
166
+ const before = content.slice(0, startIdx);
167
+ const pluginArrayContent = content.slice(startIdx, endIdx);
168
+ const after = content.slice(endIdx);
169
+ const escapedOldEntry = oldEntry.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
170
+ const regex = new RegExp(`["']${escapedOldEntry}["']`);
171
+ if (!regex.test(pluginArrayContent)) {
172
+ logAutoUpdate(`Entry "${oldEntry}" not found in plugin array of ${configPath}`);
173
+ return false;
174
+ }
175
+ const updatedPluginArray = pluginArrayContent.replace(regex, `"${newEntry}"`);
176
+ const updatedContent = before + updatedPluginArray + after;
177
+ if (updatedContent === content) {
178
+ logAutoUpdate(`No changes made to ${configPath}`);
179
+ return false;
180
+ }
181
+ fs.writeFileSync(configPath, updatedContent, "utf-8");
182
+ logAutoUpdate(`Updated ${configPath}: ${oldEntry} → ${newEntry}`);
183
+ return true;
184
+ }
185
+ catch (err) {
186
+ console.error(`[auto-update-checker] Failed to update config file ${configPath}:`, err);
187
+ return false;
188
+ }
189
+ }
190
+ export async function getLatestVersion() {
191
+ const controller = new AbortController();
192
+ const timeoutId = setTimeout(() => controller.abort(), NPM_FETCH_TIMEOUT);
193
+ try {
194
+ const response = await fetch(NPM_REGISTRY_URL, {
195
+ signal: controller.signal,
196
+ headers: { Accept: "application/json" },
197
+ });
198
+ if (!response.ok)
199
+ return null;
200
+ const data = (await response.json());
201
+ return data.latest ?? null;
202
+ }
203
+ catch {
204
+ return null;
205
+ }
206
+ finally {
207
+ clearTimeout(timeoutId);
208
+ }
209
+ }
210
+ export async function checkForUpdate(directory) {
211
+ if (isLocalDevMode(directory)) {
212
+ logAutoUpdate("Local dev mode detected, skipping update check");
213
+ return { needsUpdate: false, currentVersion: null, latestVersion: null, isLocalDev: true, isPinned: false };
214
+ }
215
+ const pluginInfo = findPluginEntry(directory);
216
+ if (!pluginInfo) {
217
+ logAutoUpdate("Plugin not found in config");
218
+ return { needsUpdate: false, currentVersion: null, latestVersion: null, isLocalDev: false, isPinned: false };
219
+ }
220
+ const currentVersion = getCachedVersion() ?? pluginInfo.pinnedVersion;
221
+ if (!currentVersion) {
222
+ logAutoUpdate("No version found (cached or pinned)");
223
+ return { needsUpdate: false, currentVersion: null, latestVersion: null, isLocalDev: false, isPinned: pluginInfo.isPinned };
224
+ }
225
+ const latestVersion = await getLatestVersion();
226
+ if (!latestVersion) {
227
+ logAutoUpdate("Failed to fetch latest version");
228
+ return { needsUpdate: false, currentVersion, latestVersion: null, isLocalDev: false, isPinned: pluginInfo.isPinned };
229
+ }
230
+ const needsUpdate = currentVersion !== latestVersion;
231
+ logAutoUpdate(`Current: ${currentVersion}, Latest: ${latestVersion}, NeedsUpdate: ${needsUpdate}`);
232
+ return { needsUpdate, currentVersion, latestVersion, isLocalDev: false, isPinned: pluginInfo.isPinned };
233
+ }
@@ -0,0 +1,8 @@
1
+ export declare const PACKAGE_NAME = "opencode-antigravity-auth";
2
+ export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org/-/package/opencode-antigravity-auth/dist-tags";
3
+ export declare const NPM_FETCH_TIMEOUT = 5000;
4
+ export declare const CACHE_DIR: string;
5
+ export declare const INSTALLED_PACKAGE_JSON: string;
6
+ export declare const USER_CONFIG_DIR: string;
7
+ export declare const USER_OPENCODE_CONFIG: string;
8
+ export declare const USER_OPENCODE_CONFIG_JSONC: string;
@@ -0,0 +1,22 @@
1
+ import * as path from "node:path";
2
+ import * as os from "node:os";
3
+ export const PACKAGE_NAME = "opencode-antigravity-auth";
4
+ export const NPM_REGISTRY_URL = `https://registry.npmjs.org/-/package/${PACKAGE_NAME}/dist-tags`;
5
+ export const NPM_FETCH_TIMEOUT = 5000;
6
+ function getCacheDir() {
7
+ if (process.platform === "win32") {
8
+ return path.join(process.env.LOCALAPPDATA ?? os.homedir(), "opencode");
9
+ }
10
+ return path.join(os.homedir(), ".cache", "opencode");
11
+ }
12
+ export const CACHE_DIR = getCacheDir();
13
+ export const INSTALLED_PACKAGE_JSON = path.join(CACHE_DIR, "node_modules", PACKAGE_NAME, "package.json");
14
+ function getUserConfigDir() {
15
+ if (process.platform === "win32") {
16
+ return process.env.APPDATA ?? path.join(os.homedir(), "AppData", "Roaming");
17
+ }
18
+ return process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config");
19
+ }
20
+ export const USER_CONFIG_DIR = getUserConfigDir();
21
+ export const USER_OPENCODE_CONFIG = path.join(USER_CONFIG_DIR, "opencode", "opencode.json");
22
+ export const USER_OPENCODE_CONFIG_JSONC = path.join(USER_CONFIG_DIR, "opencode", "opencode.jsonc");
@@ -0,0 +1,33 @@
1
+ import type { AutoUpdateCheckerOptions } from "./types";
2
+ interface PluginClient {
3
+ tui: {
4
+ showToast(options: {
5
+ body: {
6
+ title?: string;
7
+ message: string;
8
+ variant: "info" | "warning" | "success" | "error";
9
+ duration?: number;
10
+ };
11
+ }): Promise<unknown>;
12
+ };
13
+ }
14
+ interface SessionCreatedEvent {
15
+ type: "session.created";
16
+ properties?: {
17
+ info?: {
18
+ parentID?: string;
19
+ };
20
+ };
21
+ }
22
+ type PluginEvent = SessionCreatedEvent | {
23
+ type: string;
24
+ properties?: unknown;
25
+ };
26
+ export declare function createAutoUpdateCheckerHook(client: PluginClient, directory: string, options?: AutoUpdateCheckerOptions): {
27
+ event: ({ event }: {
28
+ event: PluginEvent;
29
+ }) => void;
30
+ };
31
+ export type { UpdateCheckResult, AutoUpdateCheckerOptions } from "./types";
32
+ export { checkForUpdate, getCachedVersion, getLatestVersion } from "./checker";
33
+ export { invalidatePackage, invalidateCache } from "./cache";
@@ -0,0 +1,121 @@
1
+ import { getCachedVersion, getLocalDevVersion, findPluginEntry, getLatestVersion, updatePinnedVersion } from "./checker";
2
+ import { invalidatePackage } from "./cache";
3
+ import { PACKAGE_NAME } from "./constants";
4
+ import { logAutoUpdate } from "./logging";
5
+ export function createAutoUpdateCheckerHook(client, directory, options = {}) {
6
+ const { showStartupToast = true, autoUpdate = true } = options;
7
+ let hasChecked = false;
8
+ return {
9
+ event: ({ event }) => {
10
+ if (event.type !== "session.created")
11
+ return;
12
+ if (hasChecked)
13
+ return;
14
+ const props = event.properties;
15
+ if (props?.info?.parentID)
16
+ return;
17
+ hasChecked = true;
18
+ setTimeout(() => {
19
+ const localDevVersion = getLocalDevVersion(directory);
20
+ if (localDevVersion) {
21
+ if (showStartupToast) {
22
+ showLocalDevToast(client, localDevVersion).catch(() => { });
23
+ }
24
+ logAutoUpdate("Local development mode");
25
+ return;
26
+ }
27
+ runBackgroundUpdateCheck(client, directory, autoUpdate).catch((err) => {
28
+ logAutoUpdate(`Background update check failed: ${err}`);
29
+ });
30
+ }, 0);
31
+ },
32
+ };
33
+ }
34
+ async function runBackgroundUpdateCheck(client, directory, autoUpdate) {
35
+ const pluginInfo = findPluginEntry(directory);
36
+ if (!pluginInfo) {
37
+ logAutoUpdate("Plugin not found in config");
38
+ return;
39
+ }
40
+ const cachedVersion = getCachedVersion();
41
+ const currentVersion = cachedVersion ?? pluginInfo.pinnedVersion;
42
+ if (!currentVersion) {
43
+ logAutoUpdate("No version found (cached or pinned)");
44
+ return;
45
+ }
46
+ if (currentVersion.includes('-')) {
47
+ logAutoUpdate(`Prerelease version (${currentVersion}), skipping auto-update`);
48
+ return;
49
+ }
50
+ const latestVersion = await getLatestVersion();
51
+ if (!latestVersion) {
52
+ logAutoUpdate("Failed to fetch latest version");
53
+ return;
54
+ }
55
+ if (currentVersion === latestVersion) {
56
+ logAutoUpdate("Already on latest version");
57
+ return;
58
+ }
59
+ logAutoUpdate(`Update available: ${currentVersion} → ${latestVersion}`);
60
+ if (!autoUpdate) {
61
+ await showUpdateAvailableToast(client, latestVersion);
62
+ logAutoUpdate("Auto-update disabled, notification only");
63
+ return;
64
+ }
65
+ if (pluginInfo.isPinned) {
66
+ const updated = updatePinnedVersion(pluginInfo.configPath, pluginInfo.entry, latestVersion);
67
+ if (updated) {
68
+ invalidatePackage(PACKAGE_NAME);
69
+ await showAutoUpdatedToast(client, currentVersion, latestVersion);
70
+ logAutoUpdate(`Config updated: ${pluginInfo.entry} → ${PACKAGE_NAME}@${latestVersion}`);
71
+ }
72
+ else {
73
+ await showUpdateAvailableToast(client, latestVersion);
74
+ }
75
+ }
76
+ else {
77
+ invalidatePackage(PACKAGE_NAME);
78
+ await showUpdateAvailableToast(client, latestVersion);
79
+ }
80
+ }
81
+ async function showUpdateAvailableToast(client, latestVersion) {
82
+ await client.tui
83
+ .showToast({
84
+ body: {
85
+ title: `Antigravity Auth Update`,
86
+ message: `v${latestVersion} available. Restart OpenCode to apply.`,
87
+ variant: "info",
88
+ duration: 8000,
89
+ },
90
+ })
91
+ .catch(() => { });
92
+ logAutoUpdate(`Update available toast shown: v${latestVersion}`);
93
+ }
94
+ async function showAutoUpdatedToast(client, oldVersion, newVersion) {
95
+ await client.tui
96
+ .showToast({
97
+ body: {
98
+ title: `Antigravity Auth Updated!`,
99
+ message: `v${oldVersion} → v${newVersion}\nRestart OpenCode to apply.`,
100
+ variant: "success",
101
+ duration: 8000,
102
+ },
103
+ })
104
+ .catch(() => { });
105
+ logAutoUpdate(`Auto-updated toast shown: v${oldVersion} → v${newVersion}`);
106
+ }
107
+ async function showLocalDevToast(client, version) {
108
+ await client.tui
109
+ .showToast({
110
+ body: {
111
+ title: `Antigravity Auth ${version} (dev)`,
112
+ message: "Running in local development mode.",
113
+ variant: "warning",
114
+ duration: 5000,
115
+ },
116
+ })
117
+ .catch(() => { });
118
+ logAutoUpdate(`Local dev toast shown: v${version}`);
119
+ }
120
+ export { checkForUpdate, getCachedVersion, getLatestVersion } from "./checker";
121
+ export { invalidatePackage, invalidateCache } from "./cache";
@@ -0,0 +1,2 @@
1
+ export declare function formatAutoUpdateLogMessage(message: string): string;
2
+ export declare function logAutoUpdate(message: string): void;
@@ -0,0 +1,8 @@
1
+ import { debugLogToFile } from "../../plugin/debug";
2
+ const AUTO_UPDATE_LOG_PREFIX = "[auto-update-checker]";
3
+ export function formatAutoUpdateLogMessage(message) {
4
+ return `${AUTO_UPDATE_LOG_PREFIX} ${message}`;
5
+ }
6
+ export function logAutoUpdate(message) {
7
+ debugLogToFile(formatAutoUpdateLogMessage(message));
8
+ }
@@ -0,0 +1,24 @@
1
+ export interface NpmDistTags {
2
+ latest: string;
3
+ [key: string]: string;
4
+ }
5
+ export interface OpencodeConfig {
6
+ plugin?: string[];
7
+ [key: string]: unknown;
8
+ }
9
+ export interface PackageJson {
10
+ version: string;
11
+ name?: string;
12
+ [key: string]: unknown;
13
+ }
14
+ export interface UpdateCheckResult {
15
+ needsUpdate: boolean;
16
+ currentVersion: string | null;
17
+ latestVersion: string | null;
18
+ isLocalDev: boolean;
19
+ isPinned: boolean;
20
+ }
21
+ export interface AutoUpdateCheckerOptions {
22
+ showStartupToast?: boolean;
23
+ autoUpdate?: boolean;
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin } from "../opencode/plugin";
2
+ export { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin };
3
+ export { authorizeAntigravity, exchangeAntigravity, } from "./antigravity/oauth";
4
+ export type { AntigravityAuthorization, AntigravityTokenExchangeResult, } from "./antigravity/oauth";
5
+ export default AntigravityCLIOAuthPlugin;
6
+ export declare const server: ({ client, directory }: import("./plugin/types").PluginContext) => Promise<import("./plugin/types").PluginResult>;
@@ -0,0 +1,5 @@
1
+ import { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin } from "../opencode/plugin";
2
+ export { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin };
3
+ export { authorizeAntigravity, exchangeAntigravity, } from "./antigravity/oauth";
4
+ export default AntigravityCLIOAuthPlugin;
5
+ export const server = AntigravityCLIOAuthPlugin;
@@ -0,0 +1,173 @@
1
+ import { type AccountStorageV4, type AccountMetadataV3, type RateLimitStateV3, type ModelFamily, type HeaderStyle, type CooldownReason } from "./storage";
2
+ import type { OAuthAuthDetails, RefreshParts } from "./types";
3
+ import type { AccountSelectionStrategy } from "./config/schema";
4
+ import { type Fingerprint, type FingerprintVersion } from "./fingerprint";
5
+ import type { QuotaGroup, QuotaGroupSummary } from "./quota";
6
+ export type { ModelFamily, HeaderStyle, CooldownReason } from "./storage";
7
+ export type { AccountSelectionStrategy } from "./config/schema";
8
+ export type RateLimitReason = "QUOTA_EXHAUSTED" | "RATE_LIMIT_EXCEEDED" | "MODEL_CAPACITY_EXHAUSTED" | "SERVER_ERROR" | "UNKNOWN";
9
+ export interface RateLimitBackoffResult {
10
+ backoffMs: number;
11
+ reason: RateLimitReason;
12
+ }
13
+ export declare function parseRateLimitReason(reason: string | undefined, message: string | undefined, status?: number): RateLimitReason;
14
+ export declare function calculateBackoffMs(reason: RateLimitReason, consecutiveFailures: number, retryAfterMs?: number | null): number;
15
+ export type BaseQuotaKey = "claude" | "gemini-antigravity" | "gemini-cli";
16
+ export type QuotaKey = BaseQuotaKey | `${BaseQuotaKey}:${string}`;
17
+ export interface ManagedAccount {
18
+ index: number;
19
+ email?: string;
20
+ addedAt: number;
21
+ lastUsed: number;
22
+ parts: RefreshParts;
23
+ access?: string;
24
+ expires?: number;
25
+ enabled: boolean;
26
+ proxies?: string[];
27
+ rateLimitResetTimes: RateLimitStateV3;
28
+ lastSwitchReason?: "rate-limit" | "initial" | "rotation";
29
+ coolingDownUntil?: number;
30
+ cooldownReason?: CooldownReason;
31
+ touchedForQuota: Record<string, number>;
32
+ consecutiveFailures?: number;
33
+ /** Timestamp of last failure for TTL-based reset of consecutiveFailures */
34
+ lastFailureTime?: number;
35
+ /** Per-account device fingerprint for rate limit mitigation */
36
+ fingerprint?: import("./fingerprint").Fingerprint;
37
+ /** History of previous fingerprints for this account */
38
+ fingerprintHistory?: FingerprintVersion[];
39
+ /** Cached quota data from last checkAccountsQuota() call */
40
+ cachedQuota?: Partial<Record<QuotaGroup, QuotaGroupSummary>>;
41
+ cachedQuotaUpdatedAt?: number;
42
+ verificationRequired?: boolean;
43
+ verificationRequiredAt?: number;
44
+ verificationRequiredReason?: string;
45
+ verificationUrl?: string;
46
+ }
47
+ /**
48
+ * Resolve the quota group for soft quota checks.
49
+ *
50
+ * When a model string is available, we can precisely determine the quota group.
51
+ * When model is null/undefined, we fall back based on family:
52
+ * - Claude → "claude" quota group
53
+ * - Gemini → "gemini-pro" (conservative fallback; may misclassify flash models)
54
+ *
55
+ * @param family - The model family ("claude" | "gemini")
56
+ * @param model - Optional model string for precise resolution
57
+ * @returns The QuotaGroup to use for soft quota checks
58
+ */
59
+ export declare function resolveQuotaGroup(family: ModelFamily, model?: string | null): QuotaGroup;
60
+ export declare function computeSoftQuotaCacheTtlMs(ttlConfig: "auto" | number, refreshIntervalMinutes: number): number;
61
+ /**
62
+ * In-memory multi-account manager with sticky account selection.
63
+ *
64
+ * Uses the same account until it hits a rate limit (429), then switches.
65
+ * Rate limits are tracked per-model-family (claude/gemini) so an account
66
+ * rate-limited for Claude can still be used for Gemini.
67
+ *
68
+ * Source of truth for the pool is `antigravity-accounts.json`.
69
+ */
70
+ export declare class AccountManager {
71
+ private accounts;
72
+ private cursor;
73
+ private currentAccountIndexByFamily;
74
+ private sessionOffsetApplied;
75
+ private lastToastAccountIndex;
76
+ private lastToastTime;
77
+ private savePending;
78
+ private saveTimeout;
79
+ private savePromiseResolvers;
80
+ static loadFromDisk(authFallback?: OAuthAuthDetails): Promise<AccountManager>;
81
+ constructor(authFallback?: OAuthAuthDetails, stored?: AccountStorageV4 | null);
82
+ getAccountCount(): number;
83
+ getTotalAccountCount(): number;
84
+ getEnabledAccounts(): ManagedAccount[];
85
+ getAccountsSnapshot(): ManagedAccount[];
86
+ getCurrentAccountForFamily(family: ModelFamily): ManagedAccount | null;
87
+ markSwitched(account: ManagedAccount, reason: "rate-limit" | "initial" | "rotation", family: ModelFamily): void;
88
+ /**
89
+ * Check if we should show an account switch toast.
90
+ * Debounces repeated toasts for the same account.
91
+ */
92
+ shouldShowAccountToast(accountIndex: number, debounceMs?: number): boolean;
93
+ markToastShown(accountIndex: number): void;
94
+ getCurrentOrNextForFamily(family: ModelFamily, model?: string | null, strategy?: AccountSelectionStrategy, headerStyle?: HeaderStyle, pidOffsetEnabled?: boolean, softQuotaThresholdPercent?: number, softQuotaCacheTtlMs?: number): ManagedAccount | null;
95
+ getNextForFamily(family: ModelFamily, model?: string | null, headerStyle?: HeaderStyle, softQuotaThresholdPercent?: number, softQuotaCacheTtlMs?: number): ManagedAccount | null;
96
+ markRateLimited(account: ManagedAccount, retryAfterMs: number, family: ModelFamily, headerStyle?: HeaderStyle, model?: string | null): void;
97
+ /**
98
+ * Mark an account as used after a successful API request.
99
+ * This updates the lastUsed timestamp for freshness calculations.
100
+ * Should be called AFTER request completion, not during account selection.
101
+ */
102
+ markAccountUsed(accountIndex: number): void;
103
+ markRateLimitedWithReason(account: ManagedAccount, family: ModelFamily, headerStyle: HeaderStyle, model?: string | null, reason?: RateLimitReason, retryAfterMs?: number, ttlMs?: number): number;
104
+ markRequestSuccess(account: ManagedAccount): void;
105
+ clearAllRateLimitsForFamily(family: ModelFamily, model?: string | null): void;
106
+ shouldTryOptimisticReset(family: ModelFamily, model?: string | null): boolean;
107
+ markAccountCoolingDown(account: ManagedAccount, cooldownMs: number, reason: CooldownReason): void;
108
+ isAccountCoolingDown(account: ManagedAccount): boolean;
109
+ clearAccountCooldown(account: ManagedAccount): void;
110
+ getAccountCooldownReason(account: ManagedAccount): CooldownReason | undefined;
111
+ markTouchedForQuota(account: ManagedAccount, quotaKey: string): void;
112
+ isFreshForQuota(account: ManagedAccount, quotaKey: string): boolean;
113
+ getFreshAccountsForQuota(quotaKey: string, family: ModelFamily, model?: string | null): ManagedAccount[];
114
+ isRateLimitedForHeaderStyle(account: ManagedAccount, family: ModelFamily, headerStyle: HeaderStyle, model?: string | null): boolean;
115
+ getAvailableHeaderStyle(account: ManagedAccount, family: ModelFamily, model?: string | null): HeaderStyle | null;
116
+ /**
117
+ * Check if any OTHER account has antigravity quota available for the given family/model.
118
+ *
119
+ * Used to determine whether to switch accounts vs fall back to gemini-cli:
120
+ * - If true: Switch to another account (preserve antigravity priority)
121
+ * - If false: All accounts exhausted antigravity, safe to fall back to gemini-cli
122
+ *
123
+ * @param currentAccountIndex - Index of the current account (will be excluded from check)
124
+ * @param family - Model family ("gemini" or "claude")
125
+ * @param model - Optional model name for model-specific rate limits
126
+ * @returns true if any other enabled, non-cooling-down account has antigravity available
127
+ */
128
+ hasOtherAccountWithAntigravityAvailable(currentAccountIndex: number, family: ModelFamily, model?: string | null): boolean;
129
+ setAccountEnabled(accountIndex: number, enabled: boolean): boolean;
130
+ markAccountVerificationRequired(accountIndex: number, reason?: string, verifyUrl?: string): boolean;
131
+ clearAccountVerificationRequired(accountIndex: number, enableAccount?: boolean): boolean;
132
+ removeAccountByIndex(accountIndex: number): boolean;
133
+ removeAccount(account: ManagedAccount): boolean;
134
+ updateFromAuth(account: ManagedAccount, auth: OAuthAuthDetails): void;
135
+ toAuthDetails(account: ManagedAccount): OAuthAuthDetails;
136
+ getMinWaitTimeForFamily(family: ModelFamily, model?: string | null, headerStyle?: HeaderStyle, strict?: boolean): number;
137
+ getAccounts(): ManagedAccount[];
138
+ saveToDisk(): Promise<void>;
139
+ requestSaveToDisk(): void;
140
+ flushSaveToDisk(): Promise<void>;
141
+ private executeSave;
142
+ /**
143
+ * Regenerate fingerprint for an account, saving the old one to history.
144
+ * @param accountIndex - Index of the account to regenerate fingerprint for
145
+ * @returns The new fingerprint, or null if account not found
146
+ */
147
+ regenerateAccountFingerprint(accountIndex: number): Fingerprint | null;
148
+ /**
149
+ * Restore a fingerprint from history for an account.
150
+ * @param accountIndex - Index of the account
151
+ * @param historyIndex - Index in the fingerprint history to restore from (0 = most recent)
152
+ * @returns The restored fingerprint, or null if account/history not found
153
+ */
154
+ restoreAccountFingerprint(accountIndex: number, historyIndex: number): Fingerprint | null;
155
+ /**
156
+ * Get fingerprint history for an account.
157
+ * @param accountIndex - Index of the account
158
+ * @returns Array of fingerprint versions, or empty array if not found
159
+ */
160
+ getAccountFingerprintHistory(accountIndex: number): FingerprintVersion[];
161
+ updateQuotaCache(accountIndex: number, quotaGroups: Partial<Record<QuotaGroup, QuotaGroupSummary>>): void;
162
+ isAccountOverSoftQuota(account: ManagedAccount, family: ModelFamily, thresholdPercent: number, cacheTtlMs: number, model?: string | null): boolean;
163
+ getAccountsForQuotaCheck(): AccountMetadataV3[];
164
+ getOldestQuotaCacheAge(): number | null;
165
+ areAllAccountsOverSoftQuota(family: ModelFamily, thresholdPercent: number, cacheTtlMs: number, model?: string | null): boolean;
166
+ /**
167
+ * Get minimum wait time until any account's soft quota resets.
168
+ * Returns 0 if any account is available (not over threshold).
169
+ * Returns the minimum resetTime across all over-threshold accounts.
170
+ * Returns null if no resetTime data is available.
171
+ */
172
+ getMinWaitTimeForSoftQuota(family: ModelFamily, thresholdPercent: number, cacheTtlMs: number, model?: string | null): number | null;
173
+ }