antigravity-auth 1.6.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/README.md +79 -41
  2. package/dist/cli.js +17854 -0
  3. package/dist/handler.js +25147 -0
  4. package/dist/index.js +25138 -5
  5. package/package.json +66 -54
  6. package/dist/antigravity/oauth.d.ts +0 -30
  7. package/dist/antigravity/oauth.js +0 -170
  8. package/dist/claude/login.d.ts +0 -7
  9. package/dist/claude/login.js +0 -480
  10. package/dist/claude/menu-helpers.d.ts +0 -22
  11. package/dist/claude/menu-helpers.js +0 -281
  12. package/dist/claude/proxy-manager.d.ts +0 -11
  13. package/dist/claude/proxy-manager.js +0 -129
  14. package/dist/claude/proxy.d.ts +0 -1
  15. package/dist/claude/proxy.js +0 -733
  16. package/dist/constants.d.ts +0 -138
  17. package/dist/constants.js +0 -216
  18. package/dist/hooks/auto-update-checker/cache.d.ts +0 -2
  19. package/dist/hooks/auto-update-checker/cache.js +0 -70
  20. package/dist/hooks/auto-update-checker/checker.d.ts +0 -15
  21. package/dist/hooks/auto-update-checker/checker.js +0 -233
  22. package/dist/hooks/auto-update-checker/constants.d.ts +0 -8
  23. package/dist/hooks/auto-update-checker/constants.js +0 -22
  24. package/dist/hooks/auto-update-checker/index.d.ts +0 -33
  25. package/dist/hooks/auto-update-checker/index.js +0 -121
  26. package/dist/hooks/auto-update-checker/logging.d.ts +0 -2
  27. package/dist/hooks/auto-update-checker/logging.js +0 -8
  28. package/dist/hooks/auto-update-checker/types.d.ts +0 -24
  29. package/dist/hooks/auto-update-checker/types.js +0 -1
  30. package/dist/index.d.ts +0 -6
  31. package/dist/opencode/hooks/auto-update-checker/cache.d.ts +0 -2
  32. package/dist/opencode/hooks/auto-update-checker/cache.js +0 -70
  33. package/dist/opencode/hooks/auto-update-checker/checker.d.ts +0 -15
  34. package/dist/opencode/hooks/auto-update-checker/checker.js +0 -233
  35. package/dist/opencode/hooks/auto-update-checker/constants.d.ts +0 -8
  36. package/dist/opencode/hooks/auto-update-checker/constants.js +0 -22
  37. package/dist/opencode/hooks/auto-update-checker/index.d.ts +0 -33
  38. package/dist/opencode/hooks/auto-update-checker/index.js +0 -121
  39. package/dist/opencode/hooks/auto-update-checker/logging.d.ts +0 -2
  40. package/dist/opencode/hooks/auto-update-checker/logging.js +0 -8
  41. package/dist/opencode/hooks/auto-update-checker/types.d.ts +0 -24
  42. package/dist/opencode/hooks/auto-update-checker/types.js +0 -1
  43. package/dist/opencode/plugin.d.ts +0 -29
  44. package/dist/opencode/plugin.js +0 -2954
  45. package/dist/plugin/accounts.d.ts +0 -173
  46. package/dist/plugin/accounts.js +0 -966
  47. package/dist/plugin/auth.d.ts +0 -20
  48. package/dist/plugin/auth.js +0 -44
  49. package/dist/plugin/cache/index.d.ts +0 -4
  50. package/dist/plugin/cache/index.js +0 -4
  51. package/dist/plugin/cache/signature-cache.d.ts +0 -110
  52. package/dist/plugin/cache/signature-cache.js +0 -347
  53. package/dist/plugin/cache.d.ts +0 -43
  54. package/dist/plugin/cache.js +0 -180
  55. package/dist/plugin/cli.d.ts +0 -26
  56. package/dist/plugin/cli.js +0 -126
  57. package/dist/plugin/config/index.d.ts +0 -15
  58. package/dist/plugin/config/index.js +0 -15
  59. package/dist/plugin/config/loader.d.ts +0 -38
  60. package/dist/plugin/config/loader.js +0 -150
  61. package/dist/plugin/config/models.d.ts +0 -26
  62. package/dist/plugin/config/models.js +0 -95
  63. package/dist/plugin/config/schema.d.ts +0 -144
  64. package/dist/plugin/config/schema.js +0 -458
  65. package/dist/plugin/config/updater.d.ts +0 -76
  66. package/dist/plugin/config/updater.js +0 -205
  67. package/dist/plugin/core/streaming/index.d.ts +0 -2
  68. package/dist/plugin/core/streaming/index.js +0 -2
  69. package/dist/plugin/core/streaming/transformer.d.ts +0 -9
  70. package/dist/plugin/core/streaming/transformer.js +0 -301
  71. package/dist/plugin/core/streaming/types.d.ts +0 -28
  72. package/dist/plugin/core/streaming/types.js +0 -1
  73. package/dist/plugin/debug.d.ts +0 -93
  74. package/dist/plugin/debug.js +0 -375
  75. package/dist/plugin/errors.d.ts +0 -27
  76. package/dist/plugin/errors.js +0 -41
  77. package/dist/plugin/fingerprint.d.ts +0 -69
  78. package/dist/plugin/fingerprint.js +0 -137
  79. package/dist/plugin/image-saver.d.ts +0 -24
  80. package/dist/plugin/image-saver.js +0 -78
  81. package/dist/plugin/logger.d.ts +0 -35
  82. package/dist/plugin/logger.js +0 -67
  83. package/dist/plugin/logging-utils.d.ts +0 -22
  84. package/dist/plugin/logging-utils.js +0 -91
  85. package/dist/plugin/project.d.ts +0 -32
  86. package/dist/plugin/project.js +0 -229
  87. package/dist/plugin/quota.d.ts +0 -34
  88. package/dist/plugin/quota.js +0 -261
  89. package/dist/plugin/recovery/constants.d.ts +0 -21
  90. package/dist/plugin/recovery/constants.js +0 -42
  91. package/dist/plugin/recovery/index.d.ts +0 -11
  92. package/dist/plugin/recovery/index.js +0 -11
  93. package/dist/plugin/recovery/storage.d.ts +0 -23
  94. package/dist/plugin/recovery/storage.js +0 -340
  95. package/dist/plugin/recovery/types.d.ts +0 -115
  96. package/dist/plugin/recovery/types.js +0 -6
  97. package/dist/plugin/recovery.d.ts +0 -60
  98. package/dist/plugin/recovery.js +0 -360
  99. package/dist/plugin/refresh-queue.d.ts +0 -99
  100. package/dist/plugin/refresh-queue.js +0 -235
  101. package/dist/plugin/request-helpers.d.ts +0 -281
  102. package/dist/plugin/request-helpers.js +0 -2200
  103. package/dist/plugin/request.d.ts +0 -110
  104. package/dist/plugin/request.js +0 -1489
  105. package/dist/plugin/rotation.d.ts +0 -182
  106. package/dist/plugin/rotation.js +0 -364
  107. package/dist/plugin/search.d.ts +0 -31
  108. package/dist/plugin/search.js +0 -185
  109. package/dist/plugin/server.d.ts +0 -22
  110. package/dist/plugin/server.js +0 -306
  111. package/dist/plugin/storage.d.ts +0 -136
  112. package/dist/plugin/storage.js +0 -599
  113. package/dist/plugin/stores/signature-store.d.ts +0 -4
  114. package/dist/plugin/stores/signature-store.js +0 -24
  115. package/dist/plugin/thinking-recovery.d.ts +0 -89
  116. package/dist/plugin/thinking-recovery.js +0 -289
  117. package/dist/plugin/token.d.ts +0 -18
  118. package/dist/plugin/token.js +0 -127
  119. package/dist/plugin/transform/claude.d.ts +0 -79
  120. package/dist/plugin/transform/claude.js +0 -256
  121. package/dist/plugin/transform/cross-model-sanitizer.d.ts +0 -34
  122. package/dist/plugin/transform/cross-model-sanitizer.js +0 -224
  123. package/dist/plugin/transform/gemini.d.ts +0 -132
  124. package/dist/plugin/transform/gemini.js +0 -659
  125. package/dist/plugin/transform/index.d.ts +0 -14
  126. package/dist/plugin/transform/index.js +0 -9
  127. package/dist/plugin/transform/model-resolver.d.ts +0 -98
  128. package/dist/plugin/transform/model-resolver.js +0 -320
  129. package/dist/plugin/transform/types.d.ts +0 -110
  130. package/dist/plugin/transform/types.js +0 -1
  131. package/dist/plugin/types.d.ts +0 -95
  132. package/dist/plugin/types.js +0 -1
  133. package/dist/plugin/ui/ansi.d.ts +0 -31
  134. package/dist/plugin/ui/ansi.js +0 -45
  135. package/dist/plugin/ui/auth-menu.d.ts +0 -47
  136. package/dist/plugin/ui/auth-menu.js +0 -199
  137. package/dist/plugin/ui/confirm.d.ts +0 -1
  138. package/dist/plugin/ui/confirm.js +0 -14
  139. package/dist/plugin/ui/select.d.ts +0 -22
  140. package/dist/plugin/ui/select.js +0 -243
  141. package/dist/plugin/version.d.ts +0 -18
  142. package/dist/plugin/version.js +0 -79
  143. package/dist/src/antigravity/oauth.d.ts +0 -30
  144. package/dist/src/antigravity/oauth.js +0 -170
  145. package/dist/src/constants.d.ts +0 -138
  146. package/dist/src/constants.js +0 -216
  147. package/dist/src/hooks/auto-update-checker/cache.d.ts +0 -2
  148. package/dist/src/hooks/auto-update-checker/cache.js +0 -70
  149. package/dist/src/hooks/auto-update-checker/checker.d.ts +0 -15
  150. package/dist/src/hooks/auto-update-checker/checker.js +0 -233
  151. package/dist/src/hooks/auto-update-checker/constants.d.ts +0 -8
  152. package/dist/src/hooks/auto-update-checker/constants.js +0 -22
  153. package/dist/src/hooks/auto-update-checker/index.d.ts +0 -33
  154. package/dist/src/hooks/auto-update-checker/index.js +0 -121
  155. package/dist/src/hooks/auto-update-checker/logging.d.ts +0 -2
  156. package/dist/src/hooks/auto-update-checker/logging.js +0 -8
  157. package/dist/src/hooks/auto-update-checker/types.d.ts +0 -24
  158. package/dist/src/hooks/auto-update-checker/types.js +0 -1
  159. package/dist/src/index.d.ts +0 -6
  160. package/dist/src/index.js +0 -5
  161. package/dist/src/plugin/accounts.d.ts +0 -173
  162. package/dist/src/plugin/accounts.js +0 -966
  163. package/dist/src/plugin/auth.d.ts +0 -20
  164. package/dist/src/plugin/auth.js +0 -44
  165. package/dist/src/plugin/cache/index.d.ts +0 -4
  166. package/dist/src/plugin/cache/index.js +0 -4
  167. package/dist/src/plugin/cache/signature-cache.d.ts +0 -110
  168. package/dist/src/plugin/cache/signature-cache.js +0 -347
  169. package/dist/src/plugin/cache.d.ts +0 -43
  170. package/dist/src/plugin/cache.js +0 -180
  171. package/dist/src/plugin/cli.d.ts +0 -26
  172. package/dist/src/plugin/cli.js +0 -126
  173. package/dist/src/plugin/config/index.d.ts +0 -15
  174. package/dist/src/plugin/config/index.js +0 -15
  175. package/dist/src/plugin/config/loader.d.ts +0 -38
  176. package/dist/src/plugin/config/loader.js +0 -150
  177. package/dist/src/plugin/config/models.d.ts +0 -26
  178. package/dist/src/plugin/config/models.js +0 -95
  179. package/dist/src/plugin/config/schema.d.ts +0 -144
  180. package/dist/src/plugin/config/schema.js +0 -458
  181. package/dist/src/plugin/config/updater.d.ts +0 -76
  182. package/dist/src/plugin/config/updater.js +0 -205
  183. package/dist/src/plugin/core/streaming/index.d.ts +0 -2
  184. package/dist/src/plugin/core/streaming/index.js +0 -2
  185. package/dist/src/plugin/core/streaming/transformer.d.ts +0 -9
  186. package/dist/src/plugin/core/streaming/transformer.js +0 -301
  187. package/dist/src/plugin/core/streaming/types.d.ts +0 -28
  188. package/dist/src/plugin/core/streaming/types.js +0 -1
  189. package/dist/src/plugin/debug.d.ts +0 -93
  190. package/dist/src/plugin/debug.js +0 -375
  191. package/dist/src/plugin/errors.d.ts +0 -27
  192. package/dist/src/plugin/errors.js +0 -41
  193. package/dist/src/plugin/fingerprint.d.ts +0 -69
  194. package/dist/src/plugin/fingerprint.js +0 -137
  195. package/dist/src/plugin/image-saver.d.ts +0 -24
  196. package/dist/src/plugin/image-saver.js +0 -78
  197. package/dist/src/plugin/logger.d.ts +0 -35
  198. package/dist/src/plugin/logger.js +0 -67
  199. package/dist/src/plugin/logging-utils.d.ts +0 -22
  200. package/dist/src/plugin/logging-utils.js +0 -91
  201. package/dist/src/plugin/project.d.ts +0 -32
  202. package/dist/src/plugin/project.js +0 -229
  203. package/dist/src/plugin/quota.d.ts +0 -34
  204. package/dist/src/plugin/quota.js +0 -261
  205. package/dist/src/plugin/recovery/constants.d.ts +0 -21
  206. package/dist/src/plugin/recovery/constants.js +0 -42
  207. package/dist/src/plugin/recovery/index.d.ts +0 -11
  208. package/dist/src/plugin/recovery/index.js +0 -11
  209. package/dist/src/plugin/recovery/storage.d.ts +0 -23
  210. package/dist/src/plugin/recovery/storage.js +0 -340
  211. package/dist/src/plugin/recovery/types.d.ts +0 -115
  212. package/dist/src/plugin/recovery/types.js +0 -6
  213. package/dist/src/plugin/recovery.d.ts +0 -60
  214. package/dist/src/plugin/recovery.js +0 -360
  215. package/dist/src/plugin/refresh-queue.d.ts +0 -99
  216. package/dist/src/plugin/refresh-queue.js +0 -235
  217. package/dist/src/plugin/request-helpers.d.ts +0 -281
  218. package/dist/src/plugin/request-helpers.js +0 -2200
  219. package/dist/src/plugin/request.d.ts +0 -110
  220. package/dist/src/plugin/request.js +0 -1489
  221. package/dist/src/plugin/rotation.d.ts +0 -182
  222. package/dist/src/plugin/rotation.js +0 -364
  223. package/dist/src/plugin/search.d.ts +0 -31
  224. package/dist/src/plugin/search.js +0 -185
  225. package/dist/src/plugin/server.d.ts +0 -22
  226. package/dist/src/plugin/server.js +0 -306
  227. package/dist/src/plugin/storage.d.ts +0 -136
  228. package/dist/src/plugin/storage.js +0 -599
  229. package/dist/src/plugin/stores/signature-store.d.ts +0 -4
  230. package/dist/src/plugin/stores/signature-store.js +0 -24
  231. package/dist/src/plugin/thinking-recovery.d.ts +0 -89
  232. package/dist/src/plugin/thinking-recovery.js +0 -289
  233. package/dist/src/plugin/token.d.ts +0 -18
  234. package/dist/src/plugin/token.js +0 -127
  235. package/dist/src/plugin/transform/claude.d.ts +0 -79
  236. package/dist/src/plugin/transform/claude.js +0 -256
  237. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +0 -34
  238. package/dist/src/plugin/transform/cross-model-sanitizer.js +0 -224
  239. package/dist/src/plugin/transform/gemini.d.ts +0 -132
  240. package/dist/src/plugin/transform/gemini.js +0 -659
  241. package/dist/src/plugin/transform/index.d.ts +0 -14
  242. package/dist/src/plugin/transform/index.js +0 -9
  243. package/dist/src/plugin/transform/model-resolver.d.ts +0 -98
  244. package/dist/src/plugin/transform/model-resolver.js +0 -320
  245. package/dist/src/plugin/transform/types.d.ts +0 -110
  246. package/dist/src/plugin/transform/types.js +0 -1
  247. package/dist/src/plugin/types.d.ts +0 -95
  248. package/dist/src/plugin/types.js +0 -1
  249. package/dist/src/plugin/ui/ansi.d.ts +0 -31
  250. package/dist/src/plugin/ui/ansi.js +0 -45
  251. package/dist/src/plugin/ui/auth-menu.d.ts +0 -47
  252. package/dist/src/plugin/ui/auth-menu.js +0 -199
  253. package/dist/src/plugin/ui/confirm.d.ts +0 -1
  254. package/dist/src/plugin/ui/confirm.js +0 -14
  255. package/dist/src/plugin/ui/select.d.ts +0 -22
  256. package/dist/src/plugin/ui/select.js +0 -243
  257. package/dist/src/plugin/version.d.ts +0 -18
  258. package/dist/src/plugin/version.js +0 -79
@@ -1,8 +0,0 @@
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;
@@ -1,22 +0,0 @@
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");
@@ -1,33 +0,0 @@
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";
@@ -1,121 +0,0 @@
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";
@@ -1,2 +0,0 @@
1
- export declare function formatAutoUpdateLogMessage(message: string): string;
2
- export declare function logAutoUpdate(message: string): void;
@@ -1,8 +0,0 @@
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
- }
@@ -1,24 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export {};
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin } from "./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: any;
@@ -1,2 +0,0 @@
1
- export declare function invalidatePackage(packageName?: string): boolean;
2
- export declare function invalidateCache(): boolean;
@@ -1,70 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import { CACHE_DIR, PACKAGE_NAME } from "./constants";
4
- function stripTrailingCommas(json) {
5
- return json.replace(/,(\s*[}\]])/g, "$1");
6
- }
7
- function removeFromBunLock(packageName) {
8
- const lockPath = path.join(CACHE_DIR, "bun.lock");
9
- if (!fs.existsSync(lockPath))
10
- return false;
11
- try {
12
- const content = fs.readFileSync(lockPath, "utf-8");
13
- const lock = JSON.parse(stripTrailingCommas(content));
14
- let modified = false;
15
- if (lock.workspaces?.[""]?.dependencies?.[packageName]) {
16
- delete lock.workspaces[""].dependencies[packageName];
17
- modified = true;
18
- }
19
- if (lock.packages?.[packageName]) {
20
- delete lock.packages[packageName];
21
- modified = true;
22
- }
23
- if (modified) {
24
- fs.writeFileSync(lockPath, JSON.stringify(lock, null, 2));
25
- console.log(`[auto-update-checker] Removed from bun.lock: ${packageName}`);
26
- }
27
- return modified;
28
- }
29
- catch {
30
- return false;
31
- }
32
- }
33
- export function invalidatePackage(packageName = PACKAGE_NAME) {
34
- try {
35
- const pkgDir = path.join(CACHE_DIR, "node_modules", packageName);
36
- const pkgJsonPath = path.join(CACHE_DIR, "package.json");
37
- let packageRemoved = false;
38
- let dependencyRemoved = false;
39
- let lockRemoved = false;
40
- if (fs.existsSync(pkgDir)) {
41
- fs.rmSync(pkgDir, { recursive: true, force: true });
42
- console.log(`[auto-update-checker] Package removed: ${pkgDir}`);
43
- packageRemoved = true;
44
- }
45
- if (fs.existsSync(pkgJsonPath)) {
46
- const content = fs.readFileSync(pkgJsonPath, "utf-8");
47
- const pkgJson = JSON.parse(content);
48
- if (pkgJson.dependencies?.[packageName]) {
49
- delete pkgJson.dependencies[packageName];
50
- fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
51
- console.log(`[auto-update-checker] Dependency removed from package.json: ${packageName}`);
52
- dependencyRemoved = true;
53
- }
54
- }
55
- lockRemoved = removeFromBunLock(packageName);
56
- if (!packageRemoved && !dependencyRemoved && !lockRemoved) {
57
- console.log(`[auto-update-checker] Package not found, nothing to invalidate: ${packageName}`);
58
- return false;
59
- }
60
- return true;
61
- }
62
- catch (err) {
63
- console.error("[auto-update-checker] Failed to invalidate package:", err);
64
- return false;
65
- }
66
- }
67
- export function invalidateCache() {
68
- console.warn("[auto-update-checker] WARNING: invalidateCache is deprecated, use invalidatePackage");
69
- return invalidatePackage();
70
- }
@@ -1,15 +0,0 @@
1
- import type { UpdateCheckResult } from "./types";
2
- export declare function isLocalDevMode(directory: string): boolean;
3
- export declare function getLocalDevPath(directory: string): string | null;
4
- export declare function getLocalDevVersion(directory: string): string | null;
5
- export interface PluginEntryInfo {
6
- entry: string;
7
- isPinned: boolean;
8
- pinnedVersion: string | null;
9
- configPath: string;
10
- }
11
- export declare function findPluginEntry(directory: string): PluginEntryInfo | null;
12
- export declare function getCachedVersion(): string | null;
13
- export declare function updatePinnedVersion(configPath: string, oldEntry: string, newVersion: string): boolean;
14
- export declare function getLatestVersion(): Promise<string | null>;
15
- export declare function checkForUpdate(directory: string): Promise<UpdateCheckResult>;
@@ -1,233 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
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;
@@ -1,22 +0,0 @@
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");
@@ -1,33 +0,0 @@
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";